NoSuchMethod exception thrown in GWT - gwt

I'm starting to get my feet wet in the latest Google Web Toolkit using the Eclipse plugin on OS X 10.5.8. So far I've been able to get the client up and running, which is great.
The server, though, is a different matter. I'm trying to link to a .jar file that has some classes I want to use in a server ServiceImpl class, but it seems to have glommed onto a previous iteration of the .jar - I've added a method, rebuilt the jar, removed the jar from the libraries tab on the GWT project's build path (as well as on the exports) and reincluded the jar. No luck - I'm still getting:
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract org.gwtapplication.client.LWDocument org.gwtapplication.client.DocumentService.getDocument()' threw an unexpected exception: java.lang.NoSuchMethodError: org.externalmodel.MyReallyValidClass.toSomething()Ljava/lang/String;
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
...
Caused by: java.lang.NoSuchMethodError: org.externalmodel.MyReallyValidClass.toSomething()Ljava/lang/String;
at org.application.server.DocumentServiceImpl.getDocument(DocumentServiceImpl.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Eclipse's code sense has no problems resolving the MyReallyValidClass.toSomething() call, and there are no errors with other calls into the externalmodel classes. Any clue where I should be looking?

In your DocumentServiceImpl class, adding the following log:
System.out.println(Thread.currentThread().getContextClassLoader().getResource("org/externalmodel/MyReallyValidClass.class");
should tell you where this jar is being picked up.

Related

Hi, I am currently upgrading wicket application from 1.5.3 to 6.30.0 but i am getting error and login page is not getting instantiated

org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public com.ecs.test.web.page.Login()'. An exception has been thrown during construction!
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:194)
Caused by: java.lang.NoClassDefFoundError: javax/inject/Inject
at org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.supportsField(AnnotProxyFieldValueFactory.java:324)
at org.apache.wicket.injection.Injector.findFields(Injector.java:148)
it might help tring to add Objenesis lib to your project dependencies. Wicket CI checks if this lib is available and if so, it's used to build proxy objects even if they don't provide a no args (i.e. Default) constructor.

Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

I've a gradle project which uses hibernate > 4 . If I run my war file in Apache tomcat, I don't get any error. But when I'm deploying it in Wildfly 8.2 , I get the following exception
Caused by: org.hibernate.InvalidMappingException: Error while parsing file: /G:/wildfly-8.2.0.Final/bin/content/mywar-1.0.war/WEB-INF/classes/com/mysite/
hbm/Role.hbm.xml
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1182) [hibernate-ent
itymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:848) [hibernate-entitymanager-4.3.7.Fi
nal.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) [hibernate-entitymanager-4.3.7.Fi
nal.jar:4.3.7.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) [hibernate-core-4.3.7.Final.jar:4.
3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) [hibernate-entitymanager-4.3.7.Final.
jar:4.3.7.Final]
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
... 8 more
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:375) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:304) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.cfg.Configuration.add(Configuration.java:518) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.cfg.Configuration.add(Configuration.java:514) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.cfg.Configuration.add(Configuration.java:688) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:726) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1177) [hibernate-ent
itymanager-4.3.7.Final.jar:4.3.7.Final]
... 14 more
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot
be cast to org.dom4j.DocumentFactory
at org.dom4j.io.SAXReader.read(SAXReader.java:484) [dom4j-1.6.1.jar:1.6.1]
I just added a exclude in my Gradle file like
runtime.exclude group: "dom4j"
Now when I run gradle build, dom4j.jar is not created in the war file. Now I can run my deploy and run my project successfully on Wildfly 8.2 without any error. But the real problem starts here.
One of the feature in my project is that, it'll copy a file.xlsm to anotherfile.xlsm where I'm using jars like Apache Poi for those purposes. Here, Apache Poi is trying to access a method in dom4j.jar during file processing, it results in the following error
18:40:13,261 ERROR [io.undertow.request] (default task-29) UT005023: Exception handling request to /app/parentPath/myAction: org.springframework.web.util.NestedSe
rvletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1287) [spring-webmvc-4.1.4.RELEASE.jar:4.1.4
.RELEASE]
Any ideas how I can permanently use dom4j.jar inside my classpath? I've searched for many question and most of them suggested to remove dom4j from classpath. I do successfully run my program by removing it from classpath but it results in the above error during excel file processing. Wasted more than a day on this..!! IS it possible to include dom4j.jar in my classpath?
Update:
I've done a little trick in MANIFEST.MF file.
I've opened
mywar.war > META-INF > MANIFEST.MF
and added
Dependencies: org.dom4j export
at the end of the file and saved it. So if I deploy my war file, I'm successfully running it without any error.
Can someone explain where I've to add this kind of property in my src/ file so that it will be automatcially added to MANIFEST.MF after gradle build..
This exception on wildfly usually occurs when you include a hibernate lib in your war that's different from the wildfly one, since you are deploying to wildfly it already include hibernate so you can set you live as provided in gradle aka compileProvided and deploy without exporting the dependence.
If you still got the same error try declaring the hibernate dependency on manifest but keep the lib as provided it should work fine.
I had this same problem and i know how frustrating this one can be. I was able to resolve this problem. see my answer here. Hope this help

GWT Deobfuscator Builder ClassCastException

I have a GWT webapp which uses a RequestFactory - the app seems to launch just fine, but as soon as I try to open it in a browser, it blows up with this exception:
com.google.web.bindery.requestfactory.server.RequestFactoryServlet doPost
SEVERE: Unexpected error
java.lang.ClassCastException: class com.myapp.console.shared.MyAppRequestFactoryDeobfuscatorBuilder
at java.lang.Class.asSubclass(Class.java:3126)
at com.google.web.bindery.requestfactory.vm.impl.Deobfuscator$Builder.load(Deobfuscator.java:52)
at com.google.web.bindery.requestfactory.server.ResolverServiceLayer.updateDeobfuscator(ResolverServiceLayer.java:43)
at com.google.web.bindery.requestfactory.server.ResolverServiceLayer.resolveRequestFactory(ResolverServiceLayer.java:176)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestFactory(ServiceLayerDecorator.java:172)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestFactory(ServiceLayerDecorator.java:172)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestFactory(ServiceLayerDecorator.java:172)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveRequestFactory(ServiceLayerDecorator.java:172)
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:606)
at com.google.web.bindery.requestfactory.server.ServiceLayerCache.getOrCache(ServiceLayerCache.java:233)
at com.google.web.bindery.requestfactory.server.ServiceLayerCache.resolveRequestFactory(ServiceLayerCache.java:198)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:215)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135)
at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
....
The MyAppRequestFactoryDeobfuscatorBuilder class is auto-generated (my class is MyAppRequestFactory), so it's proving very difficult to debug. This didn't used to happen a few weeks ago when I last used this app. What's causing this error and how do I fix it? I'm not a GWT expert, so small words and understandable explanations would be appreciated!
This is likely a classloader issue, Deobfuscator.Builder being loaded from a different (and sibling or child, not parent) classloader than MyAppRequestFactoryDeobfuscatorBuilder, so the Deobfuscator.Builder parent class of MyAppRequestFactoryDeobfuscatorBuilder is not the same as the Deobfuscator.Builder class that tries to load it.
Did you change anything between the time it worked and now?
(note: GWT 2.6.0's DevMode has a classloader issue, so if you updated to GWT 2.6.0 and don't strictly follow the expected project layout –i.e. some libs missing from your WEB-INF/lib and/or your compiled classes not being in WEB-INF/classes– then you could run on such issue)

Issues debugging Errai app in Eclipse

When degugging an Errai application in Eclipse, I get the following error.
[WARN] failed com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload#1575d48{/,/home/matthew/git/PressGangCCMSUI/src/main/webapp}: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
[WARN] failed RequestLogHandler#ad4bb0: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
[WARN] Error starting handlers
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
Does anyone know how to fix this up?
It turns out the issue was because Eclipse was using a local Maven project as a dependency instead of the JAR file in the local repo cache. Once I close the project that my Errai app was dependant on, Eclipse reverted back to using the JAR in the local repo cache, and I could launch the debugger again.

java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()

I am getting this error java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()
at the runtime in eclipse. However, eclipse shows the method on doing intelligence search, but at runtime it fails to identify it.
I am using the latest log4j1.2.16 jar and it is added in the classpath.
Any suggestions?