1

再会,

我试图在 Karaf 3.0.2 中部署我的 war 文件,我的 servlet 正在尝试读取一些 S3 文件,但在实例化 AmazonS3Client 时出现此错误

    AmazonS3Client s3Client = new AmazonS3Client();

2015-01-09 13:04:02,205 | INFO  | pool-7-thread-1  | S3Properties                     | 75 - my-domain - 3.0.1.SNAPSHOT | Loading file from S3: my-web.properties
2015-01-09 13:04:02,241 | WARN  | pool-7-thread-1  | AbstractLifeCycle                | 91 - org.eclipse.jetty.aggregate.jetty-all-server - 8.1.15.v20140411 | FAILED MyPerfFilter: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
    at com.amazonaws.util.VersionInfoUtils.userAgent(VersionInfoUtils.java:139)
    at com.amazonaws.util.VersionInfoUtils.initializeUserAgent(VersionInfoUtils.java:134)
    at com.amazonaws.util.VersionInfoUtils.getUserAgent(VersionInfoUtils.java:95)
    at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:42)
    at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:379)

我认为这是我的静态块的问题,但我认为不是,因为我试图创建一个 simplehelloworld servlet,它调用具有此静态块的同一类并且它可以读取 S3 文件

static {
    System.out.println("test 1");
    instance = new MyProperties();
    try {
        System.out.println("test 2");
        instance.load(PROPS_FILENAME);
        reloadable = true;
        System.out.println("test 3");
    } catch (Exception e) {
        try {
            System.out.println("test 3");
            // try to load the file from the classpath instead
            instance.load(MyProperties.class.getResourceAsStream("/" + PROPS_FILENAME));
        } catch (Exception e1) {
            logger.error("Exception caught when loading properties: {}", PROPS_FILENAME, e);
        }
    }
}

任何建议或想法将不胜感激

谢谢

4

0 回答 0