try: serve("*/rest/**").with(GuiceContainer.class,params);
On Friday, July 29, 2011 6:26:57 PM UTC-4, Haitao wrote:
>
> Hi,
>
> I am very new to Guice, so please help me out on this one. I developed
> a web app with Guice injection, and deploy the war file to a Tomcat 6
> server (tried Jetty as well,same error). The WAR file is called
> myservice.war.
>
> For some reasons,
>
> http://<tomcat/jetty host>:8080/myservice/
>
> works, but
>
> http://<tomcat/jetty host>:8080/myservice/user-service/test
>
> gave me 404 error. I checked my web.xml etc., could not identify any
> obvious problem. Hope I can get some help here.
>
> -------------- Web.xml---------------
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:sch
> emaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>
> <display-name>myservice</display-name>
>
> <listener>
> <listener-class>myservice.ServletListener</listener-class>
> </listener>
> <filter>
> <filter-name>guiceFilter</filter-name>
> <filter-class>com.google.inject.servlet.GuiceFilter</filter-
> class>
> </filter>
> <filter-mapping>
> <filter-name>guiceFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> </web-app>
> -------------------------------------
>
> My code looks like
> --------------------ServiceResource------------
> public class ServiceResource {
> /**
> * @return hardcoded string
> */
> @GET
> @Produces("text/plain")
> public final String toString() {
> return "Service";
> }
> }
> -------------------- UserService------------
> @Path("/user-service")
> public class UserService
> {
> protected static Injector injector;
>
> @GET
> @Path("/test")
> public final String toString()
> {
> return "My service - user service";
> }
> }
> --------------------------
>
> My bindings looks like
> -------------------------
> public static class RestModule extends JerseyServletModule {
>
> @Override
> protected void configureServlets() {
> /*
> * REST Stuff
> */
> bind(ServiceResource.class);
> :
> bind(UserService.class);
>
> /*
> * Override Jersey Settings here
> */
> final Map<String, String> params = new HashMap<String,
> String>();
> // ensure WADL generation
> params.put("com.sun.jersey.config.feature.DisableWADL",
> "false");
>
> serve("/*").with(GuiceContainer.class,params);
> }
> }
> ---------------------------
>
> Any help or pointer would be highly appreciated!
>
> Thanks
>
> Haitao
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-guice/-/6dS0BUFaLd8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.