Hi there!
I'm using OpenEJB 3.1.3 embedded in Tomcat 5.5.26 and I use hibernate 3.6 as a JPA provider.
Here's my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
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">
<persistence-unit name="manager1" transaction-type="JTA">
<!-- provider is optional if you work with only 1 JPA provider -->
<!--
<provider>org.hibernate.ejb.HibernatePersistence</provider>
-->
<jta-data-source>java:/DefaultDS</jta-data-source>
<!--
<properties>
<property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml" />
</properties>
-->
</persistence-unit>
</persistence>
Here's my code:
@Stateless
public class MapSearchManager implements MapSearchLocal, MapSearchRemote {
@PersistenceContext
private EntityManager em;
...
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public int queryDataSelectionNumRecords(MapSearchParamBean paramBean) {
Criteria c = createCriteria(paramBean);
c.setProjection(Projections.rowCount());
List l = c.list();
...
}
...
}
When I run tomcat with OpenEJB and my app war archives in it, the deployment failed with exception stack trace:
2010-10-27 18:13:35,374 - ERROR - Unable to deploy collapsed ear in war /wma: Exception: Creating application failed: C:\apache-tomcat-5.5.26\webapps\wma: javax/persistence/spi/ProviderUtil
org.apache.openejb.OpenEJBException: Creating application failed: C:\apache-tomcat-5.5.26\webapps\wma: javax/persistence/spi/ProviderUtil
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:666)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:449)
at org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java:249)
at org.apache.openejb.tomcat.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:58)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:179)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:489)
... 27 more
Upon searching, I found the class javax/persistence/spi/ProviderUtil is part of Java EE 6/JPA 2.0 spec, which is not supported by OpenEJB. But I dont think in my app I use any JPA 2.0. I specifically mention in persistence.xml of 1.0. I know hibernate 3.6 supports JPA 2.0. I don't know if hibernate's Criteria API is part of JPA 2.0 but that shouldn't cause the problem bcause I have specifically menitioned 1.0 in persistence.xml.
Thank you for your help.
Regards
Will