1

The build of my maven project is a war which contains spring-data-commons-1.13.4.RELEASE.jar, hibernate-jpa-2.1-api-1.0.0.Final.jar, hibernate-entitymanager-5.0.12.Final.jar etc.

I have configured the datasource in the tomee.xml and the relevant snippet of persistence.xml is given below:

 <persistence-unit name="PU_JTA"  transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  
    <jta-data-source>java:/comp/env/jdbc/myDS</jta-data-source>  
    <mapping-file>META-INF/orm.xml</mapping-file>
    <properties>
        ...
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect" />

By default Tomee, is using in built EclipseLink and throwing the following:

[EclipseLink-25008] (Eclipse Persistence Services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element {http://java.sun.com/xml/ns/persistence/orm}entity-mappings was not found in the project 

and when I removed the eclipselink-2.6.3.jar from tomee/libs,

[localhost-startStop-1] org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate PersistenceUnit(name=merchantEdgePU_JTA, provider=org.eclipse.persistence.jpa.PersistenceProvider) - provider time 1ms
09-Oct-2017 18:19:10.027 SEVERE [localhost-startStop-1] org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal Error merging Java EE JNDI entries in to war /merchantEdgeREST: Exception: java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider
org.apache.openejb.OpenEJBRuntimeException: java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider 

Most of the references like this OR this are suggesting to "Load all Hibernate jars and dependencies ... in tomee/libs folder".

Is it possible to use the hibernate & spring (jpa) jars from the war I have deployed to apache-tomee-plume-7.0.3 overriding the default configuration?

lab bhattacharjee
  • 1,617
  • 2
  • 17
  • 33
  • There is an article about that topic http://tomee.apache.org/tomee-and-hibernate.html – Simon Martinelli Oct 09 '17 at 14:55
  • @simas_ch, It is saying the same thing, right? – lab bhattacharjee Oct 09 '17 at 16:44
  • The question is why you want to use TomEE with Spring and Hibernate. Why don't you use Tomcat instead? TomEE is a Java EE server. – Simon Martinelli Oct 09 '17 at 16:56
  • @simas_ch, I've have already done that. I originally had only REST APIs to expose.Now client wants a HTML5+ js wrapper on it.So I was planning to create another war (as there can be another interface of the REST API like Mobile ), then bundling the whole as ear. – lab bhattacharjee Oct 09 '17 at 17:49
  • If you really want to use Spring I would suggest to stay with Tomcat and deploy two separat war instead of bundling that in an ear. Using a fully featured Java EE app server like TomEE and then exchange components doesn't make sense and will give you further problems because it's not tested in your configuration. – Simon Martinelli Oct 09 '17 at 18:58
  • @simas_ch under what conditions you suggest to use TomEE instead tomcat? – Omid Ashouri May 14 '21 at 13:47

0 Answers0