使用JBoss 4.2.2 GA进行Arquillian测试以“无法获取DeploymentManager”结束

时间:2013-01-23 18:03:52

标签: junit jboss-4.2.x jboss-arquillian

我尝试在已安装的JBoss上使用arquillian做一个简单的测试示例,其版本为4.2.2GA。花了很多时间在它上面,并在这个comnunity和stackflow中做了很多阅读,但是却无法弄清楚如何让它工作。

现在的测试就像这样:

package com.ultramain.system.view.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import javax.ejb.EJB;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.descriptor.api.Descriptors;

import org.junit.Test;
import org.junit.runner.RunWith;

import com.ultramain.system.view.test.IShrinkWrapBasicTest;
import com.ultramain.system.view.test.ShrinkWrapBasicTest;

@RunWith(Arquillian.class)
public class QuerySimulationContainer {

@EJB
private IShrinkWrapBasicTest testObject;

@Deployment
public static JavaArchive createDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
    .addClasses(QuerySimulationContainer.class,IShrinkWrapBasicTest.class,ShrinkWrapBasicTest.class);
System.out.println(jar.toString(true));
//System.out.println(jar.getContent());    
return jar; 
}

@Test 
public void testShrinkWrapWorks(){
    testObject = new ShrinkWrapBasicTest();
    assertEquals(testObject.getTestText(), "Test for ShrinkWrap");
}

}

测试单元所需的接口和类如下:

IShrinkWrapBasicTest.java:

package com.ultramain.system.view.test;

import javax.ejb.Remote;

@Remote
public interface IShrinkWrapBasicTest
{
    public String getTestText();

    public void testMethod();
}

ShrinkWrapBasicTest.java:

package com.ultramain.system.view.test;

import javax.ejb.Stateless;
import javax.ejb.Local;

@Stateless
public class ShrinkWrapBasicTest implements IShrinkWrapBasicTest
{ 
    public String getTestText()
    {
        return "Test for ShrinkWrap";
    }

    public void testMethod(){
    }
}

我的pom.XML中更改的部分位于并列出如下: 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">

<!-- other parts in pom.XML which haven't been changed -->

    <dependencies>
        <!-- other dependency parts in original pom.XML, which haven't been changed after using arquillian -->

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.2.1.ga</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-math</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>javax.jee</groupId>
            <artifactId>jee</artifactId>
            <version>5.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-annotations-ejb3</artifactId>
            <version>4.2.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>1.0.3.Final</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>            
        <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>
            <version>1.0.3.Final</version>            
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.ejb</groupId>
            <artifactId>ejb-api</artifactId>
            <version>3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1-jboss</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-5.0</artifactId>
            <version>1.0.0.GA</version>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>    
        <dependency>
            <groupId>org.jboss.client</groupId>
             <artifactId>jmx-invoker-adaptor-client</artifactId>
              <version>4.2.2.GA</version>
              <scope>test</scope>
        </dependency>    
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-jbossas-remote-4.2</artifactId>
            <version>1.0.0.Final-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.arquillian.container</groupId>
          <artifactId>arquillian-container-spi</artifactId>
          <version>1.0.3.Final</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.arquillian.container</groupId>
          <artifactId>arquillian-container-test-spi</artifactId>
          <version>1.0.3.Final</version>
          <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <version>1.0.3.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jbossall-client</artifactId>
            <version>4.2.2.GA</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.deployers</groupId>
            <artifactId>jboss-deployers-client-spi</artifactId>
            <version>2.2.2.GA</version>
            <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.deployers</groupId>
          <artifactId>jboss-deployers-core-spi</artifactId>
          <version>2.2.2.GA</version>
              <scope>test</scope>
        </dependency>         
        <dependency>
            <groupId>org.jboss.shrinkwrap.descriptors</groupId>
            <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
            <version>2.0.0-alpha-4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.shrinkwrap</groupId>
          <artifactId>shrinkwrap-api</artifactId>
          <version>1.1.1-alpha-2</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.shrinkwrap.resolver</groupId>
          <artifactId>shrinkwrap-resolver-bom</artifactId>
          <version>2.0.0-alpha-6</version>
          <type>pom</type>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.shrinkwrap.resolver</groupId>
          <artifactId>shrinkwrap-resolver-depchain</artifactId>
          <version>2.0.0-alpha-6</version>
          <type>pom</type>
          <scope>test</scope>
        </dependency>    

       <!-- other dependency parts in original pom.XML, which haven't been changed after using arquillian -->
    </dependencies>
<!-- other parts in original pom.XML, which haven't been changed after using arquillian -->
</project>

我正在使用jndi.properties文件,aquillian.launch文件和下面列出的另一个arquillian.xml:

jndi.properties(这里的URL是我们用来启动JBOSS服务器的ip地址):

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming\:org.jnp.interfaces 
java.naming.provider.url=jnp://URL:1099

arquilllian.launch:

local

arquillian.xml(这里的URL是我们用来启动JBOSS服务器的ip地址):

<?xml version="1.0"?>
<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="local" default="true">
        <configuration>
            <property name="profileName">local</property>
            <property name="providerUrl">jnp://URL:1099</property>      
            <property name="contextFactory">org.jnp.interfaces.NamingContextFactory</property>
            <property name="urlPkgPrefix">org.jboss.naming:org.jnp.interfaces</property>
        </configuration>   
        <protocol type="Servlet 2.5">
                <property name="host">URL</property>
                <property name="port">8080</property>
        </protocol>          
    </container>
</arquillian>

失败追踪是:

org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not connect to container
    at org.jboss.arquillian.container.jbossas.remote_4_2.JBossASRemoteContainer.start(JBossASRemoteContainer.java:97)
    at org.jboss.arquillian.container.impl.ContainerImpl.start(ContainerImpl.java:199)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$8.perform(ContainerLifecycleController.java:163)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$8.perform(ContainerLifecycleController.java:157)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forContainer(ContainerLifecycleController.java:255)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.startContainer(ContainerLifecycleController.java:156)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$2.perform(ContainerLifecycleController.java:77)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$2.perform(ContainerLifecycleController.java:70)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forEachSuiteContainer(ContainerLifecycleController.java:221)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.startSuiteContainers(ContainerLifecycleController.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:86)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:97)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException: Could not get DeploymentManager
    at javax.enterprise.deploy.shared.factories.DeploymentFactoryManager.getDeploymentManager(DeploymentFactoryManager.java:138)
    at org.jboss.arquillian.container.jbossas.remote_4_2.JBossASRemoteContainer.createDeploymentManager(JBossASRemoteContainer.java:117)
    at org.jboss.arquillian.container.jbossas.remote_4_2.JBossASRemoteContainer.start(JBossASRemoteContainer.java:93)
    ... 61 more

我已经被困在这里几天,并尝试了我从其他帖子中学到的所有内容以及Github中arquillian.container.jboss中的示例。有点绝望现在......有谁能看到我的错误在这里?我错过了pom文件中的任何内容吗?

提前感谢任何建议!

0 个答案:

没有答案