kaliber-scala / play-s3

S3 module for Play
MIT License
119 stars 49 forks source link

Null pointer exception while reading file from s3 bucket in play 2.4.4 #64

Closed snaxe closed 8 years ago

snaxe commented 8 years ago

On upgrading play from 2.2.x to 2.4.4, we tried to read file from s3 bucket, but getting NullPointerException on upgrade. However it works fine on the old version. Following are the details: build.sbt: "net.kaliber" %% "play-s3" % "7.0.2"

Application.conf: s3.region="us-west-2" aws.accessKeyId="xxxxxxxxxxx" aws.secretKey="xxxxxxxxx" aws.bucket="xxxxxxxx"

Code for accessing the s3 file: import play.api.Play.{configuration, current} private lazy val LOGOBUCKET: String = configuration.getString("aws.bucket").get val logobucket = S3(LOGOBUCKET) val result = logobucket get "xxx/xxx/xxx/logo.png"

Stacktrace for the same: lay.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[NullPointerException: originalUrl]] at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:265) ~[play_2.11-2.4.4.jar:2.4.4] at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:191) ~[play_2.11-2.4.4.jar:2.4.4] at play.api.GlobalSettings$class.onError(GlobalSettings.scala:179) [play_2.11-2.4.4.jar:2.4.4] at play.api.mvc.WithFilters.onError(Filters.scala:93) [play_2.11-2.4.4.jar:2.4.4] at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:94) [play_2.11-2.4.4.jar:2.4.4] Caused by: java.lang.NullPointerException: originalUrl at com.ning.http.client.uri.UriParser.parse(UriParser.java:323) ~[async-http-client-1.9.21.jar:na] at com.ning.http.client.uri.Uri.create(Uri.java:30) ~[async-http-client-1.9.21.jar:na] at com.ning.http.client.providers.netty.handler.Protocol.exitAfterHandlingRedirect(Protocol.java:124) ~[async-http-client-1.9.21.jar:na] at com.ning.http.client.providers.netty.handler.HttpProtocol.handleHttpResponse(HttpProtocol.java:423) ~[async-http-client-1.9.21.jar:na] at com.ning.http.client.providers.netty.handler.HttpProtocol.handle(HttpProtocol.java:470) ~[async-http-client-1.9.21.jar:na]

EECOLOR commented 8 years ago

You probably need the following configuration option:

#required in case dots are present in the bucket name and https is enabled
s3.pathStyleAccess=false
snaxe commented 8 years ago

I tried setting it to false but getting same exception.

EECOLOR commented 8 years ago

I misread your code. Please ignore my previous statement. Let me try to see if I can reproduce the problem. It would be helpful if you set up a small, self contained example (including a test bucket with valid credentials) to reproduce the problem.

EECOLOR commented 8 years ago

A few questions:

snaxe commented 8 years ago

The issue is resolved. It was because the region was set to "us-west-2" that was visible on the aws console link. However the contents were hosted on ap-southeast-1.

EECOLOR commented 8 years ago

Oh great! Good to know for future encounters.

thehappycoder commented 8 years ago

I got

Caused by: java.lang.NullPointerException: originalUrl

too

Didn't have region set. The exception could be more readable :-)