Uploaded image for project: 'OpenEJB'
  1. OpenEJB
  2. OPENEJB-1243

Automatically override eclipselink.target-server for all EclipseLink persistence units

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2
    • Fix Version/s: None
    • Component/s: configuration
    • Labels:
      None
    • Environment:
      EclipseLink 2.0.1
      OpenEJB 3.1.2

      Description

      This enhancement request aims at extending OPENEJB-881 (Automatically set eclipselink.target-server for EclipseLink).

      It may happen that some apps built on top of OpenEJB have to reuse as-is EclipseLink persistence units that were initially built for other EJB runtimes (let's say WebSphere Application Server). In that case, the persistence unit would look like this:


      <?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="nxtCommons" transaction-type="JTA">
      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
      <jta-data-source>jdbc/NXTDataSource</jta-data-source>
      <exclude-unlisted-classes>false</exclude-unlisted-classes>
      <properties>
      <property name="eclipselink.jdbc.native-sql" value="true"/>
      <property name="eclipselink.logging.level" value="FINER"/>
      <property name="eclipselink.target-database" value="Oracle"/>
      <property name="eclipselink.target-server" value="WebSphere"/>
      </properties>
      </persistence-unit>
      </persistence>

      Notice the eclipselink.target-server property set to WebSphere.
      Of course, when you directly reuse this PU from OpenEJB, you end up getting the following exception because EclipseLink tries to load WebSphere's transaction manager:


      Exception in thread "main" javax.ejb.EJBException: The bean encountered a non-application exception; nested exception is:
      javax.persistence.PersistenceException: Exception [EclipseLink-23004] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.TransactionException
      Exception Description: Error obtaining the Transaction Manager
      Internal Exception: java.lang.ClassNotFoundException: com.ibm.ws.Transaction.TransactionManagerFactory
      at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:358)[EL Finer]: 2010-03-19 09:51:51.828-ServerSession(1148404851)Thread(Thread[main,5,main])-Could not initialize Validation Factory. Encountered following exception: java.lang.NoClassDefFoundError: javax.validation.ValidatorFactory
      [EL Severe]: 2010-03-19 09:51:51.859-ServerSession(1148404851)Thread(Thread[main,5,main])-Local Exception Stack:
      Exception [EclipseLink-23004] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.TransactionException
      Exception Description: Error obtaining the Transaction Manager
      Internal Exception: java.lang.ClassNotFoundException: com.ibm.ws.Transaction.TransactionManagerFactory
      at org.eclipse.persistence.exceptions.TransactionException.errorObtainingTransactionManager(TransactionException.java:125)
      at org.eclipse.persistence.transaction.JTATransactionController.<init>(JTATransactionController.java:69)
      ...

      As such, it is mandatory to manually override the eclipselink.target-server property for all PUs, for example as follow:


      Properties p = new Properties();
      p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
      p.put("nxtCommons.eclipselink.target-server", "org.apache.openejb.eclipselink.JTATransactionController");

      ==> This would be good if OpenEJB provides an automatic mechanism which would override the eclipselink.target-server property of all PUs, particularly if these PUs are bundled as JAR files.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rseguy Romain Seguy
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: