gwt guice注入远程servlet。未找到错误404

时间:2012-03-21 07:14:04

标签: java gwt servlets rpc guice

我想在我的远程servlet中使用Guice,但遇到了这个恼人的错误。

在运行我的项目之前,已经出现错误。

警告:启动处理程序时出错 java.lang.NoSuchMethodError:com.google.inject.Scopes.isSingleton(Lcom / google / inject / Binding;)Z     在com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:103)     在com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82)     在com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:102)     在com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:172)     在org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)     在org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)     在org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)     在org.mortbay.jetty.servlet.Context.startContext(Context.java:140)     at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)     在org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)     在org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)     在org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)     在org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)     在org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)     在org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)     在org.mortbay.jetty.Server.doStart(Server.java:224)     在org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)     在com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:191)     在com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:239)     在com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:146)     在com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:97)     在com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)     在com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068)     在com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)     在com.google.gwt.dev.DevMode.main(DevMode.java:311)

运行项目后。

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>

这是我的代码。

<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) {}

}

似乎有什么问题?谢谢。

1 个答案:

答案 0 :(得分:1)

请参阅Scopes.java

方法isSingleton已添加到2.1(当前为3.0)。检查你的安装(可能你使用guice 2.0)