Table of Contents
mvn maven
Javaee6 maven jbossAS 7
Install JbosAS 7, maven 2
Start JbossAS
cd $JBOSS_HOME/bin ./standalone.sh
Creating maven project
mvn archetype:generate Choose a number: 113: 326 <-- arche Choose version: 1: 7.0.0.CR1 2: 7.0.0.Final Choose a number: 2: Define value for property 'groupId': : de.td.inhanoi Define value for property 'artifactId': : InHanoi Define value for property 'version': 1.0-SNAPSHOT: : Define value for property 'package': de.td.inhanoi: : [INFO] Using property: name = Java EE 6 webapp project Confirm properties configuration: groupId: de.td.inhanoi artifactId: InHanoi version: 1.0-SNAPSHOT package: de.td.inhanoi name: Java EE 6 webapp project Y: :
Archetype from jboss javaee6: 399: remote → org.jboss.spec.archetypes:jboss-javaee6-ear-webapp (An archetype that generates a starter Java EE 6 webapp project for JBoss AS 7. The project is an EAR, with an EJB-JAR and WAR) 40
With Eclipse
This arche types are available in maven central. http://repo1.maven.org/maven2/archetype-catalog.xml
To add this catalog go to: Window / Preferences / Maven / Archetype / Add Remote Catalog…
jobss-as plugin commands
Compile, package:
mvn install mvn package
'mvn install' first. somehow war package can not find ejb.jar.
Deployment:
mvn jboss-as:deploy mvn jboss-as:redeploy mvn jboss-as:undeploy
Now goto http://localhost:8080/InHanoi.
Arquillian test
If you haven't already, download the latest version of JBoss AS 6.0 from the JBoss AS download page, extract the distribution and start the container.
Since Arquillian needs to perform JNDI lookups to get references to the components under test, we need to include a jndi.properties file on the test classpath. Create the file src/test/resources/jndi.properties and populate it with the following contents:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=jnp://localhost:1099
Next, we're going to return to pom.xml to add another dependency. Arquillian picks which container it's going to use to deploy the test archive and negotiate test execution using the service provider mechanism, meaning which implementation of the DeployableContainer SPI is on the classpath. We'll control that through the use of Maven profiles. Add the following profiles to pom.xml:
<profiles> <profile> <id>jbossas-remote-60</id> <dependencies> <dependency> <groupId>org.jboss.arquillian.container</groupId> <artifactId>arquillian-jbossas-remote-60</artifactId> <version>${arquillian.version}</version> </dependency> </dependencies> </profile> </profiles>
You would setup a similar profile for each Arquillian-supported container in which you want your tests executed.
All that's left is to execute the tests. In Maven, that's easy. Simply run the Maven test goal with the jbossas-remote-60 profile activated:
mvn test -Pjbossas-remote-60