Issue
i'm trying to use amazon AWS in a java web application, running in apache tomcat. when i run my app, it fails with,
java.lang.InstantiationError: com.amazonaws.handlers.b
com.amazonaws.services.s3.AmazonS3Client.<init>(Unknown Source)
com.amazonaws.services.s3.AmazonS3Client.<init>(Unknown Source)
org.test.msync.photoweb.PhotoWebServlet.processRequest(PhotoWebServlet.java:47)
org.test.msync.photoweb.PhotoWebServlet.doGet(PhotoWebServlet.java:104)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
any ideas?
looking at the code for AmazonS3Client, it appears to be trying to load a resource named "request.handlers", which does not exist in the SDK jar ... and i cannot find any reference to it anywhere else.
edit: correction, request.handlers is in the JAR, but the version under S3 is empty. no idea where the "b" is coming from.
edit: removing tomcat tag, as i tried on glassfish with the same result. note that it does work in a java SE env.
Solution
I turned off "antiLockingJARs" in Context.xml and the problem went away.
If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value is false.
I can't explain why the AWS jar had problems with this setting. It was set to true by default when I created a new web application project through netbeans (6.9.1).
Answered By - Jeffrey Blattman
Answer Checked By - Cary Denson (JavaFixing Admin)