Approach#1
Include jbossall-client as a dependency from JBoss public repository. Co-ordinates ar
e org.jboss.jbossas:jboss-as-client, but this results in Maven downloading huge number of artifacts that are not requried. We would need to selectively include the required or exclude the unnecessary artifacts, which is not an easy job given the huge number. See here and here for some help on this approach.Approach#2I tried adding a dependency with scope as system, providing the absolute path to the jbossall-client.jar. Using system scope has its own issues, most critical being the dependency not being included on the classpath. After going through lot of answers on stackoverflow zeroed on two approaches again - creating a local repository or using dependency and jar plugins. But the problem is jbossall-client.jar
In JBoss 4.0, jbossall-client.jar used to include all the required jars/classes for a standalone client, which is changed since JBoss 5. Now the jar is sleek and refers all the jars through manifest. Issue with this is the jars won't be available if we jbossall-client.jar to some other location as the paths in the manifest are relative.
At this point I gave up and started running my Test directly from cmd by including the jbossall-client.jar in the classpath. Then I came across two Maven plugins maven-ant-plugin and maven-antrun-plugin. The former generates build scripts out of pom and the later can run any ant target from within pom. The antrun plugin is what I tried as I felt the effort to setup maven local repository just to run my test program did not seem worth. Here is what I came up with:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<java classname="com.sample.Tester">
<classpath> <pathelement path="${runtime_classpath}" />
</classpath> <pathelement location="JBOSS_HOME/client/jbossall-client.jar" />
</java>
</target>
</configuration>
</execution>
</executions>
</plugin>
Note that jbossall-client.jar is included later on the classpath otherwise it will try to bootstrap log4j (slf4j is part of jbossall-client.jar)Please share if you done this differently.