Marcelo Fernandes
Marcelo Fernandes

Reputation: 163

Error with undertow and spring-boot 1.4

I'm getting NullPointerException when running undertow and spring-boot 1.4.

You can see this error if you run joinfaces-example with

java -jar target/joinfaces-example-2.1.3-SNAPSHOT.jar

I realized that the error does not occur if I debug the project inside IDE (NetBeans).

More, this error started when I upgraded spring boot to 1.4. No error occurs if I change jsf-spring-boot-parent version to 2.0.0 which uses spring boot 1.3 version.

This error may occur when StartupServletContextListener is not activated. It is created by UndertowMyfacesSpringBootAutoConfiguration. Debug said it is activated:

   UndertowMyfacesSpringBootAutoConfiguration matched
      - @ConditionalOnClass classes found: io.undertow.Undertow,org.apache.myfaces.webapp.StartupServletContextListener (OnClassCondition)

Stack trace above:

java.lang.NullPointerException: null at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:62) ~[myfaces-bundle-2.2.10.jar!/:2.2.10]
    at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:172) ~[myfaces-bundle-2.2.10.jar!/:2.2.10]
    at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:121) [myfaces-bundle-2.2.10.jar!/:2.2.10]
    at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) [undertow-servlet-1.3.23.Final.jar!/:1.3.23.Final]
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198) [undertow-servlet-1.3.23.Final.jar!/:1.3.23.Final]
    at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.createDeploymentManager(UndertowEmbeddedServletContainerFactory.java:390) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.getEmbeddedServletContainer(UndertowEmbeddedServletContainerFactory.java:224) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) [spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.joinfaces.example.JoinFacesExampleApplication.main(JoinFacesExampleApplication.java:10) [classes!/:2.1.4-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [joinfaces-example-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]

Upvotes: 1

Views: 1890

Answers (1)

Marcelo Fernandes
Marcelo Fernandes

Reputation: 163

The error is with JoinFaces Undertow starter because it was using two versions of JspFactory class.

Duplicate Finder Maven Plugin is now used to avoid duplicated classes and resources.

Upvotes: 1

Related Questions