我刚刚完成了webservices的编码。我需要能够调试webservice加载路径。当我sudo restart service tomcat7
时,/var/log/tomcat7/catalina.2014-09-29.log
为我们提供了webservice的包路径
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_access_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>
从junit调用http://localhost:8080/SwipeXBackEnd/backend/Activation/Request
,我得到了
com.sun.jersey.api.client.UniformInterfaceException: POST http://localhost:8080/SwipeXBackEnd/backend/Activation/Request returned a response status of 304 Not Modified
从junit调用http://localhost:8080/Activation/Request
,我得到了
com.sun.jersey.api.client.UniformInterfaceException: POST http://localhost:8080/Activation/Request returned a response status of 404 Not Found
是否有一个日志文件可以验证路径/SwipeXBackEnd/backend/Activation/Request
是否适用于class com.swipex.backend.webservices.Activation
答案 0 :(得分:0)
我无法找到任何已定义加载路径的日志文件。我当然希望有人能指出来。但我确实发现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 .. date :如果您的网络服务加载,您会注意到这样的事情。
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-date :如果出现加载问题,您会发现一些错误。