JBoss AS7 上的 AWS Java SDK - module.xml 个条目
AWS Java SDK on JBoss AS7 - module.xml entries
我在 JBoss AS 7.1 (EE6) 项目中使用新的 AmazonAWS SDK 时遇到问题
我只是使用 S3 库,所以根据新版本 (1.9.7) 我只使用 s3、core、kms jars
-aws-java-sdk-core-1.9.17.jar
-aws-java-sdk-s3-1.9.17.jar
-aws-java-sdk-kms-1.9.17.jar
所以我在 /com/amazonaws 目录中为每个 jar 创建了 3 个单独的 module.xml 条目:
/com/amazonaws/aws-java-sdk-s3/main/module.xml
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws.aws-java-sdk-s3">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-s3-1.9.17.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
<module name="com.amazonaws.aws-java-sdk-kms" />
</dependencies>
</module>
/com/amazonaws/aws-java-sdk-kms/main/module.xml
<resources>
<resource-root path="aws-java-sdk-kms-1.9.17.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
</dependencies>
/com/amazonaws/aws-java-sdk-core/main/module.xml
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws.aws-java-sdk-core">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-core-1.9.17.jar"/>
<resource-root path="commons-logging-1.1.3.jar"/>
<resource-root path="httpclient-4.3.4.jar"/>
<resource-root path="jackson-databind-2.3.2.jar"/>
<resource-root path="joda-time-2.2.jar"/>
<!-- Insert resources here -->
</resources>
</module>
(我已经把额外的依赖如apache-commons, jodatime等直接放到了模块目录下)
以下jboss-部署-structure.xml条目:
<sub-deployment name="Processor-ejb.jar">
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
<module name="com.amazonaws.aws-java-sdk-s3" />
<module name="com.amazonaws.aws-java-sdk-kms" />
</dependencies>
</sub-deployment>
(我也尝试过使用 export=true 将它们声明为 EAR 级依赖项)
以下pom.xml条目:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.9.17</version>
<scope>provided</scope>
</dependency>
但是每当我尝试初始化新的 S3 客户端时:
AWSCredentials credentials = new ProfileCredentialsProvider("ProcessingApp").getCredentials();
AmazonS3 s3 = new AmazonS3Client(credentials);
我得到以下异常:
Caused by: java.lang.NoClassDefFoundError: javax/management/MalformedObjectNameException
at com.amazonaws.jmx.SdkMBeanRegistrySupport.registerMetricAdminMBean(SdkMBeanRegistrySupport.java:27)
at com.amazonaws.metrics.AwsSdkMetrics.registerMetricAdminMBean(AwsSdkMetrics.java:330)
at com.amazonaws.metrics.AwsSdkMetrics.<clinit>(AwsSdkMetrics.java:308)
at com.amazonaws.services.s3.AmazonS3Client.<clinit>(AmazonS3Client.java:261)
at net.processor.actions.scheduled.ScheduledActionsBean.minuteActions(ScheduledActionsBean.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_65]
at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_65]
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.intercept.Interceptor.aroundTimeout(Interceptor.java:201)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:74)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:79)
... 56 more
我的预感会与 apache-commons-logging 发生冲突,因为 SdkMBeanRegistrySupport 中有一个导入 class 并且我知道 JBoss 在其他地方使用这个库使用 org 的别名。slf4j.jcl-over-slf4j,但我认为将 apache 库与 jar 放在一起可以解决这个问题?
我对 AS7 还很陌生,所以我可能错过了一个技巧?
好吧,我最终感谢@Federico Sierra,这里是 sdk-core module.xml(注意。我不得不将 commons-logging、httpclient 和 httpcore jar 放入模块文件夹中,因为它们已发货JBoss 不兼容,我添加了 jackson 和 joda 库作为它们自己的模块)...
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws.aws-java-sdk-core">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-core-1.9.17.jar"/>
<resource-root path="commons-logging-1.1.3.jar"/>
<resource-root path="httpclient-4.3.4.jar"/>
<resource-root path="httpcore-4.3.2.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.stream.api"/>
<module name="javax.xml.bind.api"/>
<module name="com.fasterxml.jackson"/>
<module name="org.joda.time"/>
</dependencies>
</module>
并且 sdk-s3 module.xml 也需要 javax.xml.stream.api
<resources>
<resource-root path="aws-java-sdk-s3-1.9.17.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
<module name="com.amazonaws.aws-java-sdk-kms" />
<module name="javax.xml.stream.api"/>
</dependencies>
希望这对其他人有帮助
我想分享我的代码,它对我有用,希望对你有用
<module xmlns="urn:jboss:module:1.5" name="com.amazonaws.aws-java-sdk-s3">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-s3-1.11.106.jar"/>
<resource-root path="aws-java-sdk-core-1.11.106.jar"/>
<resource-root path="aws-java-sdk-kms-1.11.106.jar"/>
<resource-root path="jmespath-java-1.11.106.jar"/>
<resource-root path="commons-logging-1.1.1.jar"/>
<resource-root path="httpclient-4.5.2.redhat-1.jar"/>
<resource-root path="httpcore-4.4.4.redhat-1.jar"/>
<resource-root path="jackson-annotations-2.8.9.redhat-1.jar"/>
<resource-root path="jackson-databind-2.8.9.redhat-1.jar"/>
<resource-root path="jackson-core-2.8.9.redhat-1.jar"/>
<resource-root path="jackson-dataformat-cbor-2.6.6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.bind.api"/>
<module name="javax.xml.stream.api"/>
<module name="org.joda.time"/>
</dependencies>
</module>
我只使用 jboss 中的一个文件夹 "com/amazonaws/aws-java-sdk-s3",我把所有的罐子都放在那里。
我在 JBoss AS 7.1 (EE6) 项目中使用新的 AmazonAWS SDK 时遇到问题
我只是使用 S3 库,所以根据新版本 (1.9.7) 我只使用 s3、core、kms jars
-aws-java-sdk-core-1.9.17.jar
-aws-java-sdk-s3-1.9.17.jar
-aws-java-sdk-kms-1.9.17.jar
所以我在 /com/amazonaws 目录中为每个 jar 创建了 3 个单独的 module.xml 条目:
/com/amazonaws/aws-java-sdk-s3/main/module.xml
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws.aws-java-sdk-s3">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-s3-1.9.17.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
<module name="com.amazonaws.aws-java-sdk-kms" />
</dependencies>
</module>
/com/amazonaws/aws-java-sdk-kms/main/module.xml
<resources>
<resource-root path="aws-java-sdk-kms-1.9.17.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
</dependencies>
/com/amazonaws/aws-java-sdk-core/main/module.xml
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws.aws-java-sdk-core">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-core-1.9.17.jar"/>
<resource-root path="commons-logging-1.1.3.jar"/>
<resource-root path="httpclient-4.3.4.jar"/>
<resource-root path="jackson-databind-2.3.2.jar"/>
<resource-root path="joda-time-2.2.jar"/>
<!-- Insert resources here -->
</resources>
</module>
(我已经把额外的依赖如apache-commons, jodatime等直接放到了模块目录下)
以下jboss-部署-structure.xml条目:
<sub-deployment name="Processor-ejb.jar">
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
<module name="com.amazonaws.aws-java-sdk-s3" />
<module name="com.amazonaws.aws-java-sdk-kms" />
</dependencies>
</sub-deployment>
(我也尝试过使用 export=true 将它们声明为 EAR 级依赖项)
以下pom.xml条目:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.9.17</version>
<scope>provided</scope>
</dependency>
但是每当我尝试初始化新的 S3 客户端时:
AWSCredentials credentials = new ProfileCredentialsProvider("ProcessingApp").getCredentials();
AmazonS3 s3 = new AmazonS3Client(credentials);
我得到以下异常:
Caused by: java.lang.NoClassDefFoundError: javax/management/MalformedObjectNameException
at com.amazonaws.jmx.SdkMBeanRegistrySupport.registerMetricAdminMBean(SdkMBeanRegistrySupport.java:27)
at com.amazonaws.metrics.AwsSdkMetrics.registerMetricAdminMBean(AwsSdkMetrics.java:330)
at com.amazonaws.metrics.AwsSdkMetrics.<clinit>(AwsSdkMetrics.java:308)
at com.amazonaws.services.s3.AmazonS3Client.<clinit>(AmazonS3Client.java:261)
at net.processor.actions.scheduled.ScheduledActionsBean.minuteActions(ScheduledActionsBean.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_65]
at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_65]
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.intercept.Interceptor.aroundTimeout(Interceptor.java:201)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:74)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:79)
... 56 more
我的预感会与 apache-commons-logging 发生冲突,因为 SdkMBeanRegistrySupport 中有一个导入 class 并且我知道 JBoss 在其他地方使用这个库使用 org 的别名。slf4j.jcl-over-slf4j,但我认为将 apache 库与 jar 放在一起可以解决这个问题?
我对 AS7 还很陌生,所以我可能错过了一个技巧?
好吧,我最终感谢@Federico Sierra,这里是 sdk-core module.xml(注意。我不得不将 commons-logging、httpclient 和 httpcore jar 放入模块文件夹中,因为它们已发货JBoss 不兼容,我添加了 jackson 和 joda 库作为它们自己的模块)...
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws.aws-java-sdk-core">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-core-1.9.17.jar"/>
<resource-root path="commons-logging-1.1.3.jar"/>
<resource-root path="httpclient-4.3.4.jar"/>
<resource-root path="httpcore-4.3.2.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.stream.api"/>
<module name="javax.xml.bind.api"/>
<module name="com.fasterxml.jackson"/>
<module name="org.joda.time"/>
</dependencies>
</module>
并且 sdk-s3 module.xml 也需要 javax.xml.stream.api
<resources>
<resource-root path="aws-java-sdk-s3-1.9.17.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="com.amazonaws.aws-java-sdk-core" />
<module name="com.amazonaws.aws-java-sdk-kms" />
<module name="javax.xml.stream.api"/>
</dependencies>
希望这对其他人有帮助
我想分享我的代码,它对我有用,希望对你有用
<module xmlns="urn:jboss:module:1.5" name="com.amazonaws.aws-java-sdk-s3">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-s3-1.11.106.jar"/>
<resource-root path="aws-java-sdk-core-1.11.106.jar"/>
<resource-root path="aws-java-sdk-kms-1.11.106.jar"/>
<resource-root path="jmespath-java-1.11.106.jar"/>
<resource-root path="commons-logging-1.1.1.jar"/>
<resource-root path="httpclient-4.5.2.redhat-1.jar"/>
<resource-root path="httpcore-4.4.4.redhat-1.jar"/>
<resource-root path="jackson-annotations-2.8.9.redhat-1.jar"/>
<resource-root path="jackson-databind-2.8.9.redhat-1.jar"/>
<resource-root path="jackson-core-2.8.9.redhat-1.jar"/>
<resource-root path="jackson-dataformat-cbor-2.6.6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.bind.api"/>
<module name="javax.xml.stream.api"/>
<module name="org.joda.time"/>
</dependencies>
</module>
我只使用 jboss 中的一个文件夹 "com/amazonaws/aws-java-sdk-s3",我把所有的罐子都放在那里。