JBoss EJB3 and Maven

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.

Leave a Reply

pictures

IMG_0094.JPGJack on his iPhoneJack and his vacuum cleanerMoving the furniture aroundThe new Cars punch bagGetting ready for the traveling life

twitter

  • Back in London. Home again after 3 years. Too long 14 hrs ago
  • RT @BarCampCLT: We are looking for sponsors - help create the first Barcamp in Charlotte - contact philip.dodds at me.com 19 hrs ago
  • pondering whether Picasa and iPhoto compliment each other ? 19 hrs ago
  • looking forward to getting to London this afternoon - anyone recommend a good pub in the City? its been a while 19 hrs ago
  • last chance to see some family for a while - and thinking I might get out to Sydney before the end of 2009 19 hrs ago
  • More updates...

Powered by Twitter Tools.