2 Replies Latest reply on May 4, 2008 3:16 PM by mfobrien

    TopLink with Jboss 4.2.1 not working?

    tsirel84

      I'm stuck with the problem described in this forum thread:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=128533
      and decided to try toplink instead of hibernate to see whether it is hibernate problem.

      But when I'm using toplink
      1) if I'm not specifying toplink.target-server property like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence">
       <persistence-unit name="first">
       <provider>oracle.toplink.essentials.PersistenceProvider</provider>
       <jta-data-source>java:/TestEJB3DS</jta-data-source>
       <properties>
       <!--<property name="toplink.target-server" value="oracle.toplink.essentials.platform.server.jboss.JBossPlatform"/>-->
       <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
       </properties>
       </persistence-unit>
      </persistence>


      all entities fails to deploy with such messages:
      13:14:14,143 INFO [STDOUT] [TopLink Warning]: 2008.02.08 01:14:14.143--java.lang.NullPointerException: null was thrown on attempt of PersistenceLoadProcessor to load class com.gemini.test.ejb.entity.relationship.Course. The class is ignored.


      2) and if I'm adding this property:
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence">
       <persistence-unit name="first">
       <provider>oracle.toplink.essentials.PersistenceProvider</provider>
       <jta-data-source>java:/TestEJB3DS</jta-data-source>
       <properties>
       <property name="toplink.target-server" value="oracle.toplink.essentials.platform.server.jboss.JBossPlatform"/>
       <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
       </properties>
       </persistence-unit>
      </persistence>


      deployment fails with:
      
      13:25:08,617 WARN [ServiceController] Problem starting service persistence.units:ear=javaEEApplication.ear,jar=EJB.jar,unitName=first
      javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
      Exception Description: predeploy for PersistenceUnit [first] failed.
      Internal Exception: java.lang.NullPointerException
       at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:615)
       at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:178)
       at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:247)



      Any ideas?

        • 1. Re: TopLink with Jboss 4.2.1 not working?
          tsirel84

          Slightly digged in, look for my comment to:
          http://jira.jboss.com/jira/browse/EJBTHREE-572

          • 2. Re: TopLink with Jboss 4.2.1 not working?
            mfobrien

            Hi,
            The following workaround has been checked in for EclipseLink M8 to work with JBoss 4.2.2 GA.
            Container managed entities should predeploy/deploy and register now with/without static weaving.
            When the UCL3 classLoader no longer causes a NPE (See JIRA http://jira.jboss.com/jira/browse/EJBTHREE-572 ) we will reenable dynamic weaving on EAR predeploy().

            http://bugs.eclipse.org/229634

            Workaround:
            ---------------------------------
            EclipseLink will use the non-temporary classLoader instead of the one from getNewTempClassLoader() obtained from the JBoss PersistenceUnitInfo that throws a NPE on loadClass() or Class.forName().
            We require that JBoss implementers statically weave container managed entities and reference JBoss as the target-server in persistence.xml.

            Deployment Changes:
            1) If weaving is required then static weave the entities before EAR packaging using either the command-line weaver or the weaving ant task.
            2) All persistence units deployed to the JBoss container must contain the following property in persistence.xml or container managed entities will predeploy but fail to be managed at runtime.



            JBoss AS 4.2.2 GA debugging:
            ----------------------------------------------------------
            I debugged the UCL3 NullPointerException into the JBoss AS 4.2.2 GA source into the following segment of code.

            In the following function the classloader parent tree is searched all the way to the root.
            no clazz is returned and in the finally clause the last log.trace causes a RuntimeException on a NPE.
            Curious though that the line number in Logger.trace() does not correspond to the JDK 1.5 src.

            package org.jboss.mx.loading
            public abstract class RepositoryClassLoader extends URLClassLoader
            public Class loadClass(String name, boolean resolve)
            throws ClassNotFoundException
            ...
            finally
            ...
            --->NPE log.trace("loadClass " + this + " name=" + name + " not found");
            }
            }
            }

            Thread [main] (Suspended)
            UnifiedClassLoader3(RepositoryClassLoader).loadClass(String, boolean) line: 425
            UnifiedClassLoader3(ClassLoader).loadClass(String) line: 251
            UnifiedClassLoader3(ClassLoader).loadClassInternal(String) line: 319
            Class.forName0(String, boolean, ClassLoader) line: not available [native method]
            Class.forName(String, boolean, ClassLoader) line: 242
            PrivilegedAccessHelper.getClassForName(String, boolean, ClassLoader) line: 85
            XMLEntityMappings.getClassForName(String, ClassLoader) line: 120
            XMLEntityMappings.getClassForName(String) line: 157
            XMLEntityMappings.initPersistenceUnitClasses() line: 389
            MetadataProcessor.initPersistenceUnitClasses() line: 188
            MetadataProcessor.processEntityMappings() line: 298

            Results:
            --------
            15:41:43,772 INFO [STDOUT] [EPS Warning]: 2008.05.02 15:41:43.755--Thread(Thread[main,5,jboss])--The temporary classLoader for PersistenceLoadProcessor [helloworld] is not available. Switching classLoader to [org.jboss.mx.loading.UnifiedClassLoader3@18b995c{ url=file:/C:/opt/jboss422/server/default/tmp/deploy/tmp13465jsfejb3.ear ,addedOrder=45}]. Weaving has been disabled for this session. EclipseLink may be unable to get a spec mandated temporary class loader from the server, you may be able to use static weaving as an optional workaround.
            15:41:44,221 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=jsfejb3.ear,jar=app.jar,name=TodoDao,service=EJB3 with dependencies:
            15:41:44,221 INFO [JmxKernelAbstraction] persistence.units:ear=jsfejb3.ear,jar=app.jar,unitName=helloworld
            15:41:44,359 INFO [EJBContainer] STARTED EJB: TodoDao ejbName: TodoDao
            15:42:45,344 INFO [STDOUT] [EPS Finer]: 2008.05.02 15:42:45.343--UnitOfWork(20862427)--Thread(Thread[http-127.0.0.1-8080-1,5,jboss])--TX binding to tx mgr, status=STATUS_ACTIVE
            15:42:45,344 INFO [STDOUT] [EPS Finest]: 2008.05.02 15:42:45.344--UnitOfWork(20862427)--Thread(Thread[http-127.0.0.1-8080-1,5,jboss])--Execute query DoesExistQuery()
            15:42:45,350 INFO [STDOUT] [EPS Finest]: 2008.05.02 15:42:45.350--UnitOfWork(20862427)--Thread(Thread[http-127.0.0.1-8080-1,5,jboss])--PERSIST operation called on: Todo@15914f3.

            thank you
            /michael