Hi Mateo,

Your GWT rpc servlet is not guice managed, so this is still Tomcat trying
instantiating it
insteasd of Guice.
You want to do this :
http://stuffthathappens.com/blog/2009/09/14/guice-with-gwt/

2010/5/11 Mateo <[email protected]>

> I'm somewhat familiar with Spring, trying to learn Guice, and I'm
> pretty sure I'm missing something simple. Nonetheless my reading and
> searching has yet to produce any insights, so I'll reveal my
> foolishness here.
>
> My problem appears to be that Guice is not instantiating the
> GreetingServiceImpl class. (I'm using the auto-created GWT
> GreetingService application as a learning point.)
>
> The specific error I am getting comes when I click "Send" (sending my
> name to the server). Tomcat prints the following:
>
> Stack Trace:
>     [java] INFO: Marking servlet greetServlet as unavailable
>     [java] May 11, 2010 11:20:33 AM
> org.apache.catalina.core.StandardWrapperValve invoke
>     [java] SEVERE: Allocate exception for servlet greetServlet
>     [java] java.lang.InstantiationException:
> com.~~~.server.GreetingServiceImpl
>     [java]     at java.lang.Class.newInstance0(Class.java:340)
>     [java]     at java.lang.Class.newInstance(Class.java:308)
>     [java]     at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:
> 1104)
>     ...
>
>
> So, here's what I have. (I've provided a lot - sorry it's a bit long.
> At the same time, let me know if I need to provide something more.)
>
> I've included the following jars from Guice2.0.zip:
>  * aopalliance.jar
>  * guice-2.0.jar
>  * guice-servlet-2.0.jar
> ==================
>
> My GreetingServiceImpl class is as follows:
>
> ... package and imports ...
> @SuppressWarnings("serial")
> public class GreetingServiceImpl extends RemoteServiceServlet
> implements GreetingService
> {
>    private final SecurityHandlerService securityHandlerService;
>    private final AuthenticationHandlerService
> authenticationHandlerService;
>
>    @Inject
>    GreetingServiceImpl(SecurityHandlerService securityHandlerService,
>                        AuthenticationHandlerService
> authenticationHandlerService)
>    {
>        this.securityHandlerService = securityHandlerService;
>        this.authenticationHandlerService =
> authenticationHandlerService;
>    }
>
>    public String greetServer(String input) throws
> IllegalArgumentException
>    {
>           ... uses both securityHandlerService and
> authenticationHandlerService ...
>    }
> }
> =========================
>
> My GuiceServletContextListener impl:
>
> ... package and imports ...
> public class SkyclientGuiceServletConfig extends
> GuiceServletContextListener
> {
>    @Override
>    protected Injector getInjector()
>    {
>        return Guice.createInjector(new ServletModule());
>    }
> }
> ==================
>
> My Abstract Module:
>
> ... package and imports ...
> public class SkyclientBusModule extends AbstractModule
> {
>    @Override
>    public void configure()
>    {
>        System.out.println("\t * Configuring SkyclientBusModule!");
>
> bind(SecurityHandlerService.class).to(SecurityHandlerServiceImpl.class);
>
>
>
> bind(AuthenticationHandlerService.class).to(AuthenticationHandlerServiceImpl.class);
>    }
>
> }
> =============
>
> My web.xml is as follows:
>
> ... xml and doctype ...
> <web-app>
>    <!-- Guice Stuff -->
>    <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>
>    <listener>
>        <listener-class>com.~~~.server.SkyclientGuiceServletConfig</
> listener-class>
>    </listener>
>
>  <!-- Servlets -->
>  <servlet>
>    <servlet-name>greetServlet</servlet-name>
>    <servlet-class>com.~~~.server.GreetingServiceImpl</servlet-class>
>  </servlet>
>  <servlet-mapping>
>    <servlet-name>greetServlet</servlet-name>
>    <url-pattern>/skyclient/greet</url-pattern>
>  </servlet-mapping>
>
>  <!-- Default page to serve -->
>  <welcome-file-list>
>    <welcome-file>SkyClient.html</welcome-file>
>  </welcome-file-list>
>
> </web-app>
> ===========================
>
> Again - sorry it's so long. Is there something obvious I'm missing?
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
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.

Reply via email to