ava.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor Test didn't work
raba Aug 4, 2013 2:12 PMHello,
I have a problem with my test call. I*m getting alway this Exception an I didn't find a solutin. Can anyone help my with this Exception ??
I want to test a stateless bean on a jboss as 7.1 therefore i use the jboss-as-arquillian-container-remote
Here is my pom.xml with the profile of the arquillian-remote
<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>de.htwg.prozessserver</groupId>
<artifactId>ejbProzessserver</artifactId>
<version>1.0-SNAPSHOT</version>
<name>EJB3 Prozesserver</name>
<packaging>ejb</packaging>
<properties>
<!-- JBOSs_HOME mention your JBOSS_HOME directory-->
<jboss-as.home>C:\jboss-as-7.1.1.Final</jboss-as.home>
<!-- Explicitly declaring the source encoding eliminates the following
message: -->
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- JBoss dependency versions -->
<version.org.jboss.as.plugins.maven.plugin>7.3.Final</version.org.jboss.as.plugins.maven.plugin>
<version.org.jboss.spec.jboss.javaee.6.0>3.0.0.Final</version.org.jboss.spec.jboss.javaee.6.0>
<!-- other plugin versions -->
<version.compiler.plugin>2.3.1</version.compiler.plugin>
<version.ejb.plugin>2.3</version.ejb.plugin>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.6</maven.compiler.source>
<!-- Optional: to use jboss-as:run goal -->
<!--<jboss-as.home>C:\Users\iByteCode\Desktop\jboss-as-7.1.0.Final</jboss-as.home> -->
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.3.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- Define the version of JBoss' Java EE 6 APIs we want to use -->
<!-- JBoss distributes a complete set of Java EE 6 APIs including a Bill
of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection)
of artifacts. We use this here so that we always get the correct versions
of artifacts. Here we use the jboss-javaee-6.0 stack (you can read this as
the JBoss stack of the Java EE 6 APIs). You can actually use this stack with
any version of JBoss AS that implements Java EE 6, not just JBoss AS 7! -->
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>${version.org.jboss.spec.jboss.javaee.6.0}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<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>
<!-- <dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>1.1.5.Final</version>
<scope>test</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.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency> -->
<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency> -->
<!-- <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>1.0</version>
</dependency> -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.2.3.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.3.Final</version>
</dependency>
<!-- Import the Common Annotations API (JSR-250), we use provided scope
as the API is included in JBoss AS 7 -->
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the EJB 3.1 API, we use provided scope as the API is included
in JBoss AS 7 -->
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<scope>provided</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.CR5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>1.1.9.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>arquillian-jbossas-managed</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.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>arquillian-jbossas-remote</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.as</groupId>
<artifactId>jboss-as-arquillian-container-remote</artifactId>
<version>7.1.1.Final</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency> -->
</dependencies>
</profile>
</profiles>
<build>
<!-- Set the name of the deployment -->
<plugins>
<!-- JBoss AS plugin to deploy the application -->
<!-- The jboss-as-maven-plugin is used to deploy, redeploy, undeploy or run your application in JBoss AS.
Under the configuration we specify the build file name same as the project build filename which
is by default of the form “artifactid-version” in our case “ejbmavendemo-1.0-SNAPSHOT”.-->
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>${version.org.jboss.as.plugins.maven.plugin}</version>
<configuration>
<filename>${project.build.finalName}.jar</filename>
</configuration>
</plugin>
<!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation
processors -->
<!-- The maven-compiler-plugin is used to compile the sources of your project. In the above pom.xml we
have used the version 2.3.1 of the plugin with the source and target JDK set to 1.6 under configuration.
We have defined these settings as properties inside <properties> tag and referring it through ${property}.
-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
<!--This plugin generates J2EE Enterprise Javabean (EJB) file as well as the associated client jar.
We specify the ejb version as 3.1 and request the plugin to generate the client by setting the
“generateClient” property to true. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>${version.ejb.plugin}</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
<!-- this is false by default -->
<generateClient>true</generateClient>
</configuration>
</plugin>
</plugins>
</build>
</project>
And here ist my Stateless bean i want to test
@Stateless
@LocalBean
public class NutzerverwaltungBean implements NutzerverwaltungRemote {
@PersistenceContext(unitName ="ProzessServer")
EntityManager em;
/**
* Default constructor.
*/
public NutzerverwaltungBean() {
// TODO Auto-generated constructor stub
}
@Override
public boolean anmeldung(String benutzerName, String passwort) {
Query q = em.createQuery("select a from Benutzer a Where Benutzername = :qname");
q.setParameter("qname", benutzerName);
Benutzer resultBenutzer = (Benutzer)q.getSingleResult();
if(resultBenutzer != null){
if(resultBenutzer.getPasswort().equals(passwort)){
return true;
}
}
return false;
}
And here is my test class
package de.htwg.prozessserver.test.arquillian;
import javax.ejb.EJB;
import org.junit.Assert;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import de.htwg.prozessserver.NutzerverwaltungBean;
@RunWith(Arquillian.class)
public class NutzerverwaltungBeanTest{
@Deployment
public static JavaArchive createDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
.addClass(NutzerverwaltungBean.class)
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
// System.out.println(jar.toString(true));
return jar;
}
@EJB
NutzerverwaltungBean nutzer;
@Test
public void anmeldung_benutzer() {
if(nutzer == null){
Assert.assertTrue("Peti",nutzer.anmeldung("peti","1234"));
Assert.assertTrue("Mo", nutzer.anmeldung("mo","8vfbole"));
Assert.assertTrue("Schweini", nutzer.anmeldung("schweini","31"));
Assert.assertFalse("Tshirt", nutzer.anmeldung("Tshir","Time"));
Assert.assertTrue("FcbTrainer",nutzer.anmeldung("FcBTrainer","triple"));
Assert.assertFalse("fcb",nutzer.anmeldung("fcb","1234"));
Assert.assertFalse("Stuttgarter" ,nutzer.anmeldung("Stuttgarter","canstatt"));
}
}
}
I hope anyone can help me with that.
Thanks a lot.