所以我想让一个 JAX-RS 应用程序在我的 WebSphere 8.5 实例上运行。我创建了以下界面...
@Path("service")
public class RestService {
@GET
@Produces("text/plain")
public int getCount(){
return 1;
}
}
这是我的应用程序...
public class RESTConfig extends Application{
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new Hashset<?>();
classes.add(RestService.class);
return classes;
}
}
然后这是我的 web.xml ......
<servlet>
<servlet-name>Rest Servlet</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>jaxrs.ws.rs.Application</param-name>
<param-value>com.company.rest.RESTConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
....
<servlet-mapping>
<servlet-name>Rest Servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
然后我有一个配置了 WAR 作为模块的 EAR。但是当我开始一切并尝试去 http://localhost:[port]/war/rest/app/service 我看到..
[TIME] 00000115 RequestProces I org.apache.wink.server.internal.RequestProcessor logException 在调用处理程序链期间发生以下错误:WebApplicationException (404 - Not Found) with message 'null' while processing GET request sent to http: //localhost:[端口]/war/rest/service
请帮忙!