Spring Boot通过命令行启动发生FileNotFoundException

Spring Boot + Jersey 通过命令行启动会发生错误FileNotFoundException异常

异常信息如下:

ERROR o.a.c.c.C.[Tomcat].[localhost].[/] - StandardWrapper.Throwable 
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 /tmp/jar_cache417521088140895909.tmp
	at org.glassfish.jersey.internal.ServiceFinder.fail(ServiceFinder.java:433)
	at org.glassfish.jersey.internal.ServiceFinder.parse(ServiceFinder.java:512)
	at org.glassfish.jersey.internal.ServiceFinder.access$400(ServiceFinder.java:155)
	at org.glassfish.jersey.internal.ServiceFinder$AbstractLazyIterator.hasNext(ServiceFinder.java:572)
	at org.glassfish.jersey.internal.ServiceFinder.toClassArray(ServiceFinder.java:418)
	at org.glassfish.jersey.internal.ServiceFinderBinder.configure(ServiceFinderBinder.java:90)
	at org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:172)
	at org.glassfish.hk2.utilities.binding.AbstractBinder.install(AbstractBinder.java:342)
	at org.glassfish.jersey.server.ServerBinder.configure(ServerBinder.java:94)
	at org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:172)
	at org.glassfish.jersey.internal.inject.Injections.bind(Injections.java:157)
	at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:147)
	at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:330)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4913)
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbeddedContext.java:78)
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.startConnector(TomcatEmbeddedServletContainer.java:256)
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:181)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
	at com.jiajian.yishi.YishiServiceProjectApplication.main(YishiServiceProjectApplication.java:17)
	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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
	at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)

  此问题是版本为8.5.6内置tomcat的bug,将tomcat.version 改为8.5.5就好了。

即:

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  <java.version>1.8</java.version>
  <tomcat.version>8.5.5</tomcat.version> 
</properties>

  

posted @ 2016-11-28 21:32  vincent_ren  阅读(2660)  评论(0编辑  收藏  举报