1
votes

I get in inheritance EAR application which I need to continue to develop. The problem that I can't cause it work on Websphere Liberty 16.0.0.4 while on Websphere Application Server Full Profile 8.5 it works fine. Unfortunately or (fortunately :) ) my working station is Macbook Pro, and WAS Full Profile can't be installed on OSX (can't find links right now, but have done some search and find enough evidences for it) so I need to use VirtualBox with Linux or try to run this app on Liberty.

The latest solution doesn't work so well for me, I get the following error:

[ERROR ] CWWJP0012E: The persistence unit name is not specified and a unique persistence unit is not found in the BigEnterpriseAppEAR application and BigEnterpriseAppEJB.jar module. [ERROR ] CWWJP0029E: The server cannot find the persistence unit in the BigEnterpriseAppEJB.jar module and the BigEnterpriseAppEAR application. [ERROR ] CWNEN0035E: The java:comp/env/BigEnterpriseApp reference of type javax.persistence.EntityManager for the DataProvider component in the BigEnterpriseAppEJB.jar module of the BigEnterpriseAppEAR application cannot be resolved. [ERROR ] CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "getDataByOwner" on bean "BeanId(BigEnterpriseAppEAR#BigEnterpriseAppWEB.war#DataAPI, null)". Exception data: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: The java:comp/env/BigEnterpriseApp reference of type javax.persistence.EntityManager for the DataProvider component in the BigEnterpriseAppEJB.jar module of the BigEnterpriseAppEAR application cannot be resolved.

The app is pretty simple EAR = JPA + EJB + WAR

I don't know which configuration files would be helpful, so just write in a comments what to post and I will do it.

Thank you in advance.

UPDATE 1:

server.xml file:

<server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>localConnector-1.0</feature>
         <feature>servlet-3.1</feature>
         <feature>ejbLite-3.1</feature>
         <feature>jndi-1.0</feature>
         <feature>jaxrs-1.1</feature>
         <feature>ssl-1.0</feature>
         <feature>jpa-2.0</feature>
         <feature>cdi-1.0</feature>
    </featureManager>

    <basicRegistry id="basic" realm="BasicRealm">
        <!-- <user name="yourUserName" password="" />  -->
    </basicRegistry>

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>


    <applicationMonitor updateTrigger="mbean"/>

    <library id="DB2JCC4Lib">
         <fileset dir="/Users/anatoly/developer/sql_drivers" includes="*.jar"/>
    </library>

    <dataSource id="db2_slc" jndiName="jdbc/BEADB" type="javax.sql.DataSource">
            <jdbcDriver libraryRef="DB2JCC4Lib"/>
            <properties.db2.jcc databaseName="beadb" password="********" portNumber="50000" serverName="db2server" user="db2username"/>
    </dataSource>

    <keyStore id="defaultKeyStore" password="******"/>

    <enterpriseApplication id="BigEnterpriseAppEAR" location="BigEnterpriseAppEAR.ear" name="BigEnterpriseAppEAR"/>
</server>

persistence.xml file, located in BigEnterpriseAppJPA > src > META-INF > persistence.xml

in packaged EAR persistence.xml located in BigEnterpriseAppEAR -> BigEnterpriseAppJPA.jar -> META-INF -> persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
    <persistence-unit name="BigEnterpriseApp">
        <jta-data-source>jdbc/BEADB</jta-data-source>
        <class>com.bea.entities.System</class>
        <class>com.bea.entities.Data</class>
        <class>com.bea.entities.User</class>
        <class>com.bea.entities.Group</class>
        <properties>
            <property name="openjpa.jdbc.Schema" value="BEADB" />
            <property name="openjpa.ConnectionRetainMode" value="transaction" />
        </properties>
    </persistence-unit>
</persistence>
1
A good start would be to post your server.xml and persistence.xml.F Rowe
@FRowe, done. Thank you!Anatoly
What's the location of persistence.xml?F Rowe
it's located in: BigEnterpriseAppJPA > src > META-INF > persistence.xmlAnatoly
What's the location of persistence.xml in the packaged EAR? The Liberty profile strictly interprets the location per the JPA spec while the full profile accepts non-standard locations.Brett Kail

1 Answers

0
votes

[ERROR ] CWWJP0012E: The persistence unit name is not specified and a unique persistence unit is not found in the BigEnterpriseAppEAR application and BigEnterpriseAppEJB.jar module.

This would imply your persistence.xml roots are not at the legal locations defined by the JPA spec, section 8.2:

In Java EE environments, the root of a persistence unit must be one of the following:

  • an EJB-JAR file
  • the WEB-INF/classes directory of a WAR file[87]
  • a jar file in the WEB-INF/lib directory of a WAR file
  • a jar file in the EAR library directory
  • an application client jar file

NOTE: Java Persistence 1.0 supported use of a jar file in the root of the EAR as the root of a persistence unit. This use is no longer supported. Portable applications should use the EAR library directory for this case instead

Your setup seems to be trying to use #4?

BigEnterpriseAppEAR -> BigEnterpriseAppJPA.jar -> META-INF -> persistence.xml

BigEnterpriseAppJPA.jar should be placed inside your EAR library directory. I believe this will be BigEnterpriseAppEAR/lib by default, but you can configure this with your /META-INF/application.xml in the EAR

Also note, that the persistence-unit name must be unique. Make sure that all persistence-unit names are not using the same name.