Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError: javax/servlet/Servlet when running codeserver of GWT 2.8.0 #76

Closed
trohr opened this issue Feb 28, 2017 · 2 comments
Labels
question Further information is requested

Comments

@trohr
Copy link

trohr commented Feb 28, 2017

Hi Thomas,

I tried upgrading to GWT 2.8.0 because of some other issue, but I can't seem to be able to get it running. Running code-server exits with error.

[WARNING] java.lang.NoClassDefFoundError: javax/servlet/Servlet
[WARNING] 	at com.google.gwt.dev.codeserver.SourceHandler.<clinit>(SourceHandler.java:63)
[WARNING] 	at com.google.gwt.dev.codeserver.Recompiler.loadModule(Recompiler.java:500)
[WARNING] 	at com.google.gwt.dev.codeserver.Recompiler.initWithoutPrecompile(Recompiler.java:204)
[WARNING] 	at com.google.gwt.dev.codeserver.Outbox.maybePrecompile(Outbox.java:89)
[WARNING] 	at com.google.gwt.dev.codeserver.Outbox.<init>(Outbox.java:61)
[WARNING] 	at com.google.gwt.dev.codeserver.CodeServer.makeOutboxTable(CodeServer.java:191)
[WARNING] 	at com.google.gwt.dev.codeserver.CodeServer.start(CodeServer.java:150)
[WARNING] 	at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:102)
[WARNING] 	at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:55)
[WARNING] Caused by: java.lang.ClassNotFoundException: javax.servlet.Servlet
[WARNING] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
[WARNING] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[WARNING] 	at java.security.AccessController.doPrivileged(Native Method)
[WARNING] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
[WARNING] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[WARNING] 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[WARNING] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[WARNING] 	... 9 more

[ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:codeserver (default-cli) on project insolvency-client-parent: GWT exited with status 1 -> [Help 1]

I tried adding dependency to your plugin definition, but the output does not change:

        <plugin>
          <groupId>net.ltgt.gwt.maven</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <version>1.0-rc-6</version>
          <extensions>true</extensions>
          <configuration>
            <sourceLevel>1.8</sourceLevel>
            <failOnError>true</failOnError>
          </configuration>
          
          <dependencies>
            <dependency>
              <groupId>javax.servlet</groupId>
              <artifactId>javax.servlet-api</artifactId>
              <version>3.1.0</version>
              <scope>runtime</scope>
            </dependency>
          </dependencies>
        </plugin>

Is this a bug or do I make some error?
Thank you.

Sincerely yours
Tomas Rohrbacher

@tbroyer
Copy link
Owner

tbroyer commented Feb 28, 2017

gwt:codeserver will use as classpath the dependencies for all the projects matching the classpathScope; these should include gwt-dev and gwt-user which will bring javax.servlet transitively.

It might be that you set javax.servlet with scope provided, which excludes it from the runtime scope (default value for classpathScope). In this case, depending on your project layout, either remove the <scope>provided</scope> or set classpathScope to compile or compile+runtime.

In any case, adding dependencies to the plugin definition won't do anything.

@tbroyer tbroyer closed this as completed Feb 28, 2017
@tbroyer tbroyer added the question Further information is requested label Feb 28, 2017
@shauntarves
Copy link

I encountered this same problem in a subtlety different way.

My project inherits from a parent pom that has a <dependencyManagement> section which specifies a provided scope for javax.servlet. It was not enough to override the javax.servlet dependency scope to runtime even though my classpathScope was the default (runtime). I had to override the dependency scope to compile in order for the plugin to include it on the classpath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants