我想遷移到事務API 1.2,而不是1.1 JTA當騾子/春天的ClassLoader問題。遷移到事務API 1.2
雖然我知道我可以調整騾子提供林達我無法理解爲什麼應用程序不能僅僅通過增加交易-API應用程序/ lib文件夾中工作。沒有交易api一切都按預期工作,但我得到:
Caused by: java.lang.ClassNotFoundException: javax.transaction.Transactional
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_66]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_66]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_66]
at org.springframework.transaction.annotation.JtaTransactionAnnotationParser.parseTransactionAnnotation(JtaTransactionAnnotationParser.java:42) ~[spring-tx-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource.determineTransactionAttribute(TransactionalRepositoryProxyPostProcessor.java:229) ~[?:?]
at org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource.findTransactionAttribute(TransactionalRepositoryProxyPostProcessor.java:208) ~[?:?]
at org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$AbstractFallbackTransactionAttributeSource.computeTransactionAttribute(TransactionalRepositoryProxyPostProcessor.java:397) ~[?:?]
at org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$AbstractFallbackTransactionAttributeSource.getTransactionAttribute(TransactionalRepositoryProxyPostProcessor.java:345) ~[?:?]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270) ~[spring-tx-4.2.4.RELEASE.jar:4.2.4.RELEASE]
這是一些相關的Spring代碼片斷。
spring-data-commons
(應用程序/ lib目錄):
if (jta12Present) {
this.annotationParsers.add(new JtaTransactionAnnotationParser());
}
其中:
private static final boolean jta12Present = ClassUtils.isPresent("javax.transaction.Transactional",
CustomAnnotationTransactionAttributeSource.class.getClassLoader());
- 好像當事務API被添加到應用程序傳遞此檢查。
JtaTransactionAnnotationParser
從騾提供的彈簧-TX(MULE_HOME \ lib中\ OPT)到來。這是它拋出一個異常:
public class JtaTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {
@Override
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(ae, javax.transaction.Transactional.class); - ClassNotFoundException
爲什麼春天識別在一個地方事務,但不能在其他?似乎有不同的範圍彈簧數據共用和彈簧TX可能是原因,但我不明白爲什麼,因爲騾子是應該提供一個複雜的層次的ClassLoader結構和跨越整個層次的搜索。