MuleESB -3.4 CE:jpa和hibernate版本支持?

时间:2013-11-13 11:23:04

标签: spring hibernate jpa mule

我在Mule中测试一个POC,包括Mule,就像bean spring一样,我遇到了Hibernate和Jpa依赖的问题。现在每个机构都支持/使用哪个版本的Hibernate和JPA在Mule 3.4 CE中。

当我不想运行流程时,我有很多异常:whith hibernate 3.6.0.Final:

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)

4.0.1和uppe:

  java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V
    at org.hibernate.service.ServiceRegistryBuilder.buildServiceRegistry(ServiceRegistryBuilder.java:244)
    at org.hibernate.ejb.Ejb3Configuration.buildLifecycleControledServiceRegistry(Ejb3Configuration.java:930)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:903)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
    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)

我的依赖树:

[INFO] +- org.mule:mule-core:jar:3.4.0:provided
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.8.0:provided
[INFO] |  +- org.safehaus.jug:jug:jar:asl:2.0.0:provided
[INFO] |  +- commons-cli:commons-cli:jar:1.2:provided
[INFO] |  +- commons-collections:commons-collections:jar:3.2.1:provided
[INFO] |  +- commons-io:commons-io:jar:1.4:provided
[INFO] |  +- commons-lang:commons-lang:jar:2.4:provided
[INFO] |  +- commons-pool:commons-pool:jar:1.5.3:provided
[INFO] |  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:provided
[INFO] |  +- javax.annotation:jsr250-api:jar:1.0:provided
[INFO] |  +- org.slf4j:jcl-over-slf4j:jar:1.6.1:provided
[INFO] |  +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] |  +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] |  +- log4j:log4j:jar:1.2.16:compile
[INFO] |  +- asm:asm:jar:3.1:provided
[INFO] |  +- asm:asm-commons:jar:3.1:provided
[INFO] |  |  \- asm:asm-tree:jar:3.1:provided
[INFO] |  +- org.mvel:mvel2:jar:2.1.3.Final:provided
[INFO] |  +- org.jgrapht:jgrapht-jdk1.5:jar:0.7.3:provided
[INFO] |  \- org.mule.common:mule-common:jar:0.11.0:provided
[INFO] +- org.mule.modules:mule-module-spring-config:jar:3.4.0:provided
[INFO] |  +- org.mule.modules:mule-module-annotations:jar:3.4.0:provided
[INFO] |  |  \- cglib:cglib-nodep:jar:2.2:provided
[INFO] |  +- org.springframework:spring-context:jar:3.2.1.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:3.2.1.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-expression:jar:3.2.1.RELEASE:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1-osgi:provided
[INFO] |  \- jaxen:jaxen:jar:1.1.1:provided
[INFO] |     \- jdom:jdom:jar:1.0:provided
[INFO] +- org.mule.transports:mule-transport-file:jar:3.4.0:provided
[INFO] +- org.mule.modules:mule-module-xml:jar:3.4.0:provided
[INFO] |  +- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:provided
[INFO] |  +- commons-jxpath:commons-jxpath:jar:1.3-osgi:provided
[INFO] |  +- com.thoughtworks.xstream:xstream:jar:1.4.2:provided
[INFO] |  |  \- xmlpull:xmlpull:jar:1.1.3.1:provided
[INFO] |  +- joda-time:joda-time:jar:1.6:provided
[INFO] |  +- xpp3:xpp3_min:jar:1.1.3.4.O-osgi:provided
[INFO] |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.0.8:provided
[INFO] |  |  \- org.codehaus.woodstox:stax2-api:jar:3.0.2:provided
[INFO] |  +- net.java.dev.stax-utils:stax-utils:jar:20080702-osgi:provided
[INFO] |  +- net.sf.saxon:saxon:jar:8.9.0.4-osgi:provided
[INFO] |  +- net.sf.saxon:saxon-dom:jar:8.9.0.4-osgi:provided
[INFO] |  +- net.sf.saxon:saxon-xqj:jar:8.9.0.4:provided
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.1:provided
[INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.1.5:provided
[INFO] +- org.mule.tests:mule-tests-functional:jar:3.4.0:test
[INFO] |  +- org.springframework:spring-beans:jar:3.2.1.RELEASE:compile
[INFO] |  +- commons-net:commons-net:jar:2.0:test
[INFO] |  +- org.apache.ftpserver:ftpserver-core:jar:1.0.2:test
[INFO] |  |  \- org.apache.mina:mina-core:jar:2.0.0-M6:test
[INFO] |  +- org.apache.ftpserver:ftplet-api:jar:1.0.2:test
[INFO] |  +- org.apache.sshd:sshd-core:jar:0.6.0:test
[INFO] |  +- bouncycastle:bcprov-jdk14:jar:139:test
[INFO] |  +- org.mule:mule-core:test-jar:tests:3.4.0:test
[INFO] |  |  +- javax.activation:activation:jar:1.1-osgi:provided
[INFO] |  |  \- org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec:jar:1.1-osgi:test
[INFO] |  \- org.mockito:mockito-all:jar:1.9.0:test
[INFO] +- mockobjects:mockobjects-core:jar:0.09:test
[INFO] +- junit:junit:jar:4.9:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- mysql:mysql-connector-java:jar:5.1.10:compile
[INFO] +- org.mule.transports:mule-transport-email:jar:3.4.0:provided
[INFO] |  \- javax.mail:mail:jar:1.4.3:provided
[INFO] +- org.mule.transports:mule-transport-jdbc:jar:3.4.0:provided
[INFO] |  +- commons-dbutils:commons-dbutils:jar:1.2:provided
[INFO] |  \- com.experlog:xapool:jar:1.5.0-osgi:provided
[INFO] +- org.springframework:spring-orm:jar:3.2.1.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- org.springframework:spring-core:jar:3.2.1.RELEASE:compile
[INFO] |     \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.0.1.Final:test
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:test
[INFO] |  +- org.hibernate:hibernate-core:jar:4.0.1.Final:test
[INFO] |  |  \- antlr:antlr:jar:2.7.7:test
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:test
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.1.0.CR2:test
[INFO] |  +- org.javassist:javassist:jar:3.15.0-GA:test
[INFO] |  \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:test
[INFO] \- fr.myapp:jar:0.0.1-SNAPSHOT:compile
[INFO]    +- org.springframework:spring-jdbc:jar:3.2.4.RELEASE:compile
[INFO]    |  \- org.springframework:spring-tx:jar:3.2.4.RELEASE:compile
[INFO]    \- org.springframework.data:spring-data-jpa:jar:1.4.2.RELEASE:compile
[INFO]       +- org.springframework.data:spring-data-commons:jar:1.6.2.RELEASE:compile
[INFO]       \- org.aspectj:aspectjrt:jar:1.7.2:compile

我的春季服务在没有muleESB的测试环境中运行,没问题。

3 个答案:

答案 0 :(得分:2)

Mule发行版在$ {MULE_HOME} / lib / opt中包含Hibernate核心JAR。但由于某种原因,它不包含Hibernate实体管理器JAR。因此,如果在类路径中包含hibernate-entitymanager.jar-4.0.1.Final,它将尝试从$ {MULE_HOME} / lib / opt JAR中访问核心hibernate类,这些JAR已由不同的类加载器加载,从而提供了java .lang.IllegalAccessError。

解决方案是从$ {MULE_HOME} / lib / opt中删除Mule提供的Hibernate JAR并添加您自己的。在进行此类操作之前,请确保备份。

答案 1 :(得分:0)

压缩/ opt / mule中的hibernate-core-3.6.0.Final.jar有助于运行muleEsb。

答案 2 :(得分:0)

正如mmeyer所指出,这是一个类加载器问题。您可以在Mule 3.2中修复此问题.Mule提供了精细类加载选项。为了解决上述问题,我们可以在src / main / app / mule-deploy.properties中提供以下属性,并使用应用程序类加载器加载org.hibernate.engine.CascadeStyle和org.hibernate.engine.EJB3CascadeStyle:

FIX:将以下内容添加到src / main / app / mule-deploy.properties

loader.override = org.hibernate作为

注意:Mule Studio仍然继续这个问题,因此必须将hibernate实体管理器jar添加到\ MuleStudio \ plugins \ org.mule.tooling.server.3.4.1.ee_3.4.1.201312062152 \ mule \ opt < / p>

我使用mule CE独立观察:

场景1 :(部署失败)

My Mule App / lib - 有hibernate-entitymanager-3.6.0.Final。 - 我排除了所有其他的hibernate jar,包括hibernate-core-3.6.0.Final.jar

MuleCE3.4.0 / LIB /选择 - 有hibernate-core-3.6.0.Final.jar和其他hibernate jar

部署应用时出错: 引起:org.mule.api.config.ConfigurationException:在类路径资源[persistenceContext.xml]中定义名称为'entityManagerFactory'的bean创建错误:init方法的调用失败;嵌套异常是java.lang.IllegalAccessError:试图从类org.hibernate.engine.EJB3CascadeStyle $ 1(org.mule.api.lifecycle.InitialisationException)访问方法org.hibernate.engine.CascadeStyle。()V

场景2(部署成功)

My Mule App / lib - 有hibernate-entitymanager-3.6.0.Final。 - 我排除了所有其他的hibernate jar,包括hibernate-core-3.6.0.Final.jar

MuleCE3.4.0 / LIB /选择 - 有hibernate-core-3.6.0.Final.jar和其他hibernate jar - [与场景1不同]将hibernate-entitymanager-3.6.0.Final复制到MuleCE / lib / opt