正如我的标题所说,我认为问题在于类加载,以及我的应用程序试图将 jersey-core 类转换为 resteasy 的事实。下面是触发它的代码,以及错误:
java.lang.LinkageError: ClassCastException: attempting to castjar:file:/C:/Program%20Files/NetBeans%207.3/enterprise/modules/ext/rest/jersey-core-1.13.jar!/javax/ws/rs/ext/RuntimeDelegate.classtojar:file:/C:/Documents%20and%20Settings/hwng/My%20Documents/NetBeansProjects/pics-client/branding/target/netbeans_clusters/pics_client/modules/ext/org.jboss.resteasy/jaxrs-api-2.3.5.Final.jar!/javax/ws/rs/ext/RuntimeDelegate.class
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:126)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:96)
代码:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
IRoutesService client = ProxyFactory.create(IRoutesService.class,
"http://localhost:8080/rest/routeservice/");
client.postRoute(txtRouteName.getText());
}
现在,我的 NetBeans 平台模块(maven)依赖于以下内容:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.5.Final</version>
</dependency>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>myapp-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
myapp-api 是一个 jar,它也位于服务器上,用于与服务交互。myapp-api 的 POM 具有以下依赖项:
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>${resteasy.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>${resteasy.version}</version>
</dependency>
</dependencies>
总而言之,当我似乎没有任何参考时,我不确定为什么 NetBeans 甚至远程尝试查看 jersey-core。任何帮助或建议表示赞赏。
我右键单击我的 RouteTopComponent 并查看运行时类路径,可以清楚地看到 jersey-core 在那里。我该如何摆脱它?