1

Environment

  • WebLogic 11g (consequently Java EE 5 and EJB 3.0)
  • An EJB contained JAR that also holds all persistence Entities. It worked fine (have a web app that uses the EJB and it works as expected). I decided to separate Entities to another layer and to do this I created another module and deploy that as an Optional Package. So now I have two JAR files which, by the way, I deploy separately and not as part of one application; persistence JAR and EJB JAR.

Problem

During the deployment of EJB I get the following error (which tells me that the Optional Package wasn't found):

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: []

More Info

Manifest of persistence module's JAR

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: bm03043
Build-Jdk: 1.6.0_18
Extension-Name: com.amir.persistence
Implementation-Version: 1.0.0
Specification-Version: 1.6

persistence.XML in META-INF folder of persistence module's JAR

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="internalAppsPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>InternalAppsDS</jta-data-source>
        <class>com.xx.persistence.Stock</class>
        <properties>
            <property name="eclipselink.logging.level" value="FINE" />
        </properties>
    </persistence-unit>
</persistence>

EJB's code

package com.xx.bll;

// bunch of imports //

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

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

   // SNIP //
}

Manifest of EJB's JAR

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

Please take note the following:

  • The InternalAppsDS data source is configured previously in WebLogic.
  • At some point I was under the impression that names in Extension-List have to match the names of JAR files deployed as Optional Package. But as I read more I realized that's not correct.
Amir Keibi
  • 1,991
  • 28
  • 45
  • Have you tried using com.amir.persistence for the Extension-Name? – Jeff West Apr 30 '12 at 19:58
  • Yes. That was it. I fixed this a while ago and then I came across your comment today. Never got notified that someone has actually responded. Thanks. That would've saved me some time. – Amir Keibi Jul 11 '12 at 18:44

1 Answers1

0

So the answer is to use the same Extension-name used in the Library.

Amir Keibi
  • 1,991
  • 28
  • 45