This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Ready, Set, Go!
Skip to end of metadata
Go to start of metadata

The Bootstrap tutorial walks through installing the framework and creating a simple application.

While the framework is simple to use, creating non-trivial applications assumes a working knowledge of many JEE technologies, including:

  • Java
  • Filters, JSP, and Tag Libraries
  • JavaBeans
  • HTML and HTTP
  • Web Containers (such as Tomcat)
  • XML

(lightbulb) For more about supporting technologies, see the Key Technologies Primer.

In the Ready, Set, Go! lesson, we download the framework and get started on an application of our own.

Download the Distribution

A distribution can be downloaded from the Apache Struts website. The full distribution contains the struts2-core.jar file,related dependencies, example applications, a copy of the documentation in HTML format, and the complete source code.

To compile it yourself, refer to Building the Framework from Source.

Our First Application

To get started with a new application, we can use the blank template, run the Maven archetype, or set up a web infrastructure from scratch.

Using the Blank Application

The blank web application in the distribution's apps directory is meant as a template. We can make a copy of the "blank.war", deploy it to our container, and use the exploded copy as the basis for our application. There is even a simple batch file in the source code directory that we can use to recompile the application in place.

Run the Maven Archetype

For those of us using Maven as a build system, we can use the Maven Archetype to create a new application.

For directions on using the Struts 2 archetypes see the Struts 2 Maven Archetypes page.

Setting up from scratch

If for some reason the blank template or archetype doesn't work out, it's not so hard to setup a Struts 2 application from scratch. For details, see Simple Setup.

Next

Onward to Hello World

Prev

Return to Bootstrap

9 Comments

  1. Hi,

    It might be useful to give some background on the environment required to run this. Are you on Unix or Windows?

    I executed the maven goal to create a 'blank' template but it is far from blank. It seems to have a HelloWorld example already installed in it that is different from your example on the next page...

    Incidentally, I can't get that to work.

  2. With Tomcat 5.0.28 and JDK 1.5 (my exact version is jdk1.5.0_14), struts often have startup problems.

    If the struts-blank application has the following error at startup:
    >> Exception starting filter struts2
    >> javax.xml.transform.TransformerFactoryConfigurationError: Provider >>org.apache.xalan.processor.TransformerFactoryImpl not found

    Try adding xalan.jar and serializer.jar to common/endorsed directory of Tomcat. This solved the problem for me (and many others, apparently).

  3. The archetype is out of date. This is the correct mvn command:

    mvn archetype:create -DgroupId=be.realdolmen.struts2 -DartifactId=tutorial
    \ -DarchetypeGroupId=org.apache.struts
    \ -DarchetypeArtifactId=struts2-archetype-starter
    \ -DarchetypeVersion=2.0.11.2-SNAPSHOT
    \ -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository

    1. Sorry to be pedantic, but the slashes need to come at the end of the line, such as:

      mvn archetype:create -DgroupId=be.realdolmen.struts2 -DartifactId=tutorial \
      -DarchetypeGroupId=org.apache.struts \
      -DarchetypeArtifactId=struts2-archetype-starter \
      -DarchetypeVersion=2.0.11.2-SNAPSHOT \
      -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository

  4. After running the mvn command shown above, the following WARNING appeared:
    INFO create
    WARNING This goal is deprecated. Please use mvn archetype:generate instead

    Subsequently, only the pom.xml and src directory were created.

    I believe the command needs to be revised to the following:

    C:\>mvn archetype:generate -DgroupId=be.realdolmen.struts2 -DartifactId=tutorial
    -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-st
    arter -DarchetypeVersion=2.0.11.2-SNAPSHOT -DremoteRepositories=http://people.ap
    ache.org/repo/m2-snapshot-repository

    1. What version of Maven are you using (so I can update the information) ?

  5. I'm new to struts...so new in fact that I haven't even been able to get the "Hello World" action to work on Ubuntu 8.10. So I'm relying on this documentation to walk me through the process and at least get me to the point that I can start determining what's wrong and how to fix it. With that in mind, most of the jargon on the related pages is not explained. For instance, what is "Sitemesh Integration" and why should I want it? I'm willing to help write some documentation with a little more detail, if that will help.

    Perhaps it's my lack of knowledge of Java. What Java documentation should I be reading or familiar with?

    1. We always welcome comments, new ideas and in general anything that could help us improve the documentation. But if you're struggling with the basics, it might be more helpful to just report the section you're struggling with. Most devs have lost the touch with the way newbies view the documentation (well, I know I have), so we really appreciate things like your Sitemesh comment (except that you should point out where you encounter it, so we can clarify that).

      If you have problems getting started, I'd recommend the Struts user mailing list. We don't discuss problems in the wiki (wink)

    2. I'd add that the link at the top of this page, http://struts.apache.org/primer.html, lists a minimum of Java technologies you may want to familiarize yourself with.

      As in science fiction we must sometimes skip over terms we haven't heard before and assume that they'll either become clear through context or explained later.