如何设置Mule JPA模块以使用Hibernate JPA实现?

时间:2013-08-30 08:05:45

标签: java hibernate maven jpa mule

我正在尝试设置Mule以使用Mule JPA模块(http://mulesoft.github.io/mule-module-jpa/mule/jpa.html),但我遇到了依赖性问题。

我已经通过Mule Studio添加了JPA模块,为我设置了maven依赖项。我还将hibernate-entitymanager依赖性添加到我的pom中以提供JPA实现。我添加的版本3.6.0与Mule运行时中包含的hibernate-core版本相同。但是,当我尝试启动Mule应用程序时,我得到以下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)

似乎存在版本不匹配或导致此问题,但我无法弄清楚原因。我使用与hibernate核心相同版本的实体管理器。知道我能尝试什么吗?

1 个答案:

答案 0 :(得分:0)

$ {MULE_HOME} / lib / opt的Mule发行版包含Hibernate核心jar,但它没有Hibernate Entity Manager jar。如果在类路径中包含相同的jar,它将尝试从/ lib / opt jars访问hibernate的核心类,但是,它会给出一个由diff类加载器加载的IllegalAccessError。因此,尝试从/ lib / opt文件夹中删除Mule提供的Hibernate jar,并以您用于项目的任何方式添加自己的[构建路径或pom等]。

我想它应该有用。

-Shanky G。