问题
I am using the embeddable EJB container of WebSphere 8 to write some unit tests for my EJBs with JUnit4. I have a simple java project in MyEclipse where I reference the EJB project. The EJB project uses Hibernate 3.5 for persistence and the datasource JNDI in hibernate.cfg.xml is jdbc/connectionname which is defined in the properties of the embeddable container.
The embeddable container starts successfully, the EJBs can be found successfully and the datasource is also found successfully. However, on any first method call of an EJB method the followin exception is thown:
org.hibernate.HibernateException: java.lang.ClassNotFoundException: com.ibm.websphere.jtaextensions.SynchronizationCallback
at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter.<init>(WebSphereExtendedJTATransactionLookup.java:108)
at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter.<init>(WebSphereExtendedJTATransactionLookup.java:88)
at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup.getTransactionManager(WebSphereExtendedJTATransactionLookup.java:70)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:367)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
Any advice would be appreciated.
回答1:
The embeddable EJB container in WebSphere Application Server does not support ExtendedJTATransaction, but it does support java:comp/TransactionSynchronizationRegistry. I am not familiar with Hibernate, but it would seem that it should be updated to use TransactionSynchronizationRegistry when available.
来源:https://stackoverflow.com/questions/9772266/websphere-embeddable-ejb-container-with-hibernate-throws-java-lang-classnotfound