2

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.

** Update ** I've tried a few other pom.xml configurations such as changing all the arquillian scope's to runtime or just removing the tag altogether. Still get the same error. I also tried to add the following to no effect:

<dependency>
    <groupId>org.jboss.shrinkwrap.resolver</groupId>
    <artifactId>shrinkwrap-resolver-bom</artifactId>
    <version>2.1.0-alpha-1</version>
    <scope>runtime</scope>
    <type>pom</type>
</dependency>

** Update **

From what I can tell the problem lies with the jar line in my pom.xml. Libraries are needed, but they are not being packaged with the jar. So I'm back to the drawing board about how to get my tests working. Should I package them in another project? That gives me errors too when I run it since my tests cannot "see" the Model.jar that is being tested. This is turning into an aggravating catch-22.

Will Lovett
  • 1,241
  • 3
  • 18
  • 35
  • Well, your application doesn't deploy to the server as a JAR does it? Do you deploy a WAR or an EAR? Generally, best practice here is to setup a separate integration test project that depends on your other projects, and then can deploy multiple artifacts. – John Ament Sep 11 '13 at 01:15
  • Hi John. Thanks alot for your response. The problem was that it was indeed deploying as a jar which means it wasn't deploying needed libraries. So I fixed that by deploying as a "Skinny" ear. But I'm still not sure how to link up my tests with my ear. I'm running into all kinds of errors under quire a few different scenarios. I've migrated my post on over to https://community.jboss.org/thread/232490 if you care to take a look. I've documented my attempts quite a bit on that thread. – Will Lovett Sep 12 '13 at 18:47

0 Answers0