Google App Engine-

问题描述 投票:1回答:1

我正在努力在Eclipse Juno中配置JAX-RS以便部署到Google App Engine,实际上,我还没有实现本地部署(Jetty)。

这是我正在经历的堆栈跟踪,但是我不明白为什么当我包含所有jersey jar文件时,找到类com.sun.jersey.spi.container.servlet.ServletContainer仍然有问题我知道)和所有JAXB JAR文件(我什至还不关心!)。

2012-11-25 22:22:50.622 java[5703:707] [Java CocoaComponent compatibility mode]: Enabled
2012-11-25 22:22:50.623 java[5703:707] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
Nov 25, 2012 10:22:51 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Nov 25, 2012 10:22:51 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed /Users/Rob/Development/HillingarIncidentReporting/HillingarGaeServer/war/WEB-INF/appengine-web.xml
Nov 25, 2012 10:22:51 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /Users/Rob/Development/HillingarIncidentReporting/HillingarGaeServer/war/WEB-INF/web.xml
Nov 25, 2012 10:22:52 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: EXCEPTION 
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:207)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.mortbay.util.Loader.loadClass(Loader.java:91)
    at org.mortbay.util.Loader.loadClass(Loader.java:71)
    at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:242)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    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:205)
    at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:249)
    at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:157)
    at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:333)
    at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
    at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:269)
    at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:245)
Nov 25, 2012 10:22:52 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: unavailable
javax.servlet.UnavailableException: com.sun.jersey.spi.container.servlet.ServletContainer
    at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:79)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:242)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    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:205)
    at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:249)
    at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:157)
    at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:333)
    at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
    at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:269)
    at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:245)

Nov 25, 2012 10:22:52 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed Jersey Web Application: java.lang.NullPointerException
Nov 25, 2012 10:22:52 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: Failed startup of context com.google.appengine.tools.development.DevAppEngineWebAppContext@798baf36{/,/Users/Rob/Development/HillingarIncidentReporting/HillingarGaeServer/war}
java.lang.NullPointerException
    at java.lang.Class.isAssignableFrom(Native Method)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    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:205)
    at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:249)
    at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:157)
    at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:333)
    at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
    at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:269)
    at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:245)
Nov 25, 2012 10:22:52 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: The server is running at http://localhost:8888/
Nov 25, 2012 10:22:52 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: The admin console is running at http://localhost:8888/_ah/admin
2012-11-25 22:22:55.378 java[5703:6c03] Unable to obtain JNIEnv for context: 0x0

这是Eclipse项目中指定的所有JAR文件的屏幕截图-我假设Jetty将其用于本地部署?

构建路径中引用的JAR-配置构建路径

此外,这是/ war / WEB-INF / lib文件夹中的SAME Jersey和JAXB jar文件的副本,正如许多其他论坛建议的那样,它们最终何时在Google App Engine中部署了

部署的战争库文件

问题1首先,我需要解决为什么未加载JAR的原因。 我试图更改它们的加载顺序(我似乎只能在“构建路径-配置构建路径”中执行此操作),因此在这里我首先设置jersey-servlet-1.15.jar文件(因为它具有令人讨厌的类)当下)。

每次尝试解决此问题后,我都清理了我的项目。 有谁知道我可能会想念的东西?

问题2另外,在较低的优先级上,我还想知道实际需要的Jersey和JAXB Jars,我怀疑我只需要一个很小的子集。 也许所有的罐子都在冲突,尽管我尝试过只提供jersey-servley-1.15.jar,但它仍然抱怨!

问题3我注意到泽西岛包含asm-3.1.jar,但是GAE已经包含了asm-4.0.jar,我是否应该不包含3.1,因为已经存在较新的版本?

问题4当我尝试创建扩展ServletContextListener的类时,Eclipse在类列表中没有提供“ ServletContextListener”,但是在类路径中,我可以清楚地看到“ App Engine SDK”版本1.7.3包含servlet-api。 jar,我怀疑在运行时默认情况下Jetty也包含了此功能。

请您的帮助将不胜感激。

eclipse google-app-engine jaxb jax-rs eclipse-juno
1个回答
1
投票

也许您需要在web.xml中添加servlet映射? 例如(使用Spring,但应该类似):

<servlet>
    <servlet-name>REST Service</servlet-name>
    <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.evogro</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
        <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
        <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
    </init-param>
        <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>REST Service</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

问题2:您的列表与我的列表匹配(通过maven包含)。 我正在使用球衣1.13。 我不知道这是否是您可以摆脱的最低限度

问题3:我已将ASM-3.3.1包含在数据核增强器中。 它在要部署的jar列表中。 GAE将换掉所有不喜欢的罐子

Q4:ServletContextListener是您实现的接口。 在新的类向导中,Eclipse应该在添加接口部分中将其提供给您。

我希望其中一些可以解决您的一些问题。 我对这些东西很陌生!

© www.soinside.com 2019 - 2024. All rights reserved.