glassfish
  1. glassfish
  2. GLASSFISH-451

NPE when running ear less appclient jar that has multiple PUs

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.0pe
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      451

      Description

      Take the attached test case. The client.jar has two PUs defined in it. The main
      class is referencing to one of them using
      @PersistenceUnit(unitName="pu1") EntityManagerFacory emf;

      It has been verified using verifier; no issues detected. After deploying, when I
      ran it using 'appclient -client /tmp/ClientJars/clientClient.jar foo', got the
      following output:
      Listening for transport dt_socket at address: 9007
      Mar 21, 2006 11:34:51 PM com.sun.enterprise.appclient.MainWithModuleSupport <init>
      WARNING: ACC003: Application threw an exception.
      java.lang.NullPointerException
      at
      com.sun.enterprise.deployment.BundleDescriptor.getVisiblePUs(BundleDescriptor.java:755)
      at
      com.sun.enterprise.deployment.BundleDescriptor.findReferencedPU0(BundleDescriptor.java:701)
      at
      com.sun.enterprise.deployment.BundleDescriptor.findReferencedPU(BundleDescriptor.java:626)
      at
      com.sun.enterprise.appclient.PersistenceUnitLoaderImpl.findReferencedPUs(PersistenceUnitLoaderImpl.java:101)
      at
      com.sun.enterprise.appclient.PersistenceUnitLoaderImpl.load(PersistenceUnitLoaderImpl.java:66)
      at
      com.sun.enterprise.appclient.AppClientInfo.handlePersistenceUnitDependency(AppClientInfo.java:249)
      at
      com.sun.enterprise.appclient.AppClientInfo.completeInit(AppClientInfo.java:160)
      at
      com.sun.enterprise.appclient.AppClientInfoFactory.buildAppClientInfo(AppClientInfoFactory.java:136)
      at
      com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:277)
      at com.sun.enterprise.appclient.Main.main(Main.java:180)

      It only appears, when there are multiple PUs.

        Activity

        Hide
        Sanjeeb Sahoo added a comment -

        Created an attachment (id=154)
        test case along with README

        Show
        Sanjeeb Sahoo added a comment - Created an attachment (id=154) test case along with README
        Hide
        Sanjeeb Sahoo added a comment -

        Root Cause:
        -----------
        public Map<String, PersistenceUnitDescriptor> getVisiblePUs() {
        ...
        // ear scoped PUs
        for(PersistenceUnitsDescriptor pus:
        getApplication().getPersistenceUnitsDescriptors())

        { // line #755 ... }

        BundleDescriptor.java:755 is where we are assuming that getApplication() returns
        a valid Application object. While this is true when this code path is exercised
        by verifier, deployment backend as well as server runtime, when ACC runs an ear
        less client jar, getApplication() is returning null.
        Suggested Fix:
        --------------
        Add a null check.

        – Sahoo

        Show
        Sanjeeb Sahoo added a comment - Root Cause: ----------- public Map<String, PersistenceUnitDescriptor> getVisiblePUs() { ... // ear scoped PUs for(PersistenceUnitsDescriptor pus: getApplication().getPersistenceUnitsDescriptors()) { // line #755 ... } BundleDescriptor.java:755 is where we are assuming that getApplication() returns a valid Application object. While this is true when this code path is exercised by verifier, deployment backend as well as server runtime, when ACC runs an ear less client jar, getApplication() is returning null. Suggested Fix: -------------- Add a null check. – Sahoo
        Hide
        Sanjeeb Sahoo added a comment -

        Checking in
        appserv-commons/src/java/com/sun/enterprise/deployment/BundleDescriptor.java;
        /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/deployment/BundleDescriptor.java,v
        <-- BundleDescriptor.java
        new revision: 1.22; previous revision: 1.21
        done

        Show
        Sanjeeb Sahoo added a comment - Checking in appserv-commons/src/java/com/sun/enterprise/deployment/BundleDescriptor.java; /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/deployment/BundleDescriptor.java,v <-- BundleDescriptor.java new revision: 1.22; previous revision: 1.21 done
        Hide
        Sanjeeb Sahoo added a comment -

        The issue also appears when there is only one PU, but it is referenced using
        unitName=<> in @PersistenceUnit or @persistenceContext.

        It has been verified to work now.

        Show
        Sanjeeb Sahoo added a comment - The issue also appears when there is only one PU, but it is referenced using unitName=<> in @PersistenceUnit or @persistenceContext. It has been verified to work now.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: