我无法在同一个Java Web应用程序中使用restlet服务器和客户端jar。问题是一些服务器和客户端的jar具有相同的名称。如果我尝试删除重复的jar,我会收到类似
的错误java.lang.NoSuchMethodError: org.restlet.Context.getClientDispatcher()Lorg/restlet/Restlet;
org.restlet.resource.ClientResource.createNext(ClientResource.java:503)
org.restlet.resource.ClientResource.getNext(ClientResource.java:829)
org.restlet.resource.ClientResource.handleOutbound(ClientResource.java:1221)
org.restlet.resource.ClientResource.handle(ClientResource.java:1068)
org.restlet.resource.ClientResource.handle(ClientResource.java:1044)
org.restlet.resource.ClientResource.post(ClientResource.java:1453)
com.xxxxxx.web.restletclient.services.CommonService.sendRequest(CommonService.java:25)
com.xxxxxx.web.restletclient.services.adminService.execute(adminService.java:24)
com.xxxxxx.web.restletclient.client.adminLoginClient.connect(AdminLoginClient.java:41)
com.xxxxxx.web.action.operator.adminLoginAction.performAction(adminLoginAction.java:75)
com.xxxxxx.common.action.AbstractBaseAction.execute(AbstractBaseAction.java:137)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
我的方案是,我的Web应用程序可以作为Web服务客户端和服务器。所以我正在寻找一个选项,我可以在同一个Web应用程序中使用restlet客户端和服务器jar。我已经搜索了网络,但没有找到任何可行的解决方案。
感谢您的帮助。
答案 0 :(得分:0)
事实上,Restlet的核心jar支持客户端和服务器端。也就是说,扩展名(名称为org.restlet.extension.XXX
的jar文件)可以指定给一方或另一方或两者。这取决于扩展名。
你能告诉我我们试图使用的罐子清单吗?
以下是一个示例pom文件,可用于初始化Restlet项目的依赖项:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.restlet</groupId>
<artifactId>restlet-war</artifactId>
<name>${project.artifactId}</name>
<packaging>war</packaging>
<version>1.0.0-snapshot</version>
<properties>
<java-version>1.7</java-version>
<restlet-version>2.3.1</restlet-version>
<wtp-version>2.0</wtp-version>
</properties>
<dependencies>
<!-- Restlet core -->
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
<version>${restlet-version}</version>
</dependency>
<!-- To embed Restlet within a servlet container -->
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet.ext.servlet</artifactId>
<version>${restlet-version}</version>
</dependency>
<!-- To use HTTP Client to actual make HTTP
requests under the hood -->
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet.ext.httpclient</artifactId>
<version>${restlet-version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>http://maven.restlet.com</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>${wtp-version}</wtpversion>
</configuration>
</plugin>
</plugins>
</build>
</project>
希望它可以帮到你, 亨利