gpt4 book ai didi

java - Websphere 8.5.5 上的 Spring Data JPA + Hibernate

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:11:54 24 4
gpt4 key购买 nike

从 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 并添加提供者

<provider>org.hibernate.ejb.HibernatePersistence</provider>

要将 CXF 用作 Web 服务引擎,您需要将类加载器设置为最后一个父类并禁用注释扫描:

Set the DisableIBMJAXWSEngine property in the META-INF/MANIFEST.MF of a WAR file or EJB module to true

有关详细信息,请参阅文档:

关于java - Websphere 8.5.5 上的 Spring Data JPA + Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26762559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com