【发布时间】:2016-12-08 07:25:36
【问题描述】:
我在运行 undertow 和 spring-boot 1.4 时遇到 NullPointerException。
如果你运行joinfaces-example 会看到这个错误
java -jar target/joinfaces-example-2.1.3-SNAPSHOT.jar
我意识到,如果我在 IDE (NetBeans) 中调试项目,则不会发生错误。
更多,这个错误是在我将 spring boot 升级到 1.4 时开始的。如果我将 jsf-spring-boot-parent 版本更改为使用 spring boot 1.3 版本的 2.0.0,则不会发生错误。
当 StartupServletContextListener 未激活时,可能会出现此错误。它由 UndertowMyfacesSpringBootAutoConfiguration 创建。 Debug表示已激活:
UndertowMyfacesSpringBootAutoConfiguration 匹配 - 找到@ConditionalOnClass 类:io.undertow.Undertow,org.apache.myfaces.webapp.StartupServletContextListener (OnClassCondition)上面的堆栈跟踪:
java.lang.NullPointerException:在 org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration 处为空(Jsp21FacesInitializer.java:62)~[myfaces-bundle-2.2.10.jar!/:2.2.10] 在 org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:172) ~[myfaces-bundle-2.2.10.jar!/:2.2.10] 在 org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:121) [myfaces-bundle-2.2.10.jar!/:2.2.10] 在 io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) [undertow-servlet-1.3.23.Final.jar!/:1.3.23.Final] 在 io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198) [undertow-servlet-1.3.23.Final.jar!/:1.3.23.Final] 在 org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.createDeploymentManager(UndertowEmbeddedServletContainerFactory.java:390) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.getEmbeddedServletContainer(UndertowEmbeddedServletContainerFactory.java:224) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) [spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE] 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE] 在 org.joinfaces.example.JoinFacesExampleApplication.main(JoinFacesExampleApplication.java:10) [classes!/:2.1.4-SNAPSHOT] 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101] 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101] 在 java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101] 在 org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT] 在 org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT] 在 org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT] 在 org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]【问题讨论】:
-
NPE 的堆栈跟踪是什么?
-
我刚刚编辑了@AndyWilkinson 的问题。
标签: spring-boot undertow