【发布时间】:2015-06-09 18:40:44
【问题描述】:
-
我已经使用了 jaxrs 的球衣实现,但我无法执行以下程序,如果我遇到问题,任何想法都可以帮助我
在下面的程序中,我使用了 jersy 2.x 的 jaxrs 实现 我使用 jax-rs(restfull) 的 jersey 实现来实现该程序 我写了 2 个类而不是 web.xml 我使用了这个类
MyResource.java
package com.rest.application; import java.util.HashSet; import java.util.Set; import javax.ws.rs.ApplicationPath; import com.rest.webservice.SampleService; @ApplicationPath("rest") public class MyResource { private Set s; public MyResource() { s=new HashSet(); s.add(new SampleService()); } public Set getSingletons() { return s; } }SampleService.java
import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @Path("sample") public class SampleService { @GET @Produces("text/html") @Path("{username}") public String sayHello(@PathParam("username")String s) { return "<font color='blue' size=8>Hello:" +s+ "</font>"; } @GET @Produces("text/plain") public String sayBye() { return "Bye"; } }我添加了该程序所需的所有罐子 我仍然收到以下错误
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]. StandardHost[localhost].StandardContext[/RestApp2]] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]. StandardHost[localhost].StandardContext[/RestApp2]]就像到处都显示同样的错误
当我将服务器 tomcat 7 更改为 6 时 它正在工作但不显示输出 有没有人知道提前谢谢你
【问题讨论】:
-
请清理您的代码...无法读取
标签: java rest tomcat jersey jersey-2.0