从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服务引擎,您需要将类加载器设置为最后一个父级并禁用注释扫描:
将WAR文件或EJB模块中的
DisableIBMJAXWSEngine
属性设置META-INF/MANIFEST.MF
为true
请参阅文档以获取更多详细信息:
我只想不使用xml,所以我需要非xml替代这些设置。这是我的POM。
我的项目中的三个模型对象(本文末尾的模型和存储库片段)之间确实存在关系。 当我调用时,它会触发三个select查询: (“sql”) (对我来说)那是相当不寻常的行为。在阅读Hibernate文档后,我认为它应该始终使用连接查询。当类中的更改为时,查询没有区别(使用附加选择进行查询),当更改为时,城市类的查询也一样(使用JOIN进行查询)。 当我使用抑制火灾时,有两种选择: 我的目标是在所有情况下
我目前正在开发一个具有核心模块和不同“扩展”模块的应用程序。核心模块包括基于Spring配置类的JPA配置以及一些“基本”实体及其存储库,这些实体和存储库将在“扩展”模块中使用。扩展模块包含额外的实体类和JPARepositories。启动扩展模块的JUnit测试时,我遇到以下错误: 为了做到这一点,我尝试了三种不同的方法: 创建了一个名为coreEntityManager和setPackages
我目前正在使用Wink 1.1.1和Spring 3.1.2迁移一个Java应用程序从WAS7到WAS8.5.5。我正在尝试使用Wink 8.5中可用的本地Wink集成,而不是使用我们目前在Wink 7中使用的单独Wink罐。 我得到了一个错误的服务器启动,看起来像这样: 原因:java。lang.ClassNotFoundException:org。阿帕奇。眨眼服务器内部的登记处。java上的R
SpringDataJpa中 Specification怎样使用in查询 实体类Menu.java如下 想通过roles属性做in查询,代码如下 错误如下: Parameter value [com.appmtce.pojo.entity.role.Role@20f81e2a] did not match expected type [java.util.Collection (n/a)] 我的S
我正在使用100个实体(使用JHipster)设置一个新的Spring Boot API,我的问题是:鉴于我有一组存储库层方法,我希望我的所有存储库都能够调用这些方法。 我已经尝试制作所有接口来扩展('RepositoryQuery'是我默认的自定义接口名称后缀),然后使用特定于实体的类。请注意,所有的类扩展了一个泛型实现类,名为。 请注意,给定正则表达式中的“.*”代表我的持久实体集中的任何实体
如何使用Spring Rest Controller和Spring Data JPA仅更新从@刚体传递的实体属性? 员工实体: 服务类方法: 请求体: Hibernate更新查询: Spring Data JPA正在尝试将company_id设置为空以进行更新,即使我没有将其传递给请求体?但是如果我从数据库中得到实体,使用employee_id传递,然后如果我试图保存(),那么它的工作正常。 我想
我想根据我的输入选择列(列表 我知道要选择不同的特定列,我可以使用@Query("SELECT DISTINCT name OF TABLE"),但是,我想给用户选择他们想要的列的灵活性。列表