在哪里验证REST Web服务的加载路径
我刚刚完成Web服务的编码。我需要能够调试webservice加载路径。当I在哪里验证REST Web服务的加载路径,rest,jakarta-ee,junit,Rest,Jakarta Ee,Junit,我刚刚完成Web服务的编码。我需要能够调试webservice加载路径。当Isudo重新启动服务tomcat7时,/var/log/tomcat7/catalina.2014-09-29.log为我们提供了Web服务的包路径 INFO: Scanning for root resource and provider classes in the packages: com.swipex.backend.webservices INFO: Root resource classes foun
sudo重新启动服务tomcat7
时,/var/log/tomcat7/catalina.2014-09-29.log
为我们提供了Web服务的包路径
INFO: Scanning for root resource and provider classes in the packages:
com.swipex.backend.webservices
INFO: Root resource classes found:
class com.swipex.backend.webservices.Registration
class com.swipex.backend.webservices.Activation
当我运行junit测试代码来调用这些Web服务时,运行时我得到/var/log/tomcat7/localhost\u access\u log.2014-09-29.txt
"POST /SwipeXBackEnd/backend/Activation/Request HTTP/1.1" 404 1049
web.xml
<xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>de.vogella.jersey.jaxb</display-name>
<servlet>
<servlet-name>SwipeXBackendServices</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.swipex.backend.webservices</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SwipeXBackendServices</servlet-name>
<url-pattern>/backend/*</url-pattern>
</servlet-mapping>
</web-app>
呼叫http://localhost:8080/Activation/Request
我从junit获得
com.sun.jersey.api.client.UniformInterfaceException: POST http://localhost:8080/SwipeXBackEnd/backend/Activation/Request returned a response status of 304 Not Modified
com.sun.jersey.api.client.UniformInterfaceException: POST http://localhost:8080/Activation/Request returned a response status of 404 Not Found
是否有一个日志文件来验证路径
/SwipeXBackEnd/backend/Activation/Request
对于类com.swipex.backend.webservices.Activation
我无法找到任何定义了加载路径的日志文件。我当然希望有人能指出这一点。但我确实发现log4j印在了catalina.out上。现在就知道这一点已经足够了,因为这是我们可以检查负载路径是否通过junit测试获得访问权限的地方
Junit测试
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
//
// Activation Service
//
URI url = UriBuilder.fromUri(
"http://" + Globals.SERVER + ":" + Globals.PORT
+ "/MyCompanyBackend/Activate/Device").build();
WebResource service = client.resource(url);
System.out.println(url);
// Get the data ready
CDeviceDetails newDevice = new CDeviceDetails(all parameters here);
String deviceUniqueIdentity = service.type(MediaType.APPLICATION_JSON)
.post(String.class, newDevice);
assertNotNull(deviceUniqueIdentity);
System.out.println("Activation Passed " + deviceUniqueIdentity);
catalina.out:这里打印了所有log4j
catalina,2014。。日期:如果在这里加载Web服务,您会注意到类似的情况
INFO: Root resource classes found:
class com.yourpath.backend.webservices.Registration
class com.yourpath.backend.webservices.Activation
在这里,当您重新启动tomcat时,您还会注意到webserivces上的错误
SEVERE: The web application [/MyCompanyBackend] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@e08586]) and a value of type [com.sun.jersey.server.impl.application.WebApplicationContext] (value [com.sun.jersey.server.impl.application.WebApplicationContext@81bfd8]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.This is very likely to create a memory leak.
localhost.2014日期:如果出现负载问题,您将注意到一些错误。请发布您的JUnit测试用例。404表示此URL不存在。根据您以前的帖子,尝试将您的URL更改为