我的项目依赖于Spring Boot来构建独立的可执行jar文件。它非常适合内部测试。但是,一旦我们准备将其部署到我们的开发环境中,应用程序就需要在war文件中,以便可以将其部署到我们的Resin服务器。
所以我按照指南(http://spring.io/guides/gs/convert-jar-to-war/)进行了转换。然后我将war应用程序部署到本地Resin服务器,并发生了一系列异常。
长话短说,我最终创建了一个简单的hello world REST服务,使用Spring Boot构建为战争并将其部署到Resin。测试应用程序位于(https://github.com/ChrisZhong/spring-boot-war-sample)。测试应用程序发生了类似的问题。但是,同样的测试战争部署到Tomcat 7没有任何问题,并按预期工作。以下日志来自Resin。
[14-03-12 17:06:25.414] {resin-34} WebApp[production/webapp/default/spring-boot-war-sample-1.1.1,STARTING] Spring WebApplicationInitializers detected on classpath: [hello.WebXml@62da57c9]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.0.0.RC4)
2014-03-12 17:06:26.765 INFO 4024 --- [ resin-34] o.s.boot.SpringApplication : Starting application on CHRIS-DESKTOP with PID 4024 (C:\resin-4.0.38\webapps\spring-boot-war-sample-
1.1.1\WEB-INF\lib\spring-boot-1.0.0.RC4.jar started by czhong)
2014-03-12 17:06:26.919 INFO 4024 --- [ resin-34] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3
93d3e1d: startup date [Wed Mar 12 17:06:26 CDT 2014]; root of context hierarchy
2014-03-12 17:06:29.034 INFO 4024 --- [ resin-34] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
[14-03-12 17:06:29.135] {resin-34} HV000001: Hibernate Validator 4.3.0.Final
2014-03-12 17:06:29.414 INFO 4024 --- [ resin-34] com.caucho.server.webapp.WebApp : WebApp[production/webapp/default/spring-boot-war-sample-1.1.1,STARTING] Initializing Spring embedded
WebApplicationContext
[14-03-12 17:06:29.415] {resin-34} WebApp[production/webapp/default/spring-boot-war-sample-1.1.1,STARTING] Initializing Spring embedded WebApplicationContext
2014-03-12 17:06:29.416 INFO 4024 --- [ resin-34] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2497 ms
2014-03-12 17:06:31.500 INFO 4024 --- [ resin-34] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
com.caucho.config.ConfigException: Custom bean class 'org.springframework.boot.context.web.ErrorPageFilter' is not public. Bean classes must be public, concrete, and have a zero-argument constructor.
at com.caucho.config.Config.checkCanInstantiate(Config.java:532)
at com.caucho.config.Config.validate(Config.java:561)
at com.caucho.server.dispatch.FilterConfigImpl.setFilterClass(FilterConfigImpl.java:105)
at com.caucho.server.webapp.WebApp.addFilter(WebApp.java:1457)
at com.caucho.server.webapp.WebApp.addFilter(WebApp.java:1439)
at org.springframework.boot.context.embedded.FilterRegistrationBean.onStartup(FilterRegistrationBean.java:233)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:214)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:619)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:130)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:89)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:51)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at com.caucho.server.webapp.WebApp.callInitializer(WebApp.java:3494)
at com.caucho.server.webapp.WebApp.callInitializers(WebApp.java:3462)
at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3687)
at com.caucho.server.webapp.WebApp.access$400(WebApp.java:207)
at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5231)
at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173)
at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)
2014-03-12 17:06:31.518 INFO 4024 --- [ resin-34] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.
1.1/WEB-INF/classes/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/aopalliance-1.0.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/commo
ns-logging-1.1.3.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/jackson-annotations-2.3.0.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-I
NF/lib/jackson-core-2.3.1.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/jackson-databind-2.3.1.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1
/WEB-INF/lib/jcl-over-slf4j-1.7.6.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/jul-to-slf4j-1.7.6.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1
.1.1/WEB-INF/lib/log4j-over-slf4j-1.7.6.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/logback-classic-1.1.1.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war
-sample-1.1.1/WEB-INF/lib/logback-core-1.1.1.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/slf4j-api-1.7.6.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-
sample-1.1.1/WEB-INF/lib/snakeyaml-1.13.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-aop-4.0.2.RELEASE.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-
war-sample-1.1.1/WEB-INF/lib/spring-beans-4.0.2.RELEASE.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-boot-1.0.0.RC4.jar!/, jar:file:/C:/resin-4.0.38/webapps
/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-boot-autoconfigure-1.0.0.RC4.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-boot-starter-1.0.0.RC4.jar!/, jar
:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-boot-starter-logging-1.0.0.RC4.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-b
oot-starter-tomcat-1.0.0.RC4.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-boot-starter-web-1.0.0.RC4.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-wa
r-sample-1.1.1/WEB-INF/lib/spring-context-4.0.2.RELEASE.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-core-4.0.2.RELEASE.jar!/, jar:file:/C:/resin-4.0.38/web
apps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-expression-4.0.2.RELEASE.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-web-4.0.2.RELEASE.jar!/, jar:file
:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/spring-webmvc-4.0.2.RELEASE.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/tomcat-embed-core-7.0.5
2.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/tomcat-embed-el-7.0.52.jar!/, jar:file:/C:/resin-4.0.38/webapps/spring-boot-war-sample-1.1.1/WEB-INF/lib/tomcat-embe
d-logging-juli-7.0.52.jar!/]
2014-03-12 17:06:31.523 INFO 4024 --- [ resin-34] com.caucho.server.webapp.WebApp : WebApp[production/webapp/default/spring-boot-war-sample-1.1.1] fail
[14-03-12 17:06:31.523] {resin-34} WebApp[production/webapp/default/spring-boot-war-sample-1.1.1] fail
2014-03-12 17:06:31.535 WARN 4024 --- [ main] com.caucho.server.webapp.WebApp : java.lang.IllegalStateException: Registration is null. Was something already registered for name=[er
rorPageFilter]?
java.lang.IllegalStateException: Registration is null. Was something already registered for name=[errorPageFilter]?
at org.springframework.util.Assert.state(Assert.java:385)
at org.springframework.boot.context.embedded.RegistrationBean.configure(RegistrationBean.java:107)
at org.springframework.boot.context.embedded.FilterRegistrationBean.configure(FilterRegistrationBean.java:241)
at org.springframework.boot.context.embedded.FilterRegistrationBean.onStartup(FilterRegistrationBean.java:233)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:214)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:619)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:130)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:89)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:51)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at com.caucho.server.webapp.WebApp.callInitializer(WebApp.java:3494)
at com.caucho.server.webapp.WebApp.callInitializers(WebApp.java:3462)
at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3687)
at com.caucho.server.webapp.WebApp.access$400(WebApp.java:207)
at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5231)
at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173)
at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)
[14-03-12 17:06:31.541] {main} java.lang.IllegalStateException: Registration is null. Was something already registered for name=[errorPageFilter]?
at org.springframework.util.Assert.state(Assert.java:385)
at org.springframework.boot.context.embedded.RegistrationBean.configure(RegistrationBean.java:107)
at org.springframework.boot.context.embedded.FilterRegistrationBean.configure(FilterRegistrationBean.java:241)
at org.springframework.boot.context.embedded.FilterRegistrationBean.onStartup(FilterRegistrationBean.java:233)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:214)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:619)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:130)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:89)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:51)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at com.caucho.server.webapp.WebApp.callInitializer(WebApp.java:3494)
at com.caucho.server.webapp.WebApp.callInitializers(WebApp.java:3462)
at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3687)
at com.caucho.server.webapp.WebApp.access$400(WebApp.java:207)
at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5231)
at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173)
at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)
[14-03-12 17:06:31.543] {main} Host[production/host/default] active
[14-03-12 17:06:31.543] {main} ServletService[id=app-0,cluster=app] active
[14-03-12 17:06:31.543] {main}
[14-03-12 17:06:31.544] {main} http listening to *:8080
[14-03-12 17:06:32.294] {main} https listening to *:8443
[14-03-12 17:06:32.313] {main}
[14-03-12 17:06:32.327] {main} Resin[id=app-0] started in 17193ms
2014-03-12 17:08:31.542 INFO 4024 --- [ resin-29] com.caucho.server.webapp.WebApp : WebApp[production/webapp/default/spring-boot-war-sample-1.1.1] stopping
一位对Resin有一些经验的同事告诉我,加载jar文件存在问题,如下所示!在每个jar文件的末尾。
答案 0 :(得分:2)
请参阅错误参考:http://bugs.caucho.com/view.php?id=5701
您可以将自己添加为此错误的“监视”,以便通知进度。
答案 1 :(得分:1)
出于某种原因,Resin强制添加到上下文中的过滤器(以编程方式?)必须具有public
修饰符。 Spring Boot中的ErrorPageFilter
受到包保护,因此检查失败(检查Resin和Spring Boot的来源)。
我可以想象通过Filter
方法添加的ServletContext.addFilter(String, Class)
的检查。不适用于方法ServletContext.addFilter(String, Filter)
。 Spring Boot使用后者来注册过滤器。
我认为这是树脂中的一个错误。
答案 2 :(得分:1)
在2014年11月3日的Resin 4.0.42中,这似乎是fixed。
答案 3 :(得分:0)
我遇到了类似的问题,并且能够通过移除以下属于树脂分布的罐子来解决该问题:
还有: / webapp-jars / jboss-logging-3。*。jar 可能会引起问题。
据Caucho所说,树脂本身不使用这些文件。因此,您可以删除它们,并依靠WAR上的库。