Home > JBoss, Maven, Ubuntu > Maven and Struts 1

Maven and Struts 1

Maven archetype can be used to generate blank projects. However, the mvn archetype:generate command does not give an option to generate an empty struts project with Struts 1. To generate a Struts 1.x project we need to install the struts blank archetype. Use the following commands to download and install struts blank archetype in the local repository.

svn co http://svn.apache.org/repos/asf/struts/maven/trunk/struts-archetype-blank
cd struts-archetype-blank
mvn install

Now to generate a project use the following command

mvn archetype:generate -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts-archetype-blank -DarchetypeVersion=1.3.5-SNAPSHOT -DgroupId=com.wordpress.codesilo -DpackageName=com.wordpress.codesilo -DartifactId=test-struts

Now we will test this on JBoss AS. Set a variable JBOSS_HOME in bash_profile and change the plugins section generated in the pom.xml file above to the following.


Now we will use the maven JBoss plugin to deploy the war generated above. Use the following command to deploy the war file.

mvn jboss:hard-deploy

(To undeploy use the command mvn jboss:hard-undeploy)

The war will be deployed to the following dir ($JBOSS_HOME/server/web/deploy) (in JBoss 5). If Jboss 4 is used, change the serverName above to “default”.

On starting Jboss we will see an exception ….
java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory
This can be corrected by removing the jar that is included by the struts-archetype-blank plugin.
Change the following in the pom.xml




The server will now start without any exceptions.

  1. Jesse Webb
    April 6, 2010 at 10:35 pm

    Thanks for the write-up! This post proved very useful 🙂

    I was recently tasked with creating a new web application under the constraint of using Struts 1.x. I searched for how to create a new struts1 maven project and I stumbled upon this page, http://struts.apache.org/1.3.10/faqs/apps.html, which explains how to generate the skeleton for a new app.

    The first problem was that the archetype groupId and artifactId were no longer available through the Maven central repository. The first section of this post explaining how to checkout the archetype source solved that problem for me.

    I then was able to generate the starting point to my app but upon my first build, ran into the ClassCastException issue. Of coarse I just made the modification you suggested and the problem went away.

    Thanks again!

    • April 12, 2010 at 1:58 am

      I am glad I was of help.

  2. September 18, 2010 at 6:42 pm

    Thanks. This was very helpful.

  3. Fata
    April 15, 2011 at 6:15 pm

    Is it normal to run “mvn archetype” command under a folder that’s already contained a pom file ?

    When I try it I get failure message “Unable to add module to the current project I it is not of packaging type ‘pom’ “

    • April 19, 2011 at 2:10 am

      From what I know, you could run the command provided your intention is to create a sub-project in the existing structure. Also, for that to succeed the existing pom.xml should have a packaging type as pom. I assume in your case .. the packaging type was not a pom.

  1. July 12, 2010 at 6:02 am
  2. September 14, 2010 at 6:46 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: