Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-17919

[GSS](7.3.z) WAR deployment fails due to NPE when both MBean and persistence-unit are packaged

XMLWordPrintable

    • Hide

      1. Add the following persistence.xml to helloworld-mbean-webapp in EAP 7 QuickStarts "helloworld-mbean"

      helloworld-mbean-webapp/src/main/resources/META-INF/persistence.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.1"
          xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="
              http://xmlns.jcp.org/xml/ns/persistence
              http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
          <persistence-unit name="example">
              <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
              <properties>
                  <!-- Properties for Hibernate -->
                  <!-- <property name="hibernate.hbm2ddl.auto" value="create-drop" /> -->
                  <property name="hibernate.show_sql" value="false" />
              </properties>
          </persistence-unit>
      </persistence>
      

      2. Build and deploy helloworld-mbean-webapp.war to JBoss EAP 7.2

      3. Start JBoss EAP 7.2

      You will see that the deployment fails due to NullPointerException.

      Show
      1. Add the following persistence.xml to helloworld-mbean-webapp in EAP 7 QuickStarts "helloworld-mbean" helloworld-mbean-webapp/src/main/resources/META-INF/persistence.xml <?xml version= "1.0" encoding= "UTF-8" ?> <persistence version= "2.1" xmlns= "http: //xmlns.jcp.org/xml/ns/persistence" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http: //xmlns.jcp.org/xml/ns/persistence http: //xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name= "example" > <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source> <properties> <!-- Properties for Hibernate --> <!-- <property name= "hibernate.hbm2ddl.auto" value= "create-drop" /> --> <property name= "hibernate.show_sql" value= " false " /> </properties> </persistence-unit> </persistence> 2. Build and deploy helloworld-mbean-webapp.war to JBoss EAP 7.2 3. Start JBoss EAP 7.2 You will see that the deployment fails due to NullPointerException.

      When a web application contains both MBean (jboss-service.xml) and persistence-unit (persistence.xml), the WAR deployment fails due to the following NullPointerException:

      12:32:36,613 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."helloworld-mbean-webapp.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."helloworld-mbean-webapp.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "helloworld-mbean-webapp.war"
      	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:151)
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1737)
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1699)
      	at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1557)
      	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1364)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.NullPointerException: Method parameter cannot be null
      	at org.jboss.msc.service.ServiceBuilderImpl.assertNotNull(ServiceBuilderImpl.java:574)
      	at org.jboss.msc.service.ServiceBuilderImpl.addDependencies(ServiceBuilderImpl.java:242)
      	at org.jboss.msc.service.ServiceBuilderImpl.addDependencies(ServiceBuilderImpl.java:234)
      	at org.jboss.as.service.MBeanServices.<init>(MBeanServices.java:112)
      	at org.jboss.as.service.ParsedServiceDeploymentProcessor.addServices(ParsedServiceDeploymentProcessor.java:133)
      	at org.jboss.as.service.ParsedServiceDeploymentProcessor.deploy(ParsedServiceDeploymentProcessor.java:118)
      	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:144)
      	... 8 more
      
      ...(snip)...
      
      12:32:37,720 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "helloworld-mbean-webapp.war")]) - failure description: {
          "WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"helloworld-mbean-webapp.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"helloworld-mbean-webapp.war\"
          Caused by: java.lang.NullPointerException: Method parameter cannot be null"},
          "WFLYCTL0412: Required services that are not installed:" => [
              "jboss.deployment.unit.\"helloworld-mbean-webapp.war\".WeldStartService",
              "jboss.deployment.unit.\"helloworld-mbean-webapp.war\".beanmanager"
          ],
          "WFLYCTL0180: Services with missing/unavailable dependencies" => [
              "jboss.deployment.unit.\"helloworld-mbean-webapp.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"helloworld-mbean-webapp.war\".beanmanager, jboss.deployment.unit.\"helloworld-mbean-webapp.war\".WeldStartService]",
              "jboss.deployment.unit.\"helloworld-mbean-webapp.war\".batch.artifact.factory is missing [jboss.deployment.unit.\"helloworld-mbean-webapp.war\".beanmanager]"
          ]
      }
      

      This NPE happens because WebNonTxEmCloserAction#dependencies() returns null. It should return Collections.emptySet() instead of null.

      By the way, the same code exists there in EAP 7.1 but the NPE did not happen in EAP 7.1.x. Because JBoss MSC changed the null-check handling by MSC-203 and MSC-240. org.jboss.msc.service.ServiceBuilderImpl just skipped the processing when a dependency is null in the previous behavior, but it now throws "NullPointerException: Method parameter cannot be null".

              chaowan@redhat.com Chao Wang
              chaowan@redhat.com Chao Wang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: