ClassFormatError:类文件中的Absent Code属性,在类文件javax / transaction / SystemException中不是本机或抽象

时间:2013-03-13 13:38:43

标签: java-ee java-ee-6 jboss-arquillian weblogic12c

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

我将以下配置放在我的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

提前感谢您的帮助

此致

2 个答案:

答案 0 :(得分:8)

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

并解决了从

切换的问题
<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

答案 1 :(得分:2)

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

有关详细信息,请参阅this Arquillian FAQ

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