簡體   English   中英

獨立Spring應用程序(jar)與weblogic 10上的其他Web應用程序沖突

[英]Standalone Spring app ( jar) conflicting with other web apps on weblogic 10

我有一個獨立的spring應用程序,主要包含aspecj方面和很少的其他Spring托管bean,並捆綁在一個帶有maven-assembly插件的jar中,所有spring依賴項都捆綁在jar中並添加到weblogic類路徑中。

目標是使用aspectJ代理在運行時將庫中的各個方面編織到weblogic中的所有正在運行的應用程序中。

問題是,當我在類路徑中添加我的jar文件並重新啟動服務器時,在部署現有Web應用程序時會出現ClassNotFoundException。

我知道它不是一個不在lib文件夾中的jar文件,因為app在apppath中沒有我的jar文件就可以正常部署。

注意:當我將spring jar文件放在domain / lib文件夾中時,我也得到classNotFoundException。

你能不清楚為什么運行的應用程序會受到我的基於Spring的庫的影響?

請參閱下面的stacktrace:我非常確定javax.validation.ValidatorFactory位於WEB-INF \\ lib文件夾內的validation-api中。 因為當我將自定義jar文件添加到weblogic類路徑時,我才會收到此異常。

Caused By: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] for bean with name 'jsr303Validator' defined in ServletContext resource [/WEB-INF/config/webmvc-config.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1272)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:578)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1338)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:356)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:335)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:895)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
at org.s

Caused By: java.lang.ClassNotFoundException: javax.validation.ValidatorFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java

這是我的WAR文件的依賴樹。

       [INFO] [dependency:tree {execution: default-cli}]
    [INFO] com.company.project:eCom4jWeb:war:1.0.0-SNAPSHOT
    [INFO] +- com.company.project:eCom4jCore:jar:1.0.0-SNAPSHOT:compile
    [INFO] |  +- org.springframework:spring-jdbc:jar:3.1.2.RELEASE:compile
    [INFO] |  +- org.hsqldb:com.springsource.org.hsqldb:jar:1.8.0.9:runtime
    [INFO] |  +- mysql:mysql-connector-java:jar:5.1.9:compile
    [INFO] |  +- org.hibernate:com.springsource.org.hibernate:jar:3.3.2.GA:compile
    [INFO] |  |  +- net.sourceforge.cglib:com.springsource.net.sf.cglib:jar:2.2.0:compile
[INFO] |  |  +- org.antlr:com.springsource.antlr:jar:2.7.6:compile
[INFO] |  |  +- org.apache.commons:com.springsource.org.apache.commons.collections:jar:3.2.1:compile
[INFO] |  |  +- org.dom4j:com.springsource.org.dom4j:jar:1.6.1:compile
[INFO] |  |  +- org.jboss.javassist:com.springsource.javassist:jar:3.9.0.GA:compile
[INFO] |  |  \- org.objectweb.asm:com.springsource.org.objectweb.asm:jar:1.5.3:compile
[INFO] |  +- org.hibernate:com.springsource.org.hibernate.annotations:jar:3.4.0.GA:compile
[INFO] |  |  \- org.hibernate:com.springsource.org.hibernate.annotations.common:jar:3.3.0.ga:compile
[INFO] |  +- org.hibernate:hibernate-validator:jar:4.2.0.Final:compile
[INFO] |  |  +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] |  +- javax.transaction:com.springsource.javax.transaction:jar:1.1.0:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] |  +- net.sf.dozer:dozer:jar:5.3.1:compile
[INFO] |  \- org.apache.xmlbeans:xmlbeans:jar:2.4.0:runtime
[INFO] |     \- stax:stax-api:jar:1.0.1:runtime
[INFO] +- com.company.project:eCom4jWS:jar:1.0.0-SNAPSHOT:compile
[INFO] |  +- com.company.project:eCom4jRemixDomain:jar:1.0.0-SNAPSHOT:compile
[INFO] |  |  \- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.6.2:compile
[INFO] |  \- org.springframework:spring-oxm:jar:3.1.2.RELEASE:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.1.2.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-acl:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.1.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-asm:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-context-support:jar:3.1.2.RELEASE:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.springframework:spring-beans:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework.webflow:spring-binding:jar:2.2.1.RELEASE:compile
[INFO] +- org.springframework.webflow:spring-js:jar:2.2.1.RELEASE:compile
[INFO] |  \- org.springframework.webflow:spring-js-resources:jar:2.2.1.RELEASE:compile
[INFO] +- org.springframework.webflow:spring-webflow:jar:2.2.1.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-core:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.1.2.RELEASE:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-core:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.1.2.RELEASE:compile
[INFO] +- javax.el:el-api:jar:1.0:provided
[INFO] +- org.jboss.el:com.springsource.org.jboss.el:jar:2.0.0.GA:compile
[INFO] +- org.apache.tiles:tiles-core:jar:2.1.4:compile
[INFO] |  +- commons-digester:commons-digester:jar:1.8.1:compile
[INFO] |  \- commons-logging:commons-logging-api:jar:1.1:compile
[INFO] +- org.apache.tiles:tiles-jsp:jar:2.1.4:compile
[INFO] +- org.apache.tiles:tiles-api:jar:2.1.4:compile
[INFO] +- org.apache.tiles:tiles-servlet:jar:2.1.4:compile
[INFO] +- org.springframework:spring-test:jar:3.1.2.RELEASE:test
[INFO] +- org.springframework:spring-expression:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT:test
[INFO] +- org.powermock:powermock-module-junit4:jar:1.4.12:test
[INFO] |  \- org.powermock:powermock-module-junit4-common:jar:1.4.12:test
[INFO] |     +- org.powermock:powermock-core:jar:1.4.12:test
[INFO] |     |  \- org.javassist:javassist:jar:3.16.1-GA:test
[INFO] |     \- org.powermock:powermock-reflect:jar:1.4.12:test
[INFO] +- org.powermock:powermock-api-easymock:jar:1.4.12:test
[INFO] |  \- org.powermock:powermock-api-support:jar:1.4.12:test
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.5.3:compile
[INFO] |  \- org.codehaus.jackson:jackson-core-asl:jar:1.5.3:compile
[INFO] +- com.jayway.jsonpath:json-path:jar:0.8.1:test
[INFO] |  \- net.minidev:json-smart:jar:1.1.1:test
[INFO] +- org.aspectj:com.springsource.org.aspectj.weaver:jar:1.6.8.RELEASE:compile
[INFO] +- org.slf4j:com.springsource.slf4j.api:jar:1.5.6:compile
[INFO] +- org.slf4j:com.springsource.slf4j.org.apache.commons.logging:jar:1.5.6:runtime
[INFO] +- org.slf4j:com.springsource.slf4j.log4j:jar:1.5.6:runtime
[INFO] +- org.apache.log4j:com.springsource.org.apache.log4j:jar:1.2.15:compile
[INFO] +- org.apache.commons:com.springsource.org.apache.commons.dbcp:jar:1.2.2.osgi:runtime
[INFO] +- org.apache.commons:com.springsource.org.apache.commons.pool:jar:1.5.3:runtime
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:compile
[INFO] +- junit:junit:jar:4.8.1:test (scope not updated to compile)
[INFO] +- org.easymock:easymock:jar:3.1:test
[INFO] |  +- cglib:cglib-nodep:jar:2.2.2:test
[INFO] |  \- org.objenesis:objenesis:jar:1.2:test
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- org.apache.struts:struts2-core:jar:2.2.1:compile
[INFO] |  +- org.apache.struts.xwork:xwork-core:jar:2.2.1:compile
[INFO] |  +- org.freemarker:freemarker:jar:2.3.16:compile
[INFO] |  +- ognl:ognl:jar:3.0:compile
[INFO] |  +- commons-fileupload:commons-fileupload:jar:1.2.1:compile
[INFO] |  +- commons-io:commons-io:jar:1.3.2:compile
[INFO] |  \- com.sun:tools:jar:1.5.0:system
[INFO] +- org.apache.struts:struts2-tiles-plugin:jar:2.2.1:compile
[INFO] +- org.apache.struts:struts2-spring-plugin:jar:2.2.1:compile
[INFO] +- javax.mail:mail:jar:1.4:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] \- net.tanesha.recaptcha4j:recaptcha4j:jar:0.0.7:compile
[INFO] -------

謝謝

如果您使用maven來構建jar,請嘗試構建嵌入了依賴項的jar文件並對其進行測試,以下鏈接可以幫助您:

如何使用Maven創建具有依賴關系的可執行JAR?

依賴關系樹顯示:

  • commons-logging兩個版本:1.1和1.1.1
  • slf4j兩個版本:1.5.6和1.6.1
  • javax.transactioncompiled范圍而不是provided
  • 來自不同來源的各種版本的Hibernate工件org.hibernate:com.springsource.org.hibernate:jar:3.3.2.GA:compile org.hibernate:com.springsource.org.hibernate.annotations:jar:3.4.0.GA:compile org.hibernate:hibernate-validator:jar:4.2.0.Final:compile

由於ClassLoader在沒有任何確定或預定義順序的情況下加載資源,因此添加jar文件可能已更改此順序,現在可以看到類沖突 - 在EAR / WAR本身內部或應用程序服務器與應用程序之間。

這不是明顯與提供的信息指向的沖突源,但它可能是org.hibernate:hibernate-validator ,你應該調整其具有核心包版本,所以3.3.2.GAcom.springsource了。

要清除診斷,請使用-verbose:class選項運行WebLogic JVM並查看stderr輸出。 失敗之前的最新加載資源和先前加載的相關類的日志是消除由打包產生的這種沖突的最佳線索。

如果沖突來自應用程序服務器程序包而您無法與同一版本對齊,則WebLogic允許您按程序包設置類加載篩選以強制加載您自己的版本。 請參閱類加載文檔中的使用過濾類加載器一節。

聽起來像是一個Jar Hell ...如果你有同一個jar的不同版本,你的容器只加載第一個......現在,想象一下它是否加載jar 1的版本5,以及依賴jar 2的版本2(但正確的是版本5)...並且可以在你的系統中發生大的崩潰...為了防止它,一些容器只是不加載任何版本,並給出一些消息,如ClassNotFoundException。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM