3 Replies Latest reply: Apr 27, 2012 4:59 AM by Arunbodap-Oracle RSS

    Persistence Layer deployed as Optional Package

    513108
      Environment:
      - WebLogic 11g which consequently means EJB 3.0
      - Application has 3 modules: Web (referencing EJB and Persistence), EJB (referencing Persistence) and Persistence

      Could I deploy my persistence layer as an Optional Package or does it have to be a Shared Library?
      The reason I'm asking is that when I try to deploy my EJB module, WLS can't find the persistence unit being inject to it:

      Unable to deploy EJB: StocksBean from BLayer-1.0.0-SNAPSHOT.jar: No persistence unit named 'internalAppsPU' is available in scope BLayer-1.0.0-SNAPSHOT.jar. Available persistence units: []

      Persistence module is basically a JAR file deployed as an Optional Package with following in its Manifest:

      Extension-Name: PersistenceLayer
      Implementation-Version: 1.0.0-SNAPSHOT
      Specification-Version: 1.6

      in EJB's code I have:

      @Stateless(name="StocksBean", mappedName="StocksBean")
      public class StocksBean implements Stocks {

           @PersistenceContext(unitName = "internalAppsPU")
           private EntityManager em;
           .....
      }

      and in EJB's JAR file I have:

      pLayer-Extension-Name: PersistenceLayer
      pLayer-Implementation-Version: 1.0.0-SNAPSHOT
      pLayer-Specification-Version: 1.6

      I'm deploying these one by one and not as an Application.
        • 1. Re: Persistence Layer deployed as Optional Package
          Arunbodap-Oracle
          You can choose to deploy your persistence layer as an Optional Package, not required to deploy it as a Shared Library.

          I believe the problem could be due to the configuration (all these configurations are case-senstivie, so we have to be very careful)

          Here are some checks that I could think of:
          - I am assuming that the Persistence jar is named or deployed as pLayer
          - And that you have configured/added the following line in the manifest of your EJB JAR.
          Extension-List: pLayer (please check the case, small "p" versus capital "P" mismatch)

          And one more obvious thing to check:
          - You are deploying the Persistence package before the EJB JAR.
          - The order of deployment in this case should be
          1. Persistence JAR as optional package
          2. EJB JAR
          3. Web application WAR


          Arun
          • 2. Re: Persistence Layer deployed as Optional Package
            513108
            Hi Arun,

            Thank you so much for taking time and responding. I'm still having the same issue.

            You see, I had the exact same problem when my persistence Entities were in the same Jar file as EJBs and I found out the problem was the name of the persistence.xml file (which was "Persistence.xml") and also the version of the namespace used in the XML file which conflicted with version of JPA's spi (version of JPA's spi in JEE1.6 is 1.0 and I was using version 2.0 of the namespace).

            However, I got that fixed and now I'm trying to separate the layers (just moved the files around and didn't change the content). Here is what I have so far:

            Name of Persistence Layer's JAR file: PLayer.jar
            Manifest of Persistence Layer's JAR file:

            Manifest-Version: 1.0
            Archiver-Version: Plexus Archiver
            Created-By: Apache Maven
            Built-By: bm03043
            Build-Jdk: 1.6.0_18
            Extension-Name: PersistenceLayer
            Implementation-Version: 1.0.0-SNAPSHOT
            Specification-Version: 1.6


            Name of EJB's JAR file: BLayer-1.0.0-SNAPSHOT.jar
            Manifest of EJB's JAR file:

            Manifest-Version: 1.0
            Archiver-Version: Plexus Archiver
            Created-By: Apache Maven
            Built-By: bm03043
            Build-Jdk: 1.6.0_18
            Extension-List: PLayer
            PLayer-Extension-Name: PersistenceLayer
            PLayer-Implementation-Version: 1.0.0-SNAPSHOT
            PLayer-Specification-Version: 1.6


            I didn't know that Extension-List entry in EJB's jar file should match with the name of Persistence layer's jar file.

            As for deployment, I deploy the Player and then EJB.

            Appreciate any input.

            Edited by: Keibi on Apr 26, 2012 11:30 AM
            • 3. Re: Persistence Layer deployed as Optional Package
              Arunbodap-Oracle
              I do not see any configuration issue now.
              So, it might need further debugging. I would recommend contacting support.


              Arun