I’m going to skip over a rant about how much Axis2 sucks in order to pass a tip on how to include Axis2 artifacts (AAR’s, MAR’s, etc) into an EAR file using the Maven plugin to package EAR files, maven-ear-plugin. It’s a pretty obvious solution but if you’re in a hurry like I’ve been to convert a project from a single WAR to one with several EJB’s, a WAR, etc, there are a lot of new things to learn all at the same time (how classloading works with EAR’s in JBoss, how to share the same Hibernate transactions between your web app and EJB’s, etc), and this was one of those little things which wasn’t immediately obvious. If you’re seeing exceptions like these when trying to package an EAR in Maven:
- [INFO]
- ————————————————————————
- [ERROR] BUILD ERROR
- [INFO]
- ————————————————————————
- [INFO] Failed to initialize ear modules
- Embedded error: Unknown artifact type[mar]
- [INFO]
- ————————————————————————
- [DEBUG] Trace
… you’ve came to the right place.
There are many ways to setup your package structure under Maven2 to build EAR’s, but essentially what I do is create a root level project which packages a given application into an EAR, and nothing more. Once you have the maven-ear-plugin setup for the most part, all that you need to do is to tell the Maven EAR Plugin to treat the various Axis2 pieces of shit packages like JAR’s:
- <plugin>
- <artifactid>maven-ear-plugin</artifactid>
- <configuration>
- <archive>
- <manifest>
- <addclasspath>true</addclasspath>
- </manifest>
- </archive>
- <artifacttypemappings>
- <artifacttypemapping type=“mar” mapping=“jar”/>
- <artifacttypemapping type=“aar” mapping=“jar”/>
- </artifacttypemappings>
- </configuration>
- </plugin>
This is just one of many gotcha’s I learned about while working on an aforementioned project. In fact it’s really pretty hard to find any comprehensive documentation on getting EJB3, Spring, and Hibernate working together on JBoss with a typical Java web application, especially while using Maven. I have a sample project I used to work through some of the integration issues with this, and will hopefully be able to wrap it up and add it to Google Code in the next few weeks to provide an example of getting all of these technologies to play together.
By Zoltan Farkas October 28, 2008 - 1:28 pm
it is artifactTypeMappings and not artifacttypemappings
it is artifactTypeMapping and not artifacttypemapping
In case anybody will try to cut&paste this info from your site
By Brandon Harper October 28, 2008 - 3:26 pm
@Zoltan
Maybe it was because I was using an older version at the time or something.. *shrugs*.. I copied and pasted that example out of some working code.
Anyhow, I've updated the post to reflect case sensitivity-- thanks!
By Zoltan Farkas October 29, 2008 - 7:46 am
I am using maven 2.0.9 on Solaris, and the lowercase versions were ignored, took me a while to figure it out
, anyways thank you for your post it was really helpful.
By Oleg June 19, 2009 - 12:00 pm
have you tried doing the same with ant? if you could post the syntax for ant build.xml that would be greatly appreciated!
By Brandon Harper June 19, 2009 - 12:08 pm
@Oleg
Sorry, I've only done it using Maven.
By elmeromero September 15, 2010 - 7:03 am
gr8 job!
thx
By HariK September 25, 2011 - 11:23 pm
Saved my day.. Thanks