Skip to content

spring-boot-sample-jersey fails when run using java CLI (AutoDiscoverable not found) #7423

Closed
@tmueller64

Description

@tmueller64

After cloning spring-boot, I built the spring-boot-sample-jersey sample (which was successful, including the tests):

$ cd spring-boot/spring-boot-samples/spring-boot-sample-jersey
$ mvn install

and then tried to run it using the java CLI:

$ java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
$ java -jar target/spring-boot-sample-jersey-2.0.0.BUILD-SNAPSHOT.war

The server started up. Then I used curl to access the /hello endpoint:

$ curl -i http://localhost:8080/hello

This produced the following output:

HTTP/1.1 500
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 5113
Date: Sat, 19 Nov 2016 12:23:08 GMT
Connection: close

<!DOCTYPE html><html><head><title>Apache Tomcat/8.5.6 - Error report</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 500 - Servlet.init() for servlet sample.jersey.JerseyConfig threw exception</h1><div class="line"></div><p><b>type</b> Exception report</p><p><b>message</b> <u>Servlet.init() for servlet sample.jersey.JerseyConfig threw exception</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b></p><pre>javax.servlet.ServletException: Servlet.init() for servlet sample.jersey.JerseyConfig threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:745)
</pre><p><b>root cause</b></p><pre>org.glassfish.jersey.internal.ServiceConfigurationError: org.glassfish.jersey.internal.spi.AutoDiscoverable: : java.io.FileNotFoundException: JAR entry !/META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable not found in /var/folders/51/4546_7td295g8ymf1wt_9fg80026td/T/jar_cache1463452997560351481.tmp
	org.glassfish.jersey.internal.ServiceFinder.fail(ServiceFinder.java:433)
	org.glassfish.jersey.internal.ServiceFinder.parse(ServiceFinder.java:512)
	org.glassfish.jersey.internal.ServiceFinder.access$400(ServiceFinder.java:155)
	org.glassfish.jersey.internal.ServiceFinder$AbstractLazyIterator.hasNext(ServiceFinder.java:572)
	org.glassfish.jersey.internal.ServiceFinder.toClassArray(ServiceFinder.java:418)
	org.glassfish.jersey.internal.ServiceFinderBinder.configure(ServiceFinderBinder.java:90)
	org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:172)
	org.glassfish.hk2.utilities.binding.AbstractBinder.install(AbstractBinder.java:342)
	org.glassfish.jersey.server.ServerBinder.configure(ServerBinder.java:94)
	org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:172)
	org.glassfish.jersey.internal.inject.Injections.bind(Injections.java:157)
	org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:147)
	org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
	org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:330)
	org.glassfish.jersey.servlet.WebComponent.&lt;init&gt;(WebComponent.java:392)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:745)
</pre><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/8.5.6 logs.</u></p><hr class="line"><h3>Apache Tomcat/8.5.6</h3></body></html>

This exception stack trace was also reported in the server output.

If the server is run using:

$ mvn spring-boot:run

Then it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions