1
votes

I would like to use the Guice in my remote servlet but encountered this annoying errors.

Before running my project there is an error already.

WARNING: Error starting handlers java.lang.NoSuchMethodError: com.google.inject.Scopes.isSingleton(Lcom/google/inject/Binding;)Z at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:103) at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82) at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:102) at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:172) at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:224) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:191) at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:239) at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:146) at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:97) 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)

After running the project.

404

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 NOT_FOUND</title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /mercado/login. Reason:
<pre>    NOT_FOUND</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>

Here is my code.

<listener>
    <listener-class>ph.com.mercado.server.ioc.GuiceServletListener</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>


public class GuiceServiceModule extends AbstractModule {

    @Override
    protected void configure() {
        bind(LoginServiceImpl.class).in(Singleton.class);


public class GuiceServletListener extends GuiceServletContextListener{

    @Override
    public Injector getInjector() {
        return Guice.createInjector(new GuiceServletModule(), new GuiceServiceModule());
    }

public class GuiceServletModule extends ServletModule  {

    @Override
    protected void configureServlets() {
        serve("/mercado/login").with(LoginServiceImpl.class);

@RemoteServiceRelativePath("login")
public interface LoginService extends RemoteService {
    public LoginInfo loginGoggle(String requestUri);


public class LoginServiceImpl extends RemoteServiceServlet implements
        LoginService {

    @Inject
    private UserDao userDao;

    @Override
    public LoginInfo loginGoggle(String requestUri) {}

}

What seems to be the problem? Thank you.

1

1 Answers

1
votes

See Scopes.java

Method isSingleton has been added to 2.1 (current is 3.0). Check your installation (probably you use guice 2.0)