从Tomcat迁移到WebSphere时,我遇到了Spring 4 / Hibernate项目无法正确加载的问题。我已经将应用程序设置为PARENT_LAST类加载器,并将Hibernate版本恢复为4.2.16(由于WAS 8.5.5仅支持JPA 2.0)。我确实必须将WAR封装在EAR内,以符合IDE集成要求。
我现在在启动时遇到以下错误。任何援助将不胜感激。如果有人在WebSphere 8.5.5上的Web应用程序中运行过Spring + Hibernate(和CXF),我还想听听您是否还有其他问题。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [datasource.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: org.hibernate.engine.spi.CascadeStyle at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:750) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1686) at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:414) at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88) at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169) at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:749) at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634) at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:426) at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718) at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1177) at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370) at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639) at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968) at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:776) at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1379) at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2189) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:446) at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:389) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:117) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:664) at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5384) at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5600) at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:678) at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:622) at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1269) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:618) at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:87) at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:618) at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:291) at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1260) at java.security.AccessController.doPrivileged(AccessController.java:300) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1254) at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1092) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:831) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:813) at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228) at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:618) at com.ibm.ws.management.connector.soap.SOAPConnector.invoke(SOAPConnector.java:488) at com.ibm.ws.management.connector.soap.SOAPConnector.service(SOAPConnector.java:324) at com.ibm.ws.management.connector.soap.SOAPConnection.handleRequest(SOAPConnection.java:65) at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:733) at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:532) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1864) Caused by: java.lang.IncompatibleClassChangeError: org.hibernate.engine.spi.CascadeStyle at java.lang.ClassLoader.defineClassImpl(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:306) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154) at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:853) at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:763) at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:586) at java.lang.ClassLoader.loadClass(ClassLoader.java:707) at java.lang.J9VMInternals.verifyImpl(Native Method) at java.lang.J9VMInternals.verify(J9VMInternals.java:94) at java.lang.J9VMInternals.initialize(J9VMInternals.java:171) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:484) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:206) at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:51) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:182) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:177) at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:336) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ... 68 more
这是Maven依赖树
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test.mytestapp --- [INFO] com.mycompany.service:test.mytestapp:war:1.0.0.CI-SNAPSHOT [INFO] +- com.mycompany.base:base-transaction:pom:1.0.4.CI-SNAPSHOT:compile [INFO] | +- com.mycompany.base:base-spring:pom:1.0.4.CI-SNAPSHOT:compile [INFO] | | +- log4j:log4j:jar:1.2.16:compile [INFO] | | +- org.springframework:spring-context-support:jar:4.0.5.RELEASE:compile [INFO] | | +- org.springframework:spring-aop:jar:4.0.5.RELEASE:compile [INFO] | | | \- aopalliance:aopalliance:jar:1.0:compile [INFO] | | \- org.springframework:spring-orm:jar:4.0.5.RELEASE:compile [INFO] | | +- org.springframework:spring-jdbc:jar:4.0.5.RELEASE:compile [INFO] | | \- org.springframework:spring-tx:jar:4.0.5.RELEASE:compile [INFO] | +- com.mycompany.base:base-testing:pom:1.0.4.CI-SNAPSHOT:compile [INFO] | | +- junit:junit:jar:4.9:compile [INFO] | | | \- org.hamcrest:hamcrest-core:jar:1.1:compile [INFO] | | \- org.springframework:spring-test:jar:4.0.5.RELEASE:compile [INFO] | +- com.mycompany.base:base-data-access:pom:1.0.4.CI-SNAPSHOT:compile [INFO] | | +- org.hibernate:hibernate-entitymanager:jar:4.2.16.Final:compile [INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile [INFO] | | | +- dom4j:dom4j:jar:1.6.1:compile [INFO] | | | +- org.javassist:javassist:jar:3.18.1-GA:compile [INFO] | | | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:co [INFO] | | | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile [INFO] | | | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:compile [INFO] | | | \- org.hibernate:hibernate-core:jar:4.2.16.Final:compile [INFO] | | | \- antlr:antlr:jar:2.7.7:compile [INFO] | | \- org.springframework.data:spring-data-jpa:jar:1.5.2.RELEASE:compile [INFO] | | +- org.springframework.data:spring-data-commons:jar:1.7.2.RELEASE:compile [INFO] | | +- org.aspectj:aspectjrt:jar:1.7.4:compile [INFO] | | \- org.slf4j:jcl-over-slf4j:jar:1.7.6:runtime [INFO] | +- org.springframework:spring-aspects:jar:4.0.2.RELEASE:compile [INFO] | | \- org.aspectj:aspectjweaver:jar:1.7.4:compile [INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.6:compile [INFO] | | \- org.slf4j:slf4j-api:jar:1.7.6:compile [INFO] | \- com.mycompany.global:fed-spring-aop:jar:1.0.0.CI-SNAPSHOT:compile [INFO] | \- com.thoughtworks.xstream:xstream:jar:1.2.2:compile [INFO] | \- xpp3:xpp3_min:jar:1.1.3.4.O:compile [INFO] +- com.mycompany.base:base-web:pom:1.0.4.CI-SNAPSHOT:compile [INFO] | +- org.springframework:spring-webmvc:jar:4.0.2.RELEASE:compile [INFO] | | +- org.springframework:spring-beans:jar:4.0.2.RELEASE:compile [INFO] | | +- org.springframework:spring-context:jar:4.0.2.RELEASE:compile [INFO] | | +- org.springframework:spring-core:jar:4.0.2.RELEASE:compile [INFO] | | | \- commons-logging:commons-logging:jar:1.1.3:compile [INFO] | | +- org.springframework:spring-expression:jar:4.0.2.RELEASE:compile [INFO] | | \- org.springframework:spring-web:jar:4.0.2.RELEASE:compile [INFO] | +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.7.11:compile [INFO] | | +- xml-resolver:xml-resolver:jar:1.2:compile [INFO] | | +- asm:asm:jar:3.3.1:compile [INFO] | | +- org.apache.cxf:cxf-api:jar:2.7.11:compile [INFO] | | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.2.1:compile [INFO] | | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile [INFO] | | | +- org.apache.ws.xmlschema:xmlschema-core:jar:2.1.0:compile [INFO] | | | +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile [INFO] | | | \- wsdl4j:wsdl4j:jar:1.6.3:compile [INFO] | | +- org.apache.cxf:cxf-rt-core:jar:2.7.11:compile [INFO] | | | \- com.sun.xml.bind:jaxb-impl:jar:2.2.6:compile [INFO] | | +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.7.11:compile [INFO] | | | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.7.11:compile [INFO] | | +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.7.11:compile [INFO] | | +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.7.11:compile [INFO] | | \- org.apache.cxf:cxf-rt-ws-addr:jar:2.7.11:compile [INFO] | | \- org.apache.cxf:cxf-rt-ws-policy:jar:2.7.11:compile [INFO] | | \- org.apache.neethi:neethi:jar:3.0.3:compile [INFO] | \- org.apache.cxf:cxf-rt-transports-http:jar:2.7.11:compile [INFO] +- xerces:xercesImpl:jar:2.11.0:compile [INFO] | \- xml-apis:xml-apis:jar:1.4.01:compile [INFO] \- com.mycompany.transaction:toolslang.test:jar:1.0.0.CI-SNAPSHOT:compile [INFO] \- com.mycompany.base:base-db2:pom:1.0.4.CI-SNAPSHOT:compile [INFO] +- jdbc:db2:jar:driver:1.6.2:compile [INFO] \- jdbc:db2:jar:license:1.6.2:compile
要在WAS 8.5.5中使用Hibernate,您需要修改persistence.xml并添加提供程序
persistence.xml
<provider>org.hibernate.ejb.HibernatePersistence</provider>
要将CXF用作Web服务引擎,您需要将类加载器设置为最后一个父级并禁用注释扫描:
将WAR文件或EJB模块中的DisableIBMJAXWSEngine属性设置META-INF/MANIFEST.MF为true
DisableIBMJAXWSEngine
META-INF/MANIFEST.MF
true
请参阅文档以获取更多详细信息: