简体   繁体   中英

How do I setup the Mule JPA Module to use the Hibernate JPA implementation?

I am trying to setup Mule to use the Mule JPA Module ( http://mulesoft.github.io/mule-module-jpa/mule/jpa.html ) but I am running into a dependency problem.

I have added JPA module via Mule Studio which sets up the maven dependencies for me for that. I have also added the hibernate-entitymanager dependancy to my pom to provide a JPA implementation. I've added version 3.6.0 the same as the version of hibernate-core included in the Mule runtime. However when I try start the Mule application I get the following stacktrace:

INFO  2013-08-30 09:33:20,428 [main] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean: Building JPA container EntityManagerFactory for persistence unit 'org.jembi.openhim.jpa'
INFO  2013-08-30 09:33:20,525 [main] org.hibernate.annotations.common.Version: Hibernate Commons Annotations 3.2.0.Final
INFO  2013-08-30 09:33:20,530 [main] org.hibernate.cfg.Environment: Hibernate 3.6.0.Final
INFO  2013-08-30 09:33:20,531 [main] org.hibernate.cfg.Environment: hibernate.properties not found
INFO  2013-08-30 09:33:20,533 [main] org.hibernate.cfg.Environment: Bytecode provider name : javassist
INFO  2013-08-30 09:33:20,536 [main] org.hibernate.cfg.Environment: using JDK 1.4 java.sql.Timestamp handling
INFO  2013-08-30 09:33:20,594 [main] org.hibernate.ejb.Version: Hibernate EntityManager 3.6.0.Final
ERROR 2013-08-30 09:33:20,609 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
java.lang.IllegalAccessError: tried to access method org.hibernate.engine.CascadeStyle.<init>()V from class org.hibernate.engine.EJB3CascadeStyle$1
    at org.hibernate.engine.EJB3CascadeStyle$1.<init>(EJB3CascadeStyle.java:44)
    at org.hibernate.engine.EJB3CascadeStyle.<clinit>(EJB3CascadeStyle.java:39)
    at org.hibernate.ejb.event.EJB3PersistEventListener.<clinit>(EJB3PersistEventListener.java:39)
    at org.hibernate.ejb.EventListenerConfigurator.<init>(EventListenerConfigurator.java:101)
    at org.hibernate.ejb.Ejb3Configuration.<init>(Ejb3Configuration.java:159)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:288)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:922)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:89)
    at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:109)
    at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:119)
    at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:73)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
    at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:101)
    at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:57)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:84)
    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:207)
    at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64)
    at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:47)
    at org.mule.tooling.server.application.ApplicationDeployer.run(ApplicationDeployer.java:58)
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:91)

It seems that there is a version mismatch or something that is causing this but I can't figure out why. I'm using the same version of the entity manager as hibernate core. Any idea of what I can try?

The Mule distribution at ${MULE_HOME}/lib/opt contains the Hibernate core jars but it does not have the Hibernate Entity Manager jar. If you include the same jar in your classpath, it'll try to access the core classes for hibernate from the /lib/opt jars, but, it'll give a IllegalAccessError as it has been loaded by a diff classloader. So, try removing the Hibernate jars provided by Mule from /lib/opt folder and add your own by any way you are using for your project [build path or pom, etc].

I guess it should work.

-Shanky G.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM