GWT emulation issue (Hibernate Validator) - gwt

I'm trying to user super-source to emulate classes GWT has no access to the source code. This ran fine first. But when I use those classes in classes that get validated by Bean Validation (JSR 303), I get an error:
[java] com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
...
...
[java] Caused by: java.lang.NoClassDefFoundError: somepath/myClass
IMHO this looks like I cannot use Emulations in 'shared' packages but only in the 'client'.
any experiences here?
TIA
ujbi

In GWT:
client package compiled to javascript.
Shared package compiles both to java byte code and javascript.
Most probably while compiling to java code no issues raise.But while compiling to java script you might thrown in to this issue.
IMHO This looks like I cannot use Emulations in
'shared' packages but only in the 'client'.
Yes unfortunately that's true.
The code in the shared package must friendly to Compiler. I.e It should emulate.

Related

How fix sigar library when I run spray application?

I have a sbt project written in scala. The project uses akka and spray. There is a class with main function. When I run scala console application sometimes I get
[on-spray-can-akka.actor.default-dispatcher-4] [DEBUG] [2014-11-07 16:48:30,336] Sigar: no sigar-amd64-winnt.dll in java.library.path
org.hyperic.sigar.SigarException: no sigar-amd64-winnt.dll in java.library.path
I do not change anything run it again and it runs well. So it can be run successful or fail several times on end. How to fix this?
UPDATED
Also when it start normal there is a message:
[INFO] [11/07/2014 17:02:36.772] [on-spray-can-akka.actor.default-dispatcher-2]
[Cluster(akka://myApp)] Cluster Node [akka.tcp://myApp#127.0.0.1:2551] - Metrics will be
retreived from MBeans, and may be incorrect on some platforms. To increase metric accuracy
add the 'sigar.jar' to the classpath and the appropriate platform-specific native libary to
'java.library.path'. Reason: java.lang.IllegalArgumentException: java.lang.UnsatisfiedLinkError:
org.hyperic.sigar.Sigar.getPid()J
Sigar is a native library for gathering performance stats, used by Typesafe Console atmos Scala library. If you're not interested in hooking up Typesafe Console to your application, you can simply remove all references to atmos library from sbt build script and app config files without affecting your app functionality.

GWT compilation error, images and deferred binding

With three friends, I am developing an application with gwt (2.6). A few weeks ago, we started to use super dev mode. Everything works great, except that two of us cant use ImageBundles. It started when I wanted to include a SuggestBox, which apparently loads some images. GWT compile failed. I googled a lot, and I couldn't fix it, so I started to work on something else: Loading some images using an ImageResourceBundle. GWT compile failed. Same error. Workaround: loading images not using ImageResourceBundle. Whats really strange is: two of us are working with windows, one with ubuntu and I'm using a mac. The compile works fine with ubuntu and with one of the windows machines. On the other machines, the compilation error stays always the same no matter what we try:
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Computing all possible rebind results for 'com.google.gwt.user.client.ui.MenuBar.Resources'
Rebinding com.google.gwt.user.client.ui.MenuBar.Resources
Invoking generator com.google.gwt.resources.rebind.context.InlineClientBundleGenerator
[ERROR] No #com.google.gwt.resources.ext.ResourceGeneratorType was specifed for type com.google.gwt.resources.client.ImageResource or its supertypes
[ERROR] Errors in 'com/google/gwt/user/client/ui/MenuBar.java'
[ERROR] Line 212: Failed to resolve 'com.google.gwt.user.client.ui.MenuBar.Resources' via deferred binding
Computing all possible rebind results for 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template'
Rebinding com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template
Invoking generator com.google.gwt.safehtml.rebind.SafeHtmlTemplatesGenerator
Constructing interface com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template
Generating method body for image()
[ERROR] Required annotation #Template not present on interface method public abstract com.google.gwt.safehtml.shared.SafeHtml image(com.google.gwt.safehtml.shared.SafeUri clearImage, com.google.gwt.safecss.shared.SafeStyles style)
[ERROR] Errors in 'com/google/gwt/user/client/ui/impl/ClippedImageImpl.java'
[ERROR] Line 104: Failed to resolve 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.Template' via deferred binding
Computing all possible rebind results for 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate'
Rebinding com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate
Invoking generator com.google.gwt.safehtml.rebind.SafeHtmlTemplatesGenerator
Constructing interface com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate
Generating method body for image()
[ERROR] Required annotation #Template not present on interface method public abstract com.google.gwt.safehtml.shared.SafeHtml image(com.google.gwt.safehtml.shared.SafeUri clearImage, com.google.gwt.safecss.shared.SafeStyles style)
[ERROR] Errors in 'com/google/gwt/user/client/ui/impl/ClippedImageImpl.java'
[ERROR] Line 96: Failed to resolve 'com.google.gwt.user.client.ui.impl.ClippedImageImpl.DraggableTemplate' via deferred binding
[ERROR] Compiler returned false
I really don't know what to do. We checked nearly every setting/config-file in eclipse and tomcat. Its all the same. Has anyone an idea where to look? Maybe I'm looking in the wrong places. I appreciate any help you can give me.
Additional information (update):
When building the application with ant the gwt-compile runs without errors.
We use eclipse WITHOUT google plugins.
In dev mode the web application is started via tomcat7.
The super-dev-mode is invoked WITHIN the web application (in Servlet.init()). Therefor we had to add the gwt-dev jars into the classpath of the tomcat launcher.
Including new SuggestBox() anywhere into our gwt source code causes the gwt-compile-error on some machines. Without new SuggestBox() everything compiles everywhere.
I think it is a classpath or gwt-compile-sourcepath problem. But we see no differences on the different machines we use.
When building the application with ant the gwt-compile runs without errors.
1) So if you compare the way you compile it and the way ant compiles it you will see the root cause.
2) In case you don't see any difference or you don't know how Eclipse (or whatever you use) compiles your application try to compile it in this way (we may call it true pure dzen way without any eclipse, ant, maven or other third-party "helpers"):
java -cp gwt-dev.jar;gwt-user.jar;validation-api-1.0.0.GA.jar;validation-api-1.0.0.GA-sources.jar;any/other/lib.jar;path/to/your/module/source/code com.google.gwt.dev.Compiler moduleName
In case your .gwt.xml descriptor is located under com/your/gwt/module/MyModule.gwt.xml you should use com.your.gwt.module.MyModule as a moduleName
As you have not included any code it is hard to guess what could have gone wrong, but here are some possible reasons:
Zero-parameter constructors
This is the one that was mentioned the most in the articles I read (references included below) and seems to create exactly the issue you are having, but I have to admit that I do not know why that would happen just to some of your teammates (maybe it is just needed under certain VMs or something like that).
It might be a deferred binding issue (according to the compiler log you posted) and therefore you should check if all your POJO (plain old java object) classes have a zero-parameter constructor for deferred loading.
Failed to resolve class via deferred binding
Conflicting annotations
Maybe you have some annotations placed wrong, as mentioned here:
Deferred binding failed GWT using uibinder
Some annotations such as #UiConstructor and #UiFactory don't go well together and (even though they are not actually conflicting in this case) can cause similar problems.
References & More
Failed to create an instance of Service via deferred binding
http://www.sencha.com/forum/archive/index.php/t-170786.html?s=fb45a32ac52270e43026da25ff956840
http://samuelcheng.wordpress.com/2011/01/02/deferred-binding-failure-in-gwt/
Deferred binding failed
https://groups.google.com/forum/#!topic/google-web-toolkit/iHajUf7sjtE
If you are using Maven, you can easily do a javac with mvn compile, then you can run mvn gwt:compile. These nasty errors will go away.

Intellij will not run ScalaTests - "Incompatible Class Change Error"

I'm trying to run tests for an sbt-based Scala application in intellij. But I get the following error which I'm not sure how to fix:
Testing started at 21:07 ...
java.lang.IncompatibleClassChangeError: Found class scala.collection.mutable.ArrayOps, but interface was expected
at org.scalatest.tools.Runner$.checkArgsForValidity(Runner.scala:895)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:729)
at org.scalatest.tools.Runner$.run(Runner.scala:711)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:144)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
When I decorate my classes with the Junit runner attribute they work fine (and it's actually a much better run in terms of the visuals):
#RunWith(classOf[JUnitRunner])
I got the same error when trying to run tests for my Play Framework app. Drilling down into the stack trace, I found that the problem class was FakeRequest, which is in the play-test library. I had two different versions of the library, one for Play 2.4 and one for 2.3. I was able to resolve this issue by removing the play-test version for Play 2.3 (open Module Settings -> Libraries -> find and delete the bad dependency).
Your issue is probably with some other problematic dependency, but following the same steps as above may help fix it.
This seems to be a problem with scala test runner framework. I had come across the same problem; eventually like you suggested end up using junit test runner to make it work. But the problem in my case was it was pulling in a transitive dependency and no such class error.
Make sure the libraries what you are using for the JUnitRunner are same. Most of the times “Incompatible Class Change Error” occurs because of backward compatibility. And also have a look at scala library jar at the time of compiling and running.

Unable to create editor ID org.eclipse.jst.pagedesigner.PageDesignerEditor: An unexpected exception was thrown

when i added JSF support to my project, following this tutorial
http://www.mkyong.com/jsf2/how-to-make-eclipse-ide-supports-jsf-2-0/
after restarting the eclipse, i am getting the error:
Unable to create editor ID org.eclipse.jst.pagedesigner.PageDesignerEditor: An unexpected exception was thrown.
any ideas why, and how to solve it ?
UPDATE:
when i tried to select java server faces again from the project facets, i found that it says on the right:
Conflicts with the following facets:
Application Client module
Dynamic Web Module
EAR
EJB Module
JCA Module
Static Web Module
Utility Module
Web Fragment Module
i was having JSF and ICEFaces dependencies in my pom, and i was having their libraries too in the classpath, fixed the error by removing them, and adding JSF,icefaces capabilities to my project, everything works fine now.

Mysterious NoSuchMethodError & it can't be the classpath...can it?

I've been battling with this bug for 3 hours.
I have checked the build path and classpath and they are the same, this is quite a large webapp, running on Tomcat & Geronimo, it has a build file for each component & then one main once that binds them all together, but I've gone over the ant build files & compared them to others in working components that rely on 3rd party libraries and I don't see an differences.
<fileset dir="${home.dir}/component/lib" includes="*.jar"/>
It all seems to be in order.
If I call this method from a JUnit test, run from within eclipse, is passes no problem, if I run the server I get this exception.
Also I have two other libraries that this component uses & I just added it as a user library in eclipse & in the components lib referenced in the build.xml and it works without a problem. I've tried moving jars around resorting to trial and error when logic seemed to fail me & no luck yet.
To make matters even stranger, I remember now, I had this issue with some code I wrote myself that wasn't even in a library. java.lang.NoSuchMethodError, since eclipse does occasionally do random things I just changed the method name and did a clean & it worked.
I've tried cleaning and rebuilding the whole web app several times with no change.
I'd like some advice about how to get closer to the problem so I can try find the bug, how does one debug classpath issues is there anywhere else the classpath is defened besides the build file?
Any suggestions on how to pin point the problem would be appreciated.
Exception: java.lang.NoSuchMethodError
[java] Message: com.google.common.collect.ImmutableMultimap.of()Lcom/google/common/collect/ImmutableMultimap;
[java] ---- stack trace ---------------------------------------------------------------
[java] java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMultimap.of()Lcom/google/common/collect/ImmutableMultimap;
[java] com.google.gdata.util.common.net.UriParameterMap.<clinit>(UriParameterMap.java:78)
[java] com.google.gdata.client.Service.computeQueryMap(Service.java:2190)
[java] com.google.gdata.client.Service.access$000(Service.java:94)
[java] com.google.gdata.client.Service$ClientStreamProperties.<init>(Service.java:1839)
[java] com.google.gdata.client.Service$ClientOutputProperties.<init>(Service.java:1986)
[java] com.google.gdata.client.Service.writeRequestData(Service.java:2029)
[java] com.google.gdata.client.Service.insert(Service.java:1408)
[java] com.google.gdata.client.GoogleService.insert(GoogleService.java:599)
[java] com.google.gdata.client.appsforyourdomain.AppsForYourDomainService.insert(AppsForYourDomainService.java:100)
[java] za.co.venturenet.api.googleapps.GoogleAppsServices.createUser(GoogleAppsServices.java:437)
[java] za.co.venturenet.api.googleapps.GoogleAppsServices.createUser(GoogleAppsServices.java:336)
[java] za.co.venturenet.api.googleapps.GoogleAppsFacade.createNewVenturenetUser(GoogleAppsFacade.java:158)
NoSuchMethodError means that the class was found, but a referenced method in that class is not found. The most typical cause of this is accessing a wrong version of class/library. Since your problem only manifests when running on the server, I would look at your server's configuration. Perhaps a different version this library is wired into server's system classloader (which would be ahead of whatever is bundled in your webapp).
>since eclipse does occasionally do random things I just changed the method name and did a clean & it worked.
I've had the same error, and have tried the same solution: change method name, or add an empty line to the java file, rebuild. It usually works one time. But upon second server start, the NoSuchMethodError returns for the same method identifier.
My eclipse environment builds a "target/classes" folder, which gets a copy of the web-inf classes.
Removal of that folder seems to have cured my problems with random NoSuchMethodError, which were probably caused by inability to resolve which instance to load.
Your mileage may vary.