Hello Guice experts,

I'm very new to guice-servlet and love the concept - but I can't for
the life of me get it to work with my GWT project. I've not found any
references to this problem so I'm sure I must be doing something
wrong, and I really hope one of you can help me solve this before I
scurry back to my web.xml files!

My problem is this: I have a very simple GWT app that I've set up to
be injected from a (so far) completely empty ServerModule. When I try
to run this through the Eclipse GWT plugin I get an
IllegalAccessException. I'm using version 3.0 for guice and guice-
servlet, and GWT 2.4.

MyGuiceServletContextListener literally contains only this emptiness:

        protected Injector getInjector() {
                return Guice.createInjector(new ServletModule() {
                        protected void configureServlets() {
                        }
                });
        }

And my web.xml has the listener and GuiceFilter set up as per the
tutorial.

The error that gets thrown on startup is this:

java.lang.IllegalAccessError: tried to access field
com.google.inject.servlet.GuiceFilter.servletContext from class
com.google.inject.servlet.GuiceServletContextListener
        at
com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:
43)
        at
org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:
543)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
        at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
1220)
        at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
513)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:
448)
        at com.google.gwt.dev.shell.jetty.JettyLauncher
$WebAppContextWithReload.doStart(JettyLauncher.java:468)
        at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
39)
        at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
130)
        at
org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:
115)
        at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
39)
        at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
130)
        at org.mortbay.jetty.Server.doStart(Server.java:222)
        at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
39)
        at
com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:
672)
        at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
        at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068)
        at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)
        at com.google.gwt.dev.DevMode.main(DevMode.java:311)

This seems to relate to this line (and very interesting comments) from
GuiceServletContextListener:

41    // Set the Servletcontext early for those people who are using
this class.
42    // NOTE(dhanji): This use of the servletContext is deprecated.
43    GuiceFilter.servletContext = new
WeakReference<ServletContext>(servletContext);

So I wonder if there's a workaround for this.

Please, any help gratefully received!

Thanks,
Andy

-- 
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