복붙노트

[SPRING] 스프링 데이터 JPA + Websphere 8.5.5에서 최대 절전 모드

SPRING

스프링 데이터 JPA + Websphere 8.5.5에서 최대 절전 모드

Tomcat에서 WebSphere로 옮길 때 Spring 4 / Hibernate 프로젝트가 제대로로드되지 않는 문제가 발생했습니다. 나는 이미 APP를 PARENT_LAST 클래스 로더로 설정하고 Hibernate 버전을 4.2.16으로 되 돌렸다 (WAS 8.5.5는 JPA 2.0만을 지원하기 때문에). 이제 IDE 통합을 준수하기 위해 WAR을 EAR에 포함해야했습니다.

시작시 다음 오류가 표시됩니다. 어떤 도움을 주시면 감사하겠습니다. 누군가 WebSphere 8.5.5의 웹 애플리케이션 내부에서 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  

해결법

  1. ==============================

    1.WAS 8.5.5에서 Hibernate를 사용하려면 persistence.xml을 수정하고 공급자를 추가해야한다.

    WAS 8.5.5에서 Hibernate를 사용하려면 persistence.xml을 수정하고 공급자를 추가해야한다.

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

    CXF를 웹 서비스 엔진으로 사용하려면 class loader를 parent로 last 설정하고 annotation scanning을 비활성화해야합니다.

    자세한 내용은 설명서를 참조하십시오.

  2. from https://stackoverflow.com/questions/26762559/spring-data-jpa-hibernate-on-websphere-8-5-5 by cc-by-sa and MIT license