我在 JDK 1.6 http 服务器上创建了一个基于 jersey 1.12 的 restful 服务外观。当我在 Eclipse 中启动我的应用程序时,一切正常。我可以毫无问题地与外观通信,但是当我通过控制台使用启动脚本启动我的应用程序时,我在访问服务时遇到了 IncompatibleClassChangeError。
我能够缩小问题的范围。问题在于发送响应。因为我可以正常与服务通信(请求已处理)但我没有得到响应。你对此有任何线索吗?
启动脚本
#!/usr/bin/env bash
libpath=
for i in $(ls lib/*|grep ".jar"); do
libpath=$( echo "$i:$libpath");
done
java -cp "$(echo $libpath)build/jar/myjar.jar" org.....Startup
将抛出的异常
WARNUNG: Class org....facade.ServiceFacadeImpl is ignored as an instance is registered in the set of singletons
Call getMutationList: NP_005378
Exception in thread "pool-1-thread-1" java.lang.IncompatibleClassChangeError: Class javax.ws.rs.core.Response$Status does not implement the requested interface javax.ws.rs.core.Response$StatusType
我门面的一部分
@GET
@Path("/mutations/{id}/{from}/{size}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public MutationPosContainer getMutationList(@PathParam("id") String id,
@PathParam("from") Integer from, @PathParam("size") Integer size) {
...
if (posContainer == null)
throw new BadRequestException();
else
return posContainer;
}
应用程序处理程序
public class SnapDbApplication extends Application {
private ServiceFacade facade;
public SnapDbApplication(ServiceFacade facade) {
this.facade = facade;
}
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> s = new HashSet<Class<?>>();
s.add(this.facade.getClass());
return s;
}
@Override
public Set<Object> getSingletons() {
Set<Object> s = new HashSet<Object>();
s.add(this.facade);
return s;
}
}
编辑:类路径
java -cp
lib/xstream-1.4.2.jar:lib/xmlbeans-2.3.0.jar:lib/xml-resolver-1.2.jar:lib/xalan-2.7.0.jar:
lib/wstx-asl-3.2.9.jar:lib/wsdl4j-1.6.2.jar:lib/woden-impl-dom-1.0M9.jar:lib/woden-impl-commons-1.0M9.jar:
lib/woden-api-1.0M9.jar:lib/tribes-6.0.16.jar:lib/snpxsd.jar:
lib/regexp-1.2.jar:lib/org.springframework.web.struts-sources-3.1.1.RELEASE.jar:
lib/org.springframework.web.struts-3.1.1.RELEASE.jar:
lib/org.springframework.web.servlet-sources-3.1.1.RELEASE.jar:
lib/org.springframework.web.servlet-3.1.1.RELEASE.jar:
...
:lib/jersey-server-1.12.jar:lib/jersey-multipart-1.12.jar:lib/jersey-json-1.12.jar:
lib/jersey-core-1.12.jar:lib/jersey-client-1.12.jar:lib/jaxws-tools-2.1.3.jar:lib/jaxen-1.1.1.jar:lib/jaxb-xjc-2.1.7.jar:
lib/jaxb-impl-2.1.7.jar:lib/jaxb-api-2.1.jar:
lib/jalopy-1.5rc3.jar:lib/httpcore-4.0.jar:
lib/http-20070405.jar:lib/hamcrest-library-1:build/jar/myapp.jar
org.startup.Startup