curious class class not found exception

679 views
Skip to first unread message

Nuno Godinho de Matos

unread,
Oct 28, 2012, 12:10:05 PM10/28/12
to google-we...@googlegroups.com
Presently, when i try to run my gwt application through eclipse I am getting a curious:
"java.lang.NoClassDefFoundError: com/google/gwt/user/client/rpc/RemoteService"

The intersting about this exception is that by command line firing a gwt:run my project loads and runs just fine.
It is thorugh eclipse, where the classpath is even larger, that the exception happens.


After creating a fancy perl script to farm the .jar files and directories indicated by oracle visual vm for sun.java.classpath system variable, i was able to track that my maven runtime project has this class under the following loacations:

Search results are: 
 $VAR1 = {
          '/home/nmatos/.m2/repository/com/google/gwt/gwt-servlet/2.4.0/gwt-servlet-2.4.0.jar' => [
                                                                                                    'com/google/gwt/user/client/rpc/RemoteService.class',
                                                                                                    'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.class'
                                                                                                  ],
          '/home/nmatos/.m2/repository/com/google/gwt/gwt-user/2.4.0/gwt-user-2.4.0.jar' => [
                                                                                              'com/google/gwt/user/client/rpc/RemoteService.class',
                                                                                              'com/google/gwt/user/client/rpc/RemoteService.java',
                                                                                              'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.class',
                                                                                              'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.java'
                                                                                            ]
        };


On the other hand, when I use the google eclipse plugin to lunch the com.google.gwt.dev.DevMode , I have an even larger set of jar files containing this class (due to overhead jars that originate from automatic project configuration triggered by the eclipse plugin):
Search results are: 
 $VAR1 = {
          '/home/nmatos/Desktop/Applications/eclipse_20121024/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201208080121-rel-r42/gwt-2.4.0/gwt-servlet.jar' => [
                                                                                                                                                                   'com/google/gwt/user/client/rpc/RemoteService.class',
                                                                                                                                                                   'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.class'
                                                                                                                                                                 ],
          '/home/nmatos/Desktop/Applications/eclipse_20121024/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201208080121-rel-r42/gwt-2.4.0/gwt-user.jar' => [
                                                                                                                                                                'com/google/gwt/user/client/rpc/RemoteService.class',
                                                                                                                                                                'com/google/gwt/user/client/rpc/RemoteService.java',
                                                                                                                                                                'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.class',
                                                                                                                                                                'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.java'
                                                                                                                                                              ],
          '/home/nmatos/.m2/repository/com/google/gwt/gwt-servlet/2.4.0/gwt-servlet-2.4.0.jar' => [
                                                                                                    'com/google/gwt/user/client/rpc/RemoteService.class',
                                                                                                    'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.class'
                                                                                                  ],
          '/home/nmatos/.m2/repository/com/google/gwt/gwt-user/2.4.0/gwt-user-2.4.0.jar' => [
                                                                                              'com/google/gwt/user/client/rpc/RemoteService.class',
                                                                                              'com/google/gwt/user/client/rpc/RemoteService.java',
                                                                                              'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.class',
                                                                                              'com/google/gwt/user/client/rpc/RemoteServiceRelativePath.java'
                                                                                            ]
        };



Juding from the stack trace, jvm standard class loaders seem be used, they should farm the jars defined in -cp system variable:

WARNING: Error starting handlers
java.lang.NoClassDefFoundError: com/google/gwt/user/client/rpc/RemoteService
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.mortbay.util.Loader.loadClass(Loader.java:91)
at org.mortbay.util.Loader.loadClass(Loader.java:71)
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:242)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:205)
at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:249)
at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:157)
at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:97)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)
at com.google.gwt.dev.DevMode.main(DevMode.java:311)
Caused by: java.lang.ClassNotFoundException: com.google.gwt.user.client.rpc.RemoteService
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 48 more


Any hints on what is going wrong here?
I'd say the runtime should have an over those of class found exception, if that even existed, not the other way around.

Thanks in advance.

Jens

unread,
Oct 28, 2012, 12:57:10 PM10/28/12
to google-we...@googlegroups.com
And gwt-servlet.jar is in your war/WEB-INF/lib folder? 

In your stack trace you can see: 

at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:207)

which indicates that you are using AppEngine. The IsolatedAppClassLoader JavaDoc states that it isolates the webapp from the DevAppServer and everything on system classpath. I don't know AppEngine but it sounds to me that only libs in WEB-INF/lib are allowed and it does not really matter whats on system class path.

Maven probably put gwt-servlet.jar automatically into WEB-INF/lib if you have defined a dependency for it.

-- J.

Nuno Godinho de Matos

unread,
Oct 28, 2012, 1:15:06 PM10/28/12
to google-we...@googlegroups.com
Thanks a lot and well spotted!

What you just said makes all the sense in the world.
I will take a look at my runtime lib folder in while.

Thanks again.
Reply all
Reply to author
Forward
0 new messages