1

我正在尝试阅读 Arquillian入门指南。只要我使用 arquillian-weld-ee-embedded 容器,一切正常。但是,当我尝试切换到 glassfish-managed 时,我收到了这个错误:

Tests in error: org.arquillian.example.GreeterTest: Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException

我使用了参考指南中显示的配置。

这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.arquillian.example</groupId>
<artifactId>arquillian-tutorial</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>arquillian-tutorial</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>1.0.2.Final</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <id>arquillian-weld-ee-embedded</id>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-6.0</artifactId>
                <version>1.0.0.Final</version>
                <type>pom</type>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
                <version>1.0.0.CR3</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.weld</groupId>
                <artifactId>weld-core</artifactId>
                <version>1.1.5.Final</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.6.4</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>arquillian-glassfish-embedded</id>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
                <version>1.0.0.CR3</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.glassfish.main.extras</groupId>
                <artifactId>glassfish-embedded-all</artifactId>
                <version>3.1.2</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>glassfish-managed-3.1</id>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-glassfish-managed-3.1</artifactId>
                <version>1.0.0.CR3</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>6.0</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
        <build>
            <testResources>
                <testResource>
                    <directory>src/test/resources</directory>
                </testResource>
                <testResource>
                    <directory>src/test/resources-glassfish-managed</directory>
                </testResource>
            </testResources>
        </build>
    </profile>
</profiles>

还有我的 src/test/resources/arquillian.xml:

<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
    http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="glassfish" default="true">
    <configuration>
        <property name="glassFishHome">/opt/app/glassfish-3.1.2.2</property>
    </configuration>
</container>

Greeter、PhraseBuilder 和 GreeterTest 类与上述指南中的相同。

编辑:这是 Surefire 的报告:

    测试运行:1,失败:0,错误:1,跳过:0,经过时间:0.255 秒(EventTestRunnerAdaptor.java:56)
    ... 21 更多
原因:java.lang.IllegalArgumentException:必须指定 DeployableContainer
    在 org.jboss.arquillian.core.spi.Validate.notNull(Validate.java:44)
    在 org.jboss.arquillian.container.impl.ContainerImpl.(ContainerImpl.java:71)
    在 org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:76)
    ... 45 更多
引起:java.lang.reflect.InvocationTargetException
    在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    在 java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    在 org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:156)
    ... 16 更多
原因:org.jboss.arquillian.container.impl.ContainerCreationException:无法创建容器 glassfish
    在 org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:85)
    在 org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:76)
    在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    在 java.lang.reflect.Method.invoke(Method.java:601)
    在 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    在 org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    在 org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    在 org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    在 org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    在 org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:236)
    在 org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)
    在 org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:68)
    在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    在 java.lang.reflect.Method.invoke(Method.java:601)
    在 org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    在 org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    在 org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    在 org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    在 org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    在 org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:261)
    在 org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.(EventTestRunnerAdaptor.java:56)
    ... 21 更多
原因:java.lang.IllegalArgumentException:必须指定 DeployableContainer
    在 org.jboss.arquillian.core.spi.Validate.notNull(Validate.java:44)
    在 org.jboss.arquillian.container.impl.ContainerImpl.(ContainerImpl.java:71)
    在 org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:76)
    ... 45 更多
4

1 回答 1