Upon initialization of a SLSB in WebSphere 7.0 I get the following exception:
Code:
[2.2.09 10:33:04:828 CET] 00000013 BusinessExcep E CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "ping". Exception data: javax.ejb.EJBException: Injection failure; nested exception is: java.lang.IllegalArgumentException: Can not set org.hibernate.Session field beans.TestBeanEJB.session to com.ibm.ws.jpa.management.JPATxEntityManager
java.lang.IllegalArgumentException: Can not set org.hibernate.Session field beans.TestBeanEJB.session to com.ibm.ws.jpa.management.JPATxEntityManager
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:158)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:162)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:75)
at java.lang.reflect.Field.set(Field.java:659)
at com.ibm.wsspi.injectionengine.InjectionTargetField.inject(InjectionTargetField.java:253)
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.CMStatelessBeanOFactory.create(CMStatelessBeanOFactory.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 beans.EJSRemote0SLTestBeanEJB_505e9ee2.ping(EJSRemote0SLTestBeanEJB_505e9ee2.java)
at beans._EJSRemote0SLTestBeanEJB_505e9ee2_Tie.ping(_EJSRemote0SLTestBeanEJB_505e9ee2_Tie.java)
at beans._EJSRemote0SLTestBeanEJB_505e9ee2_Tie._invoke(_EJSRemote0SLTestBeanEJB_505e9ee2_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:1573)
at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2793)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2662)
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)
The bean looks like:
Code:
@Stateless
@Remote
public class TestBeanEJB implements TestBean {
@PersistenceContext(unitName = "Test")
private Session session;
public String ping() {
return "pong";
}
}
my persistence.xml looks like:
Code:
<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
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="Test">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/MyDS</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<!-- WebSphere transaction manager lookup class -->
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"/>
</properties>
</persistence-unit>
</persistence>
The application is packed as an ear with an ejb-jar containing the bean. There are no exceptions during application installation/startup and Hibernate initializes without any errors.
I'm using WebSphere 7.0 + Fix pack 1.
Why does the injection engine try to inject a JPATxEntityManager and not a Hibernate session here?
Regards,
Magnus