Uploading file from Google App Engine to Amazon S3

2019-07-21 04:04发布

i am working on gwt2.4, jre7 and GAE 1.7.3.in development mode my code working properly but when i uploaded my apps on app engine than i am getting following error

 java.lang.ExceptionInInitializerError
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:277)
at com.wa.gwtamazon.server.UploadServiceImpl.amazonConfig(UploadServiceImpl.java:124)
at com.wa.gwtamazon.server.UploadServiceImpl.doPost(UploadServiceImpl.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:100)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:447)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:703)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:679)


Nested in java.lang.ExceptionInInitializerError:
java.lang.NullPointerException
at com.amazonaws.util.VersionInfoUtils.initializeUserAgent(VersionInfoUtils.java:124)
at com.amazonaws.util.VersionInfoUtils.getUserAgent(VersionInfoUtils.java:86)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:31)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:277)
at com.wa.gwtamazon.server.AmazonService.uploadFileToAmazone(AmazonService.java:50)
at com.wa.gwtamazon.server.AmazonService.doPost(AmazonService.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:100)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:447)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:703)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:679)

i am also find out solution on following link but still it didn't works

(http://code.google.com/p/googleappengine/issues/detail?id=8166)

2条回答
姐就是有狂的资本
2楼-- · 2019-07-21 04:40

some time app engine didn't get value of os.name,os.version,java.vm.name etc so we have to specify manually in appengine-web.xml file

<system-properties>

<property name="os.name" value="Linux" />
<property name="os.version" value="6.1" />

<property name="java.vm.name" value="Java HotSpot(TM) Client VM" />
<property name="java.vm.version" value="23.5-b02" />

<property name="user.language" value="en" />
<property name="user.region" value="us" />

查看更多
别忘想泡老子
3楼-- · 2019-07-21 04:41

//EDIT: He added the following XML to his appengine-web.xml to get it work:

<system-properties> 
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> 
    <property name="os.name" value="Linux" /> 
    <property name="os.version" value="6.1" /> 
    <property name="java.vm.name" value="Java HotSpot(TM) Client VM" /> 
    <property name="java.vm.version" value="23.5-b02" /> 
    <property name="user.language" value="en" /> 
    <property name="user.region" value="us" /> 
</system-properties>

You can't use the Amazon Libs because of restrictions in the Google App Engine (no Threads, ...). But there are few solutions that should help you:

[1] http://socialappdev.com/using-amazon-s3-with-google-app-engine-02-2011

[2] https://github.com/handstandtech/s3-simple-appengine

Why don't you use Google Cloud Storage with the GAE Java SDK? The GCS API is almost the same as the S3 API.

查看更多
登录 后发表回答