Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

helloworld-spring-annotations: ClassNotFoundException: javax.servlet.ServletContext #3739

Open
akhalikov opened this issue Dec 21, 2017 · 2 comments

Comments

@akhalikov
Copy link

Failed to run the example helloworld-spring-annotations in Idea or via command mvn exec:java with the exception:

java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
	at org.glassfish.jersey.server.spring.SpringComponentProvider.initialize(SpringComponentProvider.java:92)
	at org.glassfish.jersey.server.ComponentProviderConfigurator.lambda$null$0(ComponentProviderConfigurator.java:79)
	at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:372)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1380)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at org.glassfish.jersey.server.ComponentProviderConfigurator.lambda$init$1(ComponentProviderConfigurator.java:80)
	at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
	at org.glassfish.jersey.server.ResourceModelConfigurator.bindProvidersAndResources(ResourceModelConfigurator.java:135)
	at org.glassfish.jersey.server.ResourceModelConfigurator.init(ResourceModelConfigurator.java:87)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:365)
	at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$1(ApplicationHandler.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
	at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:315)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:269)
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.<init>(GrizzlyHttpContainer.java:334)
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:138)
	at org.glassfish.jersey.examples.hello.spring.annotations.App.main(App.java:70)
	... 6 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 31 more
@jansupol
Copy link
Contributor

Seems to be done by increasing commons-logging version from 1.1 to 1.2

@akhalikov
Copy link
Author

akhalikov commented Dec 22, 2017

The problem is that there is not servlet-api dependency in the classpath.
Here is PR: https://github.com/jersey/jersey/pull/3741

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants