glassfish
  1. glassfish
  2. GLASSFISH-15869

JPADeployer throws NPE while deploying hybrid application contaning persistence.xml using asadmin command

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1_b40
    • Fix Version/s: 3.1.1, 4.0
    • Component/s: entity-persistence
    • Labels:
      None

      Description

      Try deploying the attached war as:
      asadmin deploy --type=osgi rfc143.test4.war
      Although it deploys fine, there is actually an NPE in the server.log:

      [#|2011-02-06T22:50:33.384+0530|WARNING|glassfish3.1|javax.enterprise.system.core.org.glassfish.kernel.event|_ThreadID=157;_ThreadName=admin-thread-pool-4848(5);|Exception while dispatching an event
      java.lang.NullPointerException
      at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:472)
      at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:453)
      at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:377)
      at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:452)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:372)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:354)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:369)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1080)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1260)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1248)
      at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:453)
      at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:220)
      at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
      at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:619)

      #]

      The root cause here is that JPADeployer assumes there always exists a RootDeploymentDescriptor, which is not correct as in this case. There was a similar bug in ejb container as well. The fix is really simple as the patch below shows:

      Index: persistence/jpa-connector/src/main/java/org/glassfish/persistence/jpa/JPADeployer.java
      ===================================================================
      — persistence/jpa-connector/src/main/java/org/glassfish/persistence/jpa/JPADeployer.java (revision 44807)
      +++ persistence/jpa-connector/src/main/java/org/glassfish/persistence/jpa/JPADeployer.java (working copy)
      @@ -468,7 +468,7 @@
      // We are being called for an application
      currentBundle = context.getModuleMetaData(Application.class);
      }
      -
      + if (currentBundle == null) return;
      Collection<PersistenceUnitsDescriptor> pusDescriptorForThisBundle = currentBundle.getExtensionsDescriptors(PersistenceUnitsDescriptor.class);
      for (PersistenceUnitsDescriptor persistenceUnitsDescriptor : pusDescriptorForThisBundle) {
      for (PersistenceUnitDescriptor pud : persistenceUnitsDescriptor.getPersistenceUnitDescriptors()) {

      Since this is not a critical bug, as the NPE is itself not causing deployment to fail, this has been excluded from 3.1 release.

        Activity

        Hide
        Sanjeeb Sahoo added a comment -

        The exception has changed slightly in 3.2 trunk builds:

        [#|2011-04-21T23:37:40.167+0530|WARNING|glassfish3.2|javax.enterprise.system.core.org.glassfish.kernel.event|_ThreadID=25;_ThreadName=admin-thread-pool-4848(3);|Exception while dispatching an event
        java.lang.NullPointerException
        at com.sun.enterprise.deployment.util.DOLUtils.getCurrentBundleForContext(DOLUtils.java:122)
        at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:478)
        at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:465)
        at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:389)
        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:453)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:390)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:357)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:372)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1071)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1251)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1239)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:455)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:619)

        #]

        Now, the fix is needed in both in JPADeployer and DOLUtils. I am taking ownership of this bug and will fix it soon.

        Show
        Sanjeeb Sahoo added a comment - The exception has changed slightly in 3.2 trunk builds: [#|2011-04-21T23:37:40.167+0530|WARNING|glassfish3.2|javax.enterprise.system.core.org.glassfish.kernel.event|_ThreadID=25;_ThreadName=admin-thread-pool-4848(3);|Exception while dispatching an event java.lang.NullPointerException at com.sun.enterprise.deployment.util.DOLUtils.getCurrentBundleForContext(DOLUtils.java:122) at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:478) at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:465) at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:389) at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:453) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:390) at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:357) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:372) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1071) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1251) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1239) at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:455) at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212) at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168) at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:619) #] Now, the fix is needed in both in JPADeployer and DOLUtils. I am taking ownership of this bug and will fix it soon.
        Hide
        Sanjeeb Sahoo added a comment -

        Sending deployment/dol/src/main/java/com/sun/enterprise/deployment/util/DOLUtils.java
        Sending persistence/jpa-connector/src/main/java/org/glassfish/persistence/jpa/JPADeployer.java
        Transmitting file data ..
        Committed revision 46306.

        Show
        Sanjeeb Sahoo added a comment - Sending deployment/dol/src/main/java/com/sun/enterprise/deployment/util/DOLUtils.java Sending persistence/jpa-connector/src/main/java/org/glassfish/persistence/jpa/JPADeployer.java Transmitting file data .. Committed revision 46306.
        Hide
        Sanjeeb Sahoo added a comment -

        It has been backported to 3.1.1 as a side effect of some other merge done by someone else. So, I don't have the details. But, I can't reproduce the bug against 3.1.1, so it is definitely fixed in 3.1.1.

        Show
        Sanjeeb Sahoo added a comment - It has been backported to 3.1.1 as a side effect of some other merge done by someone else. So, I don't have the details. But, I can't reproduce the bug against 3.1.1, so it is definitely fixed in 3.1.1.

          People

          • Assignee:
            Sanjeeb Sahoo
            Reporter:
            Sanjeeb Sahoo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: