这是我的 GWT 应用程序中的 web.xml:
<context-param>
<param-name>user-base-url</param-name>
<param-value>/user/admin</param-value>
</context-param>
<context-param>
<param-name>static-base-url</param-name>
<param-value></param-value>
</context-param>
<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>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
<mime-mapping>
<extension>manifest</extension>
<mime-type>text/cache-manifest</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- JBoss Resteasy -->
<context-param>
<param-name>resteasy.guice.modules</param-name>
<param-value>com.myapp.server.guice.ServeModule</param-value>
</context-param>
<listener>
<listener-class>
com.myapp.server.guice.CustomGuiceResteasyBootstrapServletContextListener
</listener-class>
</listener>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/</param-value>
</context-param>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
我的问题是我如何使它也可用于 GWT-RPC,就像我这样做时一样
服务模块:
@Override
protected void configureServlets() {
bind(MyService.class).to(MyServiceImpl.class).in(Scopes.SINGLETON);
serve("/app/myservice").with(MyServiceImpl.class);
}
对于定义为的 RPC:
@RemoteServiceRelativePath("myservice")
public interface MyService extends RemoteService
当应用程序加载时,它会引发此错误:
[错误] javax.servlet.ServletException:Servlet 必须绑定为单例。Key[type=com.myapp.server.serviceimpl.MyServiceImpl, annotation=[none]] 未绑定在单例范围内。[错误] 在 com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:104) [错误] 在 com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82) [错误] 在 com. google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:102) [ERROR] at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:172) [ERROR] at org.mortbay.jetty.servlet。 FilterHolder.doStart(FilterHolder.java:97) [ERROR] at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [ERROR] at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:
- 我的应用配置可能有什么问题?
- 我可能错过了哪些设置?