3

我正在尝试对 weblogic 12C 使用 Arquillian。

我将以下配置放入我的 pom.xml

<dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <version>1.0.0.CR7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.protocol</groupId>
        <artifactId>arquillian-protocol-servlet</artifactId>
        <version>1.0.0.CR7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.shrinkwrap.resolver</groupId>
        <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
        <version>1.0.0-beta-5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-wls-remote-12.1</artifactId>
        <version>1.0.0.Alpha2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>weblogic</groupId>
        <artifactId>wlfullclient</artifactId>
        <version>12.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-6.0</artifactId>
        <version>3.0.0.Final</version>
        <scope>test</scope>
    </dependency>

然后,我将 arquillian.xml 文件配置如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org.schema/arquillian"
            xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
    <container qualifier="weblogic" default="true">
        <configuration>
            <protocol type="Servlet 3.0">
                <property name="executionType">REMOTE</property>
            </protocol>
            <property name="adminUrl">t3://localhost:7001</property>
            <property name="adminUserName">weblogic</property>
            <property name="adminPassword">weblogic1</property>
            <property name="target">AdminServer</property>
            <property name="wlsHome">c:\java\servers\wls12c\wlserver</property>
        </configuration>
    </container>
</arquillian>

最后,我尝试使用 Arquillian “创建”一个存档:

 JavaArchive ejbArchive = ShrinkWrap.create(JavaArchive.class,"jee6app-ejb.jar").addAsResource("META-INF/persistence.xml","META-INF/persistence.xml").addPackages(false,Adr.class.getPackage(),Service.class.getPackage());
           EnterpriseArchive earArchive = ShrinkWrap.create(EnterpriseArchive.class, "jee6app.ear").addAsModule(ejbArchive).addAsLibraries(
                   new File("target/test-libs/validation-api.jar"),
                   new File("target/test-libs/hibernate-entitymanager.jar"),
                   new File("target/test-libs/hibernate-validator.jar"),
                   new File("target/test-libs/javassist.jar"),
                   new File("target/test-libs/asm.jar"),
                   new File("target/test-libs/cglib.jar"),
                   new File("target/test-libs/hibernate-jpa.jar"),
                   new File("target/test-libs/hibernate-commons-annotations.jar"),
                   new File("target/test-libs/hibernate-annotations.jar"),
                   new File("target/test-libs/slf4j-api.jar"),
                   new File("target/test-libs/jta.jar"),
                   new File("target/test-libs/dom4j.jar"),
                   new File("target/test-libs/commons-collections.jar"),
                   new File("target/test-libs/antlr.jar"),
                   new File("target/test-libs/hibernate-core.jar")
                   );

            return earArchive;

所以,在所有这些事情之后,我总是有以下错误:

Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/transaction/SystemException
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)

我的配置有什么问题?如您之前所见,我尝试将 wlfullclient jar 和 jboss api jar 添加到类路径

在此先感谢您的帮助

问候

4

2 回答 2

10

我在类文件 javax/ejb/EJBException 上与远程 EJB 调用的 JBoss 7.1 和 6.1 eap 有类似的错误

并解决了从

<groupId>javax</groupId> 
<artifactId>javaee-api</artifactId> 
<version>6.0</version>

<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0-5</version>

也许这应该有帮助?
BR

于 2014-01-14T21:29:00.713 回答
3

看到您将javaee-api工件拉入测试范围,您可能希望使用 JBoss 提供的 API,

有关更多详细信息,请参阅此 Arquillian 常见问题解答

或者,对于 WLS,您可以依靠wlfullclient.jar来提供所需的类。您需要将它安装到 Maven 存储库中(可能安装到组织范围的存储库中),然后在您的项目中引用它。

于 2013-03-13T23:58:34.870 回答