在GAE上的大型Web应用程序中添加和配置guice

时间:2011-02-08 05:59:47

标签: google-app-engine guice web.xml

我点击了web.xml中可以拥有的最大url模式,我看向guice提供了一个解决方法。如果我可以让它工作,一切都会好的。我想要做的就是设置一个服务器,以便我可以将url-pattern重新路由到新的serv这里是我的web.xml的相关部分:

    <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.google.truxmap.server.guice.MyGuiceServletContextListener</listener-class>
  </listener>

我收到的错误的堆栈跟踪:

Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@1435ec9{/,/base/data/home/apps/foodtrucksmap/5.348199425225253754}
com.google.inject.CreationException: Guice creation errors:

1) An exception was caught and reported. Message: Unable to get members for class com.google.inject.AbstractModule
  at com.google.inject.InjectorShell$Builder.build(InjectorShell.java:135)
Caused by: java.lang.SecurityException: Unable to get members for class com.google.inject.AbstractModule
    at com.google.appengine.runtime.Request.process-47bc6af27ac147aa(Request.java)
    at java.lang.Class.getDeclaredMethods(Class.java:252)
    at com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:78)
    at com.google.inject.internal.ProviderMethodsModule.configure(ProviderMethodsModule.java:70)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:232)
    at com.google.inject.spi.Elements.getElements(Elements.java:101)
    at com.google.inject.InjectorShell$Builder.build(InjectorShell.java:135)
    at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:102)
    at com.google.inject.Guice.createInjector(Guice.java:92)
    at com.google.inject.Guice.createInjector(Guice.java:69)
    at com.google.inject.Guice.createInjector(Guice.java:59)
    at com.google.truxmap.server.guice.MyGuiceServletContextListener.getInjector(MyGuiceServletContextListener.java:14)
    at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:43)
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
    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 com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24)
    at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:435)
    at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:572)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    ... 30 more
Caused by: java.lang.NoClassDefFoundError: [Lorg/aopalliance/intercept/MethodInterceptor;
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2444)
    ... 30 more
Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor
    at com.google.appengine.runtime.Request.process-47bc6af27ac147aa(Request.java)
    ... 30 more

非常感谢你的帮助!

1 个答案:

答案 0 :(得分:2)

您似乎只需要解决对aopalliance库的依赖。将aopalliance.jar放入WEB-INF / lib文件夹。