How do I run a standard Arquillian EJB Session Test with Maven?
I'm brand new to Arquillian and Maven, having just started with both this
week so I apologize for the simple question. Needless to say I've put in
some real hours learning the ropes. For my latest trick I'm trying to
setup a standard EJB Session Bean. Most of my knowledge has come from the
Arquillian getting started guides:
http://arquillian.org/guides/getting_started/
http://arquillian.org/guides/getting_started_rinse_and_repeat/
http://docs.jboss.org/arquillian/reference/1.0.0.Alpha1/en-US/html_single/#d0e395
To get the error, I right-click my Model project in Eclipse and select Run
As-> Run On Server. I receive the following error:
Caused by: java.lang.ClassNotFoundException:
org.jboss.shrinkwrap.api.asset.Asset from [Module
"deployment.Model.jar:main" from Service Module Loader]
at
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196)
[jboss-modules.jar:1.2.0.Final-redhat-1]
at
org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444)
[jboss-modules.jar:1.2.0.Final-redhat-1]
at
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432)
[jboss-modules.jar:1.2.0.Final-redhat-1]
at
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:399)
[jboss-modules.jar:1.2.0.Final-redhat-1]
at
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374)
[jboss-modules.jar:1.2.0.Final-redhat-1]
at
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119)
[jboss-modules.jar:1.2.0.Final-redhat-1]
... 29 more
Here's the complete server log:
http://www.williverstravels.com/JDev/Forums/StackOverflow/arquillianEJB/log.txt
Here is my Test class
package model.session;
import static org.junit.Assert.*;
import javax.ejb.EJB;
import model.entity.Project;
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.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class SessionTest {
@EJB
private MyManagerLocal service;
@Deployment
public static JavaArchive createTestableDeployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class,
"example.jar")
.addClasses(MyManagerLocal.class, MyManager.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return jar;
}
@Test
public void assertEqualsProject() {
Project project =
(Project)service.getEntityByPrimaryKey(Project.class, 1L);
assertEquals(project.getProjectId().longValue(), 1L);
}
}
Here's my pom.xml
<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>Model</groupId>
<artifactId>Model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.1.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<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>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</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>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1-RC1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>jboss-embedded</id>
<dependencies>
<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-jbossas-managed</id>
<dependencies>
<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>
</profiles>
I also have an arquillian.xml file
<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">
<defaultProtocol type="Servlet 3.0"></defaultProtocol>
<container qualifier="arquillian-jbossas-managed" default="true">
<configuration>
<property name="jbossHome">C:\Dev\eap</property>
<property name="allowConnectingToRunningServer">true</property>
</configuration>
</container>
Having worked with JBoss AS 7.2 / EAP 6.1, it looks like some jars are
missing, but I would have thought the Maven pom.xml would have taken care
of this. Any help would be appreciated. I'm a little lost at the moment.
No comments:
Post a Comment