This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 229634 - JBoss: Deployed CMP JPA applications on JBoss 4 fail to find Entities - no dynamic weaving available
Summary: JBoss: Deployed CMP JPA applications on JBoss 4 fail to find Entities - no dy...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/E...
Whiteboard:
Keywords:
Depends on: 227630 227707 229629 230030
Blocks: 252965 293581
  Show dependency tree
 
Reported: 2008-04-30 10:37 EDT by Michael OBrien CLA
Modified: 2022-06-09 10:23 EDT (History)
1 user (show)

See Also:


Attachments
eclipselink.core.patch (pre-code-review) (18.10 KB, patch)
2008-05-01 16:22 EDT, Michael OBrien CLA
no flags Details | Diff
eclipselink.jpa.patch (pre-code-review) (5.56 KB, patch)
2008-05-01 16:23 EDT, Michael OBrien CLA
no flags Details | Diff
JBoss deployment log for jsfejb3 example (12.37 KB, text/plain)
2008-05-01 16:50 EDT, Michael OBrien CLA
no flags Details
eclipselink.trunk.patch (pde) (18.58 KB, patch)
2008-05-02 16:21 EDT, Michael OBrien CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael OBrien CLA 2008-04-30 10:37:03 EDT
Problem:
------------
Missing descriptor for CMP3 JPA static weaved Entity class on JBoss 422
CMP JPA applications are failing after deployment in JBoss 4.2.2 when a JPA query is attempted.

The following two fixes were raised to deal with the UCL3.loadClass() NPE in EJBTHREE-572
http://jira.jboss.com/jira/browse/EJBTHREE-572

Fixed
https://bugs.eclipse.org/227630
Working
https://bugs.eclipse.org/229629

This bug should remain open until CMP Entity applications using EclipseLink as JPA provider, deploy and run on JBoss 4.2.2 - either through code changes or a documented procedure for JEE developers.
Applications that use JPA in SE mode (PU Factory is instantiated instead of injecting the PU) are functioning fine, CMP applications are deploying ok via persistence.xml but currently the Entity descriptors are not defined causing runtime errors when using the Persitence Unit.

For all JBoss issues we can extend their published EJB3 example to use as a common reproduction scenario between our groups.

This model is flat (no 1-1 or many-1) - so weaving should not be a performance issue.
RedHat JBoss example documentation:
http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.3/doc/Getting_Started/html-single/index.html#EJB3_Caveats
JBoss EJB3 example binary:
http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.3/gettingstarted.zip

Stack Trace:
----------------------
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
   {
      boolean trace = log.isTraceEnabled();
      if (trace)
         log.trace("loadClass " + this + " name=" + name+",
loadClassDepth="+loadClassDepth);
      Class clazz = null;
      try
      {
         if (repository != null)
         {
            clazz = repository.getCachedClass(name);
            if (clazz != null)
            {
               if( log.isTraceEnabled() )
               {
                  StringBuffer buffer = new StringBuffer("Loaded class from
cache, ");
                  ClassToStringAction.toString(clazz, buffer);
                  log.trace(buffer.toString());
               }
               return clazz;
            }
         }
         clazz = loadClassImpl(name, resolve, Integer.MAX_VALUE);
         return clazz;
      }
      finally
      {
         if (trace)
         {
            if (clazz != null)
               log.trace("loadClass " + this + " name=" + name + " class=" +
clazz + " cl=" + clazz.getClassLoader());
            else
--->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<T>.forName0(String, boolean, ClassLoader) line: not available
[native method]     
        Class<T>.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     


Actions:
----------------------
1) Document migration steps for JBoss public CMP3 example
2) Enter standard migration example with specific settings/workarounds for JEE containers
3) Document JBoss requires explicit classes in PU or abstract schema not found error occurs
4) Document JBoss @EJB injection workaround for servlet container using JNDI lookup (JBPAPP-192)
	http://jira.jboss.org/jira/browse/JBPAPP-192   
5) Document static weaving procedure including (no update behavior for existing jar - without a clean)
6) Update EclipseLink Wiki with specific workarounds for JBoss deployment
	Official Documentation:
	http://www.oracle.com/technology/products/ias/toplink/doc/11110/devguide/asinteg.htm#BCGBCBHD
	http://wiki.eclipse.org/Integrating_EclipseLink_with_an_Application_Server_(ELUG)#Integrating_EclipseLink_with_JBoss_Application_Server
	http://docs.jboss.org/ejb3/app-server/tutorial/

References:
----------------------
Requests for assistance in getting EclipseLink, TopLink, or Essentials working with JBoss.
http://jira.jboss.com/jira/browse/EJBTHREE-572
http://lists.jboss.org/pipermail/jboss-user/2007-July/068649.html
http://lists.jboss.org/pipermail/jboss-user/2006-September/013404.html
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973347#3973347
http://www.mailinglistarchive.com/jboss-user@lists.jboss.org/msg88123.htmlhttp://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967171#3967171
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128290#4128290
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4103456#4103456
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=63&t=002769
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=63&t=002591
http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2008-02/msg00827.html
http://www.velocityreviews.com/forums/t590864-cannot-create-toplink-persistance-in-jboss-422.html
http://devforum.besysoft.com/viewtopic.php?f=122&t=323
http://kr.forums.oracle.com/forums/thread.jspa?threadID=579642
http://forums.oracle.com/forums/thread.jspa?messageID=2186220&#2186220
https://glassfish.dev.java.net/issues/show_bug.cgi?id=3721
Related but here the temp CL is null instead of the UCL3
http://jboss.com/index.html?module=bb&op=viewtopic&t=91175&view=next
Comment 1 Michael OBrien CLA 2008-04-30 16:15:05 EDT
Did some investigation on CMP deployment on JBoss.
Was able to successfully load and query a statically weaved entity by switching to using the real classloader - previously my test entity was configured wrong.

Proposed Solution:
------------------
1) NOT USED - For NoPlatform we do a test tempClassLoader.loadClass("Version") and if we get a NPE we treat is as a CNFE and switch to using the [real] classLoader.
   For JBossPlatform we always use the [real] loader and ignore the [temp] one
   For all other Platforms we get the .getNewTempClassLoader() normally

2) IN USE - Same as 1) but we require that all persistence.xml set the target-server property to JBoss and not do a .loadClass() check - which is a hack workaround for the NPE.
<property name="eclipselink.target-server" value="org.eclipse.persistence.platform.server.jboss.JBossPlatform"/>


Comment 2 Michael OBrien CLA 2008-05-01 16:22:21 EDT
Created attachment 98364 [details]
eclipselink.core.patch (pre-code-review)
Comment 3 Michael OBrien CLA 2008-05-01 16:23:16 EDT
Created attachment 98365 [details]
eclipselink.jpa.patch (pre-code-review)
Comment 4 Michael OBrien CLA 2008-05-01 16:50:42 EDT
Created attachment 98372 [details]
JBoss deployment log for jsfejb3 example
Comment 5 Michael OBrien CLA 2008-05-01 16:51:54 EDT
JBoss predeploy() will emit the following warning for all users:

16:27:41,449 INFO  [STDOUT] [EPS Warning]: 2008.05.01 16:27:41.434--Thread(Thread[main,5,jboss])--The classLoader [org.jboss.mx.loading.UnifiedClassLoader3@10014f0{ url=file:/C:/opt/jboss422/server/default/tmp/deploy/tmp61269jsfejb3.ear ,addedOrder=0}] for PersistenceLoadProcessor [helloworld] is causing a NPE on loadClass. Switching classLoader to [org.jboss.mx.loading.UnifiedClassLoader3@26fbfc{ url=file:/C:/opt/jboss422/server/default/tmp/deploy/tmp61269jsfejb3.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. 
Comment 6 Michael OBrien CLA 2008-05-02 16:21:47 EDT
Created attachment 98504 [details]
eclipselink.trunk.patch (pde)

Code reviewed by Tom
Comment 7 Michael OBrien CLA 2008-05-02 16:26:53 EDT
I also need to update the Tutorial and ELUG with the following.

http://wiki.eclipse.org/EclipseLink/Examples/JPA/JBoss_Web_Tutorial

http://wiki.eclipse.org/Integrating_EclipseLink_with_an_Application_Server_(ELUG)#Integrating_EclipseLink_with_JBoss_Application_Server


	Description:
		For JIRA EJBTHREE-572 http://jira.jboss.com/jira/browse/EJBTHREE-572
		EclipseLink will use the non-temporary classLoader instead of the normally used temporary classLoader from JBoss that causes 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. 
	<property name="eclipselink.target-server" value="org.eclipse.persistence.platform.server.jboss.JBossPlatform"/>



Comment 8 Michael OBrien CLA 2008-05-02 16:33:56 EDT
See Wiki documentation task in
http://bugs.eclipse.org/230030
Comment 9 Michael OBrien CLA 2008-05-02 23:04:18 EDT
Changes tested and committed to revision 15928
Comment 10 Michael OBrien CLA 2008-05-02 23:19:50 EDT
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.
Comment 11 Michael OBrien CLA 2008-05-05 09:21:01 EDT
Todo: Add JBoss JPA server tests setup/build/run with/without eclipselink.weaving="static"|"STATIC"
http://bugs.eclipse.org/227707
Comment 12 Michael OBrien CLA 2008-05-05 15:42:16 EDT
See HSQL database platform request - low priority that should not impact closing this bug but would aide in JBoss/Hibernate migration.

JBoss: Add HSQL database platform
http://bugs.eclipse.org/229730
Comment 13 Michael OBrien CLA 2008-05-06 07:39:48 EDT
See static weaving and target-server workaround for JBoss at
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/JBoss
Comment 14 Michael OBrien CLA 2008-06-30 11:48:44 EDT
The root bug - EJBTHREE-572 has been reassigned.

http://jira.jboss.com/jira/browse/EJBTHREE-572?page=comments#action_12419381
            
Ales Justin commented on EJBTHREE-572:
--------------------------------------
Re-assigning to Scott, since this is UCL3 usage issue.

Comment 15 Michael OBrien CLA 2008-07-15 14:43:46 EDT
Root NON-ECLIPSE EJBTHREE-572 remains unfixed
Comment 16 Eclipse Webmaster CLA 2022-06-09 10:15:47 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 17 Eclipse Webmaster CLA 2022-06-09 10:23:44 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink