我正在尝试在Websphere 8.5.5.13上运行Spring Boot 1.5.9应用程序(类加载是父进程,我没有共享库) 当试图调用内置方法的JpaRepository时(我注意到SQL查询正在执行)但是我得到以下异常:
org.springframework.transaction.TransactionSystemException:
UOWManager transaction processing failed; nested exception is com.ibm.wsspi.uow.UOWException:
java.lang.LinkageError: com/ibm/websphere/uow/UOWSynchronizationRegistry.registerInterposedSynchronization
(Ljavax/transaction/Synchronization;)V (loaded from file:/D:/IBM/WebSphere/AppServer/plugins/com.ibm.ws.runtime.jar
by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@873a9f67)
called from class org.springframework.transaction.jta.WebSphereUowTransactionManager$UOWActionAdapter
(loaded from file:/D:/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/D1SHLAPXXPWV1Node01Cell
/Spring.ear/SpringJSF.war/WEB-INF/lib/spring-tx-4.3.13.RELEASE.jar by
com.ibm.ws.classloader.CompoundClassLoader@7c146942[war:Spring/SpringJSF.war]
我的pom文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>SpringJSF</artifactId>
<version>1</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.15.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.2.15.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.2.2.jre8</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.9</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>3.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-prettyfaces</artifactId>
<version>3.4.1.Final</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
</dependencies>
<build>
<finalName>SpringJSF</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<argLine>-Dfile.encoding=UTF8</argLine>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>org.jboss.repository.releases</id>
<name>JBoss Maven Release Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
我的存储库界面:
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
@Query("from Employee u where u.userName = :userName")
Employee findByUserName(@Param("userName") String username);
}
Maven依赖树:
[INFO] org.springframework:SpringJSF:war:1
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.5.9.RELEAS
E:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:comp
ile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.REL
EASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.9.R
ELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.1.11:compile
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | | \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] | \- org.springframework.boot:spring-boot-actuator:jar:1.5.9.RELEASE:com
pile
[INFO] +- org.springframework.boot:spring-boot-starter-cache:jar:1.5.9.RELEASE:c
ompile
[INFO] | +- org.springframework:spring-context:jar:4.3.13.RELEASE:compile
[INFO] | | +- org.springframework:spring-beans:jar:4.3.13.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:4.3.13.RELEASE:compile
[INFO] | \- org.springframework:spring-context-support:jar:4.3.13.RELEASE:compi
le
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:1.5.9.RELEASE:co
mpile
[INFO] | \- com.sun.mail:javax.mail:jar:1.5.6:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.9.RELEA
SE:compile
[INFO] | +- org.thymeleaf:thymeleaf-spring4:jar:2.1.6.RELEASE:compile
[INFO] | | +- org.thymeleaf:thymeleaf:jar:2.1.6.RELEASE:compile
[INFO] | | | +- ognl:ognl:jar:3.0.8:compile
[INFO] | | | \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
[INFO] | \- org.codehaus.groovy:groovy:jar:2.4.13:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.9.RELEASE:te
st
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.9.R
ELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.3:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1
:test
[INFO] | +- org.springframework:spring-core:jar:4.3.13.RELEASE:compile
[INFO] | \- org.springframework:spring-test:jar:4.3.13.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:com
pile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.3.6.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
[INFO] | +- org.springframework:spring-web:jar:4.3.13.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.3.13.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.9.RELEAS
E:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.9.RELEASE:
compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.9.RELEASE
:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.23:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.23:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.13.RELEASE:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.9.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.13.9.RELEASE:
compile
[INFO] | | +- org.springframework:spring-orm:jar:4.3.13.RELEASE:compile
[INFO] | | +- org.springframework:spring-tx:jar:4.3.13.RELEASE:compile
[INFO] | | \- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.13.RELEASE:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.2.15.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar
:1.0.1.Final:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:
compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.2.15.Final:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:
compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.5.9.RELEAS
E:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.13.RELEASE:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:4.2.3.RELEA
SE:compile
[INFO] | | \- org.springframework.security:spring-security-core:jar:4.2.3.RELE
ASE:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:4.2.3.RELEASE:
compile
[INFO] +- javax:javaee-api:jar:6.0:provided
[INFO] +- javax.el:javax.el-api:jar:3.0.0:provided
[INFO] +- com.microsoft.sqlserver:mssql-jdbc:jar:6.2.2.jre8:compile
[INFO] +- org.glassfish:javax.faces:jar:2.2.9:compile
[INFO] +- javax.enterprise:cdi-api:jar:1.2:compile
[INFO] | +- javax.interceptor:javax.interceptor-api:jar:1.2:compile
[INFO] | \- javax.inject:javax.inject:jar:1:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.primefaces:primefaces:jar:6.1:compile
[INFO] +- org.ocpsoft.rewrite:rewrite-servlet:jar:3.4.1.Final:compile
[INFO] +- org.ocpsoft.rewrite:rewrite-config-prettyfaces:jar:3.4.1.Final:compile
[INFO] | \- org.ocpsoft.rewrite:rewrite-integration-faces:jar:3.4.1.Final:compi
le
[INFO] +- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.5:compile
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- commons-validator:commons-validator:jar:1.6:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | +- commons-digester:commons-digester:jar:2.1:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.3.3:compile
[INFO] +- commons-io:commons-io:jar:2.5:compile
[INFO] \- joda-time:joda-time:jar:2.9.9:compile
注意:任何使用 @Query正常工作的dao方法都可以正常工作没有问题,我当前的问题是使用像findAll这样的方法构建的JpaRepository,它不起作用,产生上述异常。
UPDATE 1 :我尝试将类加载标记为父级,并将所有jar从我的应用程序lib文件夹中移出并将它们放在一个独立的共享库中,但此解决方案使应用程序启动没有springboot被初始化,也没有hibernate和jsf,所以它不起作用。
答案 0 :(得分:2)
maven depdencency树显示您有2个事务API作为依赖项:
javax.transaction-api
jboss-transaction-api_1.1_spec
并且都有范围编译。
当您查看战争的lib文件夹时,您应该找到
您必须确保两者都不在lib文件夹中,因为com.ibm.websphere.uow.UOWSynchronizationRegistry
是从另一个类加载器加载的,而且这个类加载器还包含一个版本的事务api。
尝试使用dependencyManagement
将依赖范围设置为provided
。 E.g。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.1_spec</artifactId>
<version>1.0.1.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
答案 1 :(得分:0)
问题很可能是由应用程序加载器中打包的JTA API副本引起的。这将导致Spring事务类和WAS事务类链接到JTA类的单独副本,并且Spring类(直接来自应用程序加载器,间接通过WAS类)的重复可见性在运行时导致LinkageError。 / p>
可以通过从应用程序中删除JTA API来解决此特定问题。您可能还想重新考虑PARENT_LAST的使用,除非您确定您的应用程序需要它 - 虽然它有其用途,但它也极大地增加了LinkageErrors和ClassCastExceptions的可能性,以及其他方面,如果应用程序&# 39;内容不是很严格控制。更安全的替代方案可能是具有隔离类加载器的共享库,仅包含您需要使用自己的实现而不是简单地使用服务器中包含的版本的特定库。