我有一个Spring Jersey应用程序和DAO层的Hibernate。因为MOXy的一些设施提供One Model Approach(阅读Blaise Doughan的答案JAXb, Hibernate and beans)。我使用MOXy而不是Jersey附带的JAXB。但是当我向pom.xml添加moxy依赖时,REST请求无法处理。 Weblogic抱怨道:
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:662)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
这是我的pom.xml的一部分
<!--Jersey-->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.9</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.9</version>
<exclusions>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
</exclusions>
</dependency>
我的依赖树
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.springframework:spring-core:jar:4.0.0.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-context:jar:4.0.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.0.0.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.0.0.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.0.0.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.0.0.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-orm:jar:4.0.0.RELEASE:compile
[INFO] | +- org.springframework:spring-jdbc:jar:4.0.0.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.0.0.RELEASE:compile
[INFO] +- com.sun.jersey.contribs:jersey-spring:jar:1.9:compile
[INFO] +- com.oracle:ojdbc6:jar:11.2.0.3:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | +- javax.transaction:jta:jar:1.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-moxy:jar:2.8:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:2.8:compile
[INFO] | | +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.8:compile
[INFO] | | +- org.glassfish.hk2:hk2-api:jar:2.2.0:compile
[INFO] | | | +- org.glassfish.hk2:hk2-utils:jar:2.2.0:compile
[INFO] | | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.2.0:compile
[INFO] | | +- org.glassfish.hk2.external:javax.inject:jar:2.2.0:compile
[INFO] | | +- org.glassfish.hk2:hk2-locator:jar:2.2.0:compile
[INFO] | | | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.8:compile
[INFO] | +- org.eclipse.persistence:org.eclipse.persistence.moxy:jar:2.5.0:compile
[INFO] | | \- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.0:compile
[INFO] | | \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.0:compile
[INFO] | \- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.0:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.9:compile
[INFO] | +- asm:asm:jar:3.1:compile
[INFO] | \- com.sun.jersey:jersey-core:jar:1.9:compile
[INFO] \- com.googlecode:hibernate-memcached:jar:1.2:compile
[INFO] \- spy:memcached:jar:2.3.1:compile
我怀疑MOXy 2.8与Jersey 1.9不兼容。 请给我一些建议..,谢谢!
答案 0 :(得分:1)
您可以混合使用Jersey 1.x组件和Jersey 2.x组件。你不能混合两者。
您已宣布依赖:
但你也宣布依赖:
正在拉动:
如果你想使用jersey-media-moxy,你需要升级到Jersey 2.x。