I have a problem running my code on a Linux distribution (Raspbian, Tomcat 7). The problem does not appear in the test environment under Windows / Tomcat 7 / Eclipse:
My web service just returns HTTP 204 and nothing more. The log does not indicate any error during the request. It should, as in the test environment, respond json.
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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_3_0.xsd" version="3.0"> <display-name>***</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <listener> <listener-class>**.useravailability.UserAvailabilityServletContextListener</listener-class> </listener> <servlet-mapping> <servlet-name>REST Service</servlet-name> <url-pattern>/REST/*</url-pattern> </servlet-mapping> <servlet> <servlet-name>REST Service</servlet-name> <servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class> <init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> </web-app>
usersService.xml
package **.webservice; import java.util.ArrayList; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import com.google.gson.Gson; import **.model.AccessManager; @Path("/usersService") public class UsersService { @GET @Produces("application/json") public String getUser() { String user = null; ArrayList<String> userList = new ArrayList<String>(); try { userList = new AccessManager().getUser(); Gson gson = new Gson(); user = gson.toJson(userList); } catch (Exception e) { e.printStackTrace(); } return user; } }
What am I missing? And why does it work in a test environment? Thanks!
source share