を投げる私は例here に基づいてAWSラムダ関数としてクラスをScalaのPlayアプリケーションを実行しようとしています簡単な関数である:AWSラムダ再生ScalaのプロジェクトはUnknownHostExceptionが
class PlayTask {
// AWS Lambda Handler
def exec(event: S3Event): String = WithApplication { App =>
Play.current.configuration.getString("Play.Lambda.Greet").getOrElse("")
}
private def WithApplication[A](f: Application => A): A = {
val env = Environment(new java.io.File("."), getClass.getClassLoader, Mode.Prod)
val context = ApplicationLoader.createContext(env)
val app = ApplicationLoader(context).load(context)
try {
Play.start(app)
f(app)
} finally {
Play.stop(app)
}
}
}
jarファイルがロードされていますS3コンテナに接続し、VPCに接続してRDSとインターネットにアクセスします。 しかし、VPCと接続してS3テストを実行すると、次のエラーが発生します。私はjava.net.UnknownHostExceptionを発行から理解何
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132) [task/:na]
at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:93) [task/:na]
at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:80) [task/:na]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) [task/:na]
at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80) [task/:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:62) [task/:na]
at com.google.inject.internal.InjectorImpl.injectMembers(InjectorImpl.java:984) [task/:na]
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149) [task/:na]
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies$$FastClassByGuice$$2a7177aa.invoke(<generated>) [task/:na]
at com.google.inject.internal.cglib.reflect.$FastMethod.invoke(FastMethod.java:53) [task/:na]
at com.google.inject.internal.SingleMethodInjector$1.invoke(SingleMethodInjector.java:57) [task/:na]
at com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:91) [task/:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132) [task/:na]
at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:93) [task/:na]
at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:80) [task/:na]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) [task/:na]
at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80) [task/:na]
at com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:174) [task/:na]
at com.google.inject.internal.Initializer.injectAll(Initializer.java:108) [task/:na]
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:174) [task/:na]
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110) [task/:na]
at com.google.inject.Guice.createInjector(Guice.java:96) [task/:na]
at com.google.inject.Guice.createInjector(Guice.java:73) [task/:na]
at com.google.inject.Guice.createInjector(Guice.java:62) [task/:na]
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) [task/:na]
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) [task/:na]
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) [task/:na]
at example.PlayTask.WithApplication(PlayTask.scala:16) [task/:na]
at example.PlayTask.exec(PlayTask.scala:9) [task/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_71]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_71]
at lambdainternal.EventHandlerLoader$PojoMethodRequestHandler.handleRequest(EventHandlerLoader.java:439) [lambda-sandbox.jar:na]
at lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:370) [lambda-sandbox.jar:na]
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:972) [lambda-sandbox.jar:na]
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:231) [lambda-sandbox.jar:na]
at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:59) [lambda-sandbox.jar:na]
at java.lang.Class.forName0(Native Method) [na:1.8.0_71]
at java.lang.Class.forName(Class.java:348) [na:1.8.0_71]
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:93) [runtime/:na]
Caused by: java.net.UnknownHostException: ip-10-0-77-249: unknown error
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_71]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_71]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_71]
at java.net.InetAddress.getLocalHost(InetAddress.java:1500) ~[na:1.8.0_71]
は、関数がローカルホストのホスト名を検索し、ローカルループバックにフォールバックすることができないということです。
ありがとうございます。私はすでにVPCにNATゲートウェイを追加することで、インターネットとAWS APIへのアクセスを有効にしています。設定が正しいことを確認したAWSのサポートによって裏付けられました。上記のエラーの原因となる他の理由はありますか? – binshi