Bug 296178

Summary: NonJTA Datasource testing failed on WebSphere
Product: z_Archived Reporter: Kevin Yuan <kevin.yuan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tom.ware
Version: unspecifiedKeywords: test
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 296961    
Bug Blocks:    

Description Kevin Yuan CLA 2009-11-25 14:50:40 EST
The following are persistence.xml:

<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 persistence_1_0.xsd" version="1.0">
    <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <non-jta-data-source>jdbc/ELNonJTADS</non-jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.target-server" value="WebSphere_6_1"/>
            <property name="eclipselink.validate-existence" value="true"/>
            <property name="eclipselink.descriptor.customizer.Employee" value="org.eclipse.persistence.testing.models.jpa.advanced.Customizer"/>
            <property name="eclipselink.descriptor.customizer.org.eclipse.persistence.testing.models.jpa.advanced.Address" value="org.eclipse.persistence.testing.models.jpa.advanced.Customizer"/>
            <property name="eclipselink.descriptor.customizer.Project" value="org.eclipse.persistence.testing.models.jpa.advanced.Customizer"/>
            <property name="eclipselink.logging.level" value="FINEST"/>
        </properties>
    </persistence-unit>
</persistence>

The following are exception during run tests (deploy seems successful):

    [junit] Running org.eclipse.persistence.testing.tests.jpa.advanced.AdvancedServerTestSuite
    [junit]     >> SERVER (id=4773e3aa, host=kyuan-pc.ca.oracle.com) TRACE START:
    [junit]     >>    javax.ejb.EJBException: Injection failure; nested exception is: java.lang.Runt
imeException: See JPA spec 5.5: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar#
must specify JTA transaction type.
    [junit]     >> SERVER (id=4773e3aa, host=kyuan-pc.ca.oracle.com) TRACE END.
    [junit] ; nested exception is: java.lang.RuntimeException: See JPA spec 5.5: PuId=eclipselink-ad
vanced-model#eclipselink-advanced-model_ejb.jar# must specify JTA transaction type.)
    [junit]     >> SERVER (id=4773e3aa, host=kyuan-pc.ca.oracle.com) TRACE START:
    [junit]     >>    javax.ejb.EJBException: Injection failure; nested exception is: java.lang.Runt
imeException: See JPA spec 5.5: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar#
must specify JTA transaction type.
    [junit]     >> SERVER (id=4773e3aa, host=kyuan-pc.ca.oracle.com) TRACE END.
    [junit] ; nested exception is: java.lang.RuntimeException: See JPA spec 5.5: PuId=eclipselink-ad
vanced-model#eclipselink-advanced-model_ejb.jar# must specify JTA transaction type.)
    [junit]     >> SERVER (id=4773e3aa, host=kyuan-pc.ca.oracle.com) TRACE START:
    [junit]     >>    javax.ejb.EJBException: Injection failure; nested exception is: java.lang.Runt
imeException: See JPA spec 5.5: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar#
must specify JTA transaction type.

And the following exception are from server log:

[11/25/09 14:33:10:500 EST] 00000027 LocalTranCoor E   WLTC0017E: Resources rolled back due to setRollbackOnly() being called.
[11/25/09 14:33:10:515 EST] 0000002c InjectionBind E   CWNEN0030E: The com.ibm.ws.util.JPAJndiLookupObjectFactory@285e285e factory encountered a problem getting the object instance Reference Class Name: javax.persistence.EntityManager
Type: JPAJndiLookupInfo
Content: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar#, eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar#TestRunner#org.eclipse.persistence.testing.framework.server.TestRunnerBean/entityManager, isFactory=false, isSFSB=false, PersistenceContextType=Transaction, properties=[]
 binding object.
[11/25/09 14:33:10:515 EST] 0000002c BusinessExcep E   CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "runTest". Exception data: javax.ejb.EJBException: Injection failure; nested exception is: java.lang.RuntimeException: See JPA spec 5.5: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar# must specify JTA transaction type.
java.lang.RuntimeException: See JPA spec 5.5: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar# must specify JTA transaction type.
	at com.ibm.ws.jpa.management.JPATxEntityManager.<init>(JPATxEntityManager.java:121)
	at com.ibm.ws.jpa.management.JPAComponentImpl.getEntityManager(JPAComponentImpl.java:1043)
	at com.ibm.ws.util.JPAJndiLookupObjectFactory.getObjectInstance(JPAJndiLookupObjectFactory.java:151)
	at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:590)
	at com.ibm.wsspi.injectionengine.InjectionTargetField.inject(InjectionTargetField.java:245)
	at com.ibm.ws.injectionengine.InjectionEngineImpl.inject(InjectionEngineImpl.java:579)
	at com.ibm.ejs.container.StatelessBeanO.initialize(StatelessBeanO.java:316)
	at com.ibm.ejs.container.BMStatelessBeanOFactory.create(BMStatelessBeanOFactory.java:45)
	at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1028)
	at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1138)
	at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:84)
	at com.ibm.ejs.container.activator.Activator.activateBean(Activator.java:599)
	at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3956)
	at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3341)
	at org.eclipse.persistence.testing.framework.server.EJSRemote0SLTestRunner_ed643271.runTest(EJSRemote0SLTestRunner_ed643271.java)
	at org.eclipse.persistence.testing.framework.server._EJSRemote0SLTestRunner_ed643271_Tie.runTest(_EJSRemote0SLTestRunner_ed643271_Tie.java)
	at org.eclipse.persistence.testing.framework.server._EJSRemote0SLTestRunner_ed643271_Tie._invoke(_EJSRemote0SLTestRunner_ed643271_Tie.java)
	at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:622)
	at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:475)
	at com.ibm.rmi.iiop.ORB.process(ORB.java:504)
	at com.ibm.CORBA.iiop.ORB.process(ORB.java:1571)
	at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2771)
	at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2640)
	at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:63)
	at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
javax.ejb.EJBException: Injection failure; nested exception is: java.lang.RuntimeException: See JPA spec 5.5: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar# must specify JTA transaction type.
Caused by: java.lang.RuntimeException: See JPA spec 5.5: PuId=eclipselink-advanced-model#eclipselink-advanced-model_ejb.jar# must specify JTA transaction type.
	at com.ibm.ws.jpa.management.JPATxEntityManager.<init>(JPATxEntityManager.java:121)
	at com.ibm.ws.jpa.management.JPAComponentImpl.getEntityManager(JPAComponentImpl.java:1043)
	at com.ibm.ws.util.JPAJndiLookupObjectFactory.getObjectInstance(JPAJndiLookupObjectFactory.java:151)
	at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:590)
	at com.ibm.wsspi.injectionengine.InjectionTargetField.inject(InjectionTargetField.java:245)
	at com.ibm.ws.injectionengine.InjectionEngineImpl.inject(InjectionEngineImpl.java:579)
	at com.ibm.ejs.container.StatelessBeanO.initialize(StatelessBeanO.java:316)
	at com.ibm.ejs.container.BMStatelessBeanOFactory.create(BMStatelessBeanOFactory.java:45)
	at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1028)
Comment 1 Tom Ware CLA 2009-11-26 10:52:31 EST
The server framework is written to run with Transactional EntityManagers so any tests written for resource local EMs or Extended EMs will not run in our server tests.
Comment 2 Kevin Yuan CLA 2009-11-26 11:06:40 EST
The server test framework made change manually in order to to run nonJTA datasource on server, and also successfully run nonJTA datasource on WLS, some snippet code just like the following:

    public boolean isTransactionActive(EntityManager entityManager) {
        if (isOnServer() && isJTA()) {
            return getServerPlatform().isTransactionActive();
        } else {
            return entityManager.getTransaction().isActive();
        }
    }
Comment 3 Tom Ware CLA 2009-11-26 11:23:06 EST
The issue is with how the EM is obtaionss:

@PersistenceContext
    private EntityManager entityManager;


By default, that's a transactional EM.  That is likely why WAS is throwing an exception for the NON JTA datasoruce issue.
Comment 4 Tom Ware CLA 2009-11-26 13:50:45 EST
Reopening as a test case bug - as per above.

Note: We have seen issues with running non-jta datasources on WLS, so the fix is not as simple as changing the way the injection works.  More configuration may be required to get the non-jta datasource working properly.
Comment 5 Kevin Yuan CLA 2010-03-09 16:09:53 EST
Already fixed on both 2.0.2 and trunk. Refer to the bug: 296961.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:20:17 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink