我想在我的Junit測試中模擬http請求。所以我用Jadler Project。當我運行我的測試,並把我的http請求,我有這樣的例外:Java Jadler:碼頭衝突
java.lang.SecurityException: class "javax.servlet.AsyncContext"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:806)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625)
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.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.eclipse.jetty.server.AbstractHttpConnection.<init>(AbstractHttpConnection.java:162)
at org.eclipse.jetty.server.AsyncHttpConnection.<init>(AsyncHttpConnection.java:50)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:285)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newConnection(SelectChannelConnector.java:325)
at org.eclipse.jetty.server.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:272)
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newEndPoint(SelectChannelConnector.java:331)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.createEndPoint(SelectorManager.java:842)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:496)
at org.eclipse.jetty.io.nio.SelectorManager$1.run(SelectorManager.java:290)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:662)
在開始的時候我的依賴性看起來,對於JAdler:
<dependency>
<groupId>net.jadler</groupId>
<artifactId>jadler-core</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jadler</groupId>
<artifactId>jadler-jetty</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jadler</groupId>
<artifactId>jadler-junit</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
serveral的搜索後,我明白了爲什麼我有這個例外。爲了解決這個問題,我不得不改變我的依賴這樣的:
<dependency>
<groupId>net.jadler</groupId>
<artifactId>jadler-core</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jadler</groupId>
<artifactId>jadler-jetty</artifactId>
<version>1.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>8.1.18.v20150929</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jadler</groupId>
<artifactId>jadler-junit</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
我明白,碼頭不使用org.eclipse.jetty.orbit的javax.servlet.AsyncContext:的javax.servlet但它使用的javax。 servlet:javax.servlet-api v3.0.1。
有人知道爲什麼嗎?解決方案更好
我的JDK版本是1.6.45。
如果您需要更多信息,例如我的測試資源告訴我。
編輯1:MVN依賴性:樹
+- commons-beanutils:commons-beanutils:jar:1.6:compile
+- commons-collections:commons-collections:jar:3.2.1:compile
+- commons-digester:commons-digester:jar:1.5:compile
| \- xml-apis:xml-apis:jar:1.0.b2:compile
+- commons-fileupload:commons-fileupload:jar:1.0:compile
+- commons-lang:commons-lang:jar:2.6:compile
+- commons-logging:commons-logging:jar:1.1.1:compile
+- ant:ant-jakarta-oro:jar:1.6:compile
+- log4j:log4j:jar:1.2.17:compile
+- struts:struts:jar:1.2.9:compile
| +- commons-validator:commons-validator:jar:1.1.4:compile
| +- oro:oro:jar:2.0.7:compile
| \- xalan:xalan:jar:2.5.1:compile
+- oracle:orai18n:jar:14:compile
+- oracle:ojdbc6:jar:11.1.0.7.0:provided
+- oracle:xdb:jar:11.1.1.2.0:compile
+- javax.servlet:servlet-api:jar:2.4:provided
+- javax.servlet:jsp-api:jar:2.0:provided
+- org.slf4j:slf4j-api:jar:1.7.5:compile
+- org.slf4j:slf4j-log4j12:jar:1.7.12:test (scope not updated to compile)
+- antlr:antlr:jar:2.7.6:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.6.0:compile
| +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0:compile
| \- com.fasterxml.jackson.core:jackson-core:jar:2.6.0:compile
+- net.sf.ehcache:ehcache:jar:2.10.0:compile
+- org.springframework:spring-context:jar:3.2.14.RELEASE:compile
| +- org.springframework:spring-aop:jar:3.2.14.RELEASE:compile
| +- org.springframework:spring-beans:jar:3.2.14.RELEASE:compile
| +- org.springframework:spring-core:jar:3.2.14.RELEASE:compile
| \- org.springframework:spring-expression:jar:3.2.14.RELEASE:compile
+- org.springframework:spring-context-support:jar:3.2.14.RELEASE:compile
+- junit:junit:jar:4.12:test
| \- org.hamcrest:hamcrest-core:jar:1.3:test
+- org.springframework:spring-test:jar:3.0.6.RELEASE:test
+- net.jadler:jadler-core:jar:1.1.2:test
| +- org.hamcrest:hamcrest-library:jar:1.3:test
| \- commons-io:commons-io:jar:2.4:test
+- net.jadler:jadler-jetty:jar:1.1.2:test
+- org.eclipse.jetty:jetty-server:jar:8.1.18.v20150929:test
| +- org.eclipse.jetty:jetty-continuation:jar:8.1.18.v20150929:test
| \- org.eclipse.jetty:jetty-http:jar:8.1.18.v20150929:test
| \- org.eclipse.jetty:jetty-io:jar:8.1.18.v20150929:test
| \- org.eclipse.jetty:jetty-util:jar:8.1.18.v20150929:test
+- javax.servlet:javax.servlet-api:jar:3.0.1:test
\- net.jadler:jadler-junit:jar:1.1.2:test
首先,也是最重要的:[Java 1.6在2013年是EOL(End of Life)](http://www.oracle.com/technetwork/java/eol-135779.html)和[碼頭8在2014年是EOL](https://dev.eclipse.org/mhonarc/lists/jetty-announce/msg00069.html)。其次,你可以爲你的項目做一個'mvn dependency:tree'並將它包含在你的問題中嗎? –
是的,但我沒有選擇Java 1.6和JAdler使用Jetty 8 max。我在我的問題中添加了我的依賴關係樹。 –
在問題中看不到'dependency:tree'。 –