1

我在 Mule 中使用 Service include 测试 POC,例如 bean spring,我遇到了 Hibernate 和 Jpa 依赖项的问题。现在每个人都在 Mule 3.4 CE 中支持/使用哪个版本的 Hibernate 和 JPA。

当我不想运行流程时,我有很多例外:使用休眠 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

我的 spring 服务在没有 muleESB 的测试上下文中运行,没问题。

4

3 回答 3

2

Mule distribution contains Hibernate core JARs at ${MULE_HOME}/lib/opt. But for some reason it doesn't contain Hibernate entity manager JAR. So, if you include hibernate-entitymanager.jar-4.0.1.Final in your classpath, it will try to access core hibernate classes from ${MULE_HOME}/lib/opt JARs which has been loaded by a different classloader and thus gives java.lang.IllegalAccessError.

Solution is to delete Mule provided Hibernate JARs from ${MULE_HOME}/lib/opt and add your own. Please ensure that you have a backup before you carry out such operation.

于 2014-01-06T10:54:28.840 回答
0

在 /opt/mule 中抑制 hibernate-core-3.6.0.Final.jar 有助于运行 muleEsb。

于 2013-11-14T09:32:05.813 回答
0

As pointed out by mmeyer this is a Class Loader issue. You can fix this in Mule 3.2 Mule provides a Fine Grained Class Loading option. To fix the above we can provide the following property in src/main/app/mule-deploy.properties and it loads both org.hibernate.engine.CascadeStyle and org.hibernate.engine.EJB3CascadeStyle using the application class loader:

FIX: Add the following to src/main/app/mule-deploy.properties

loader.override=org.hibernate

Note: Mule Studio still continues with this issue and hence one has to add hibernate entity manager jar to \MuleStudio\plugins\org.mule.tooling.server.3.4.1.ee_3.4.1.201312062152\mule\opt

My observation using mule CE standalone:

Scenario 1: (Deployment Fails)

My Mule App /lib - has hibernate-entitymanager-3.6.0.Final . - I excluded all other hibernate jars including hibernate-core-3.6.0.Final.jar

MuleCE3.4.0/lib/opt - has hibernate-core-3.6.0.Final.jar and other hibernate jars

Error when app is deployed: Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [persistenceContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalAccessError: tried to access method org.hibernate.engine.CascadeStyle.()V from class org.hibernate.engine.EJB3CascadeStyle$1 (org.mule.api.lifecycle.InitialisationException)

Scenario 2 (Deployment Successful)

My Mule App /lib - has hibernate-entitymanager-3.6.0.Final . - I excluded all other hibernate jars including hibernate-core-3.6.0.Final.jar

MuleCE3.4.0/lib/opt - has hibernate-core-3.6.0.Final.jar and other hibernate jars - [Different from Scenario 1] Copy hibernate-entitymanager-3.6.0.Final to MuleCE/lib/opt

于 2014-01-30T20:55:59.007 回答