I have just recently been working on some more technical stuff – and I have to admit it is really nice to be back in the code. Working with a couple of start-ups on the East coast lately I have been pottering around with some JBoss 4/5 and EJB3 configurations. Since I’m going to be running around again soon – I thought I would blog a few bits and pieces on technology while I’m about it.
The first thing I noticed about pulling Maven and JBoss together was that the EJB packaging didn’t seem quite as intuitive as I thought. In the end I did end up using the EJB plugin and the dependency plugin to get the dependencies in place. This meant including both the plugins in an EJB parent POM.
<plugin> <artifactId>maven-ejb-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive> <ejbVersion>3.0</ejbVersion> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin </artifactId> <executions> <execution> <id>copy</id> <phase>compile</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>target/classes</outputDirectory> <excludeScope>provided</excludeScope> </configuration> </execution> </executions> </plugin>
With that code in place you just need to ensure you set the packaging to EJB on your EJB’s. I thought that copying the dependencies into the target was probably the nicest way, also you need to watch your dependencies and ensure that those you don’t want to use have a scope of provided so they they don’t get bundled. At first I thought that the dependency embedding should have been part of the EJB plugin, but actually given the power of the dependency plugin it actually made more sense to use that.

