Dev Environment Setup

This are the notes I have taken while setting up my Eclipse environment to run a Smartweb application. Feel free to comment!

Environment Details:

Checking out the source code

The first thing to do is to check out the existing codebase in your Eclipse workspace as a starting point.

sebastien@kilkenny:~/workspace$ svn checkout smartweb

Once you've checked out the project, the subdirectories under smartweb should look as follows:

The Core of the Smartweb framework.
The test library used throughout the whole Smartweb application.
The different modules which can be used in a project (cf.
A project template which can be used as a startup point in a project.
An example!

Setting up your Eclipse project

(I'm assuming you're running Eclipse for Java EE developers together with the JBoss Tools plugin)

The first thing to do is to import the different modules that you are likely to use during your project. To do this, go into File > Import… > Existing Projects into Workspace. Select the smartweb folder in your workspace; all the subprojects should appear as projects.


Click Finish and the projects get imported into Eclipse.

You then have to resolve the dependencies between projects manually…

Method 1: Use the Template

Create mysmartweb project by copying the template project:

sebastien@kilkenny:~/workspace$ cp -R smartweb/template/eclipse mysmartweb

Import that new project into Eclipse as previously, and you're ready to go!

That new project is structured as follows:

The source folder
Unit tests
JSP, css, images, etc.

Method 2: Maven Archetype

Create the project with a Maven Archetype.

mvn archetype:create  -DarchetypeGroupId=org.apache.struts \ 
                      -DarchetypeArtifactId=struts-archetype-blank \
                      -DarchetypeVersion=1.3.5-SNAPSHOT \
                      -DgroupId=com.example \
                      -DpackageName=com.example.myproject \ 
                      -DartifactId=myproject \

Open the pom.xml, and edit as follows:
- remove the following:


- Add the following:


- Replace the dependencies with the following:


Obviously, you have to make sure that the Smartweb libraries have been installed into your local Maven repository.

- Run mvn install, then mvn eclipse:eclipse
- File > Import… > Existing Projects into Workspace
- import myproject
- Import myproject into the Web Development perspective as a Struts project.
- Open src/main/webapp/WEB-INF/web.xml, and the following between display-name and the Struts servlet definition:

<!-- ========================================================== Filters -->


 <!-- ======================================================== Listeners --> 


 <!-- ========================================================= Servlets -->
 <!-- Standard Action Servlet Configuration -->

- Change the Action Servlet from org.apache.struts.ActionServlet to net.smartlab.web.ActionServlet and add the following init-param to it:


- Replace welcome file with the following:


- Remove DTD from web.xml, and instead redefine the web-app tag as follows to use Servlet 2.4 / JSP 2.0 (and use EL expression like in auth):

<web-app xmlns=""

- In the Struts Config file, add the following:

<message-resources parameter="net.smartlab.web.messages" />
    <message-resources key="auth" parameter="net.smartlab.web.auth.messages" />
    <message-resources key="app" parameter="messages" />

and delete

<message-resources parameter="MessageResources" />. You can also delete

- Add the following action:

<action path="/index" forward="/index.jsp" />

Enabling the auth module

- Copy security.xml from the auth module into src/main/resources/META-INF (I've tried to make sure it was being copied in target/myproject/META-INF, but it was not working, so I had to make sure it was being copied into target/myproject/WEB-INF/classes/META-INF/, which sucks.)

- Copy smartweb.jar.hcf into src/main/resources/META-INF (same story as above).
- Copy auth JSPs in src/main/webapp/auth
- Copy smartweb-auth.tld into src/main/webapp/WEB-INF
- Copy auth images in src/main/webapp/images
- Copy forms-auth.xml and struts-auth.xml into src/main/webapp/WEB-INF
- Create authException.jsp in src/main/webapp/auth
- Copy resources bundles from both core and auth into src/main/resources (you'll have to recreate the net/smartlab/web(/auth) tree)
- Create in src/main/resources, and add the following properties:

welcome-on=Welcome to

- Add the following in src/main/resources/net/smartlab/web/

# -- welcome --
    welcome.title=Struts Blank Application
    welcome.message=To get started on your own application, edit the skeleton configuration files as needed, build with "mvn install", and you are on your way!

- Run mvn package in the "auth" module folder; this creates the etc/sql/mysql.sql file to execute. Create the database schema in MySQL by executing these queries.
- Open src/main/resources/META-INF/smartweb.jar.hcf and edit the parameters to use your local MySQL database.
- Right click on project, Run As, Open Run Dialog… Edit Arguments, VM Arguments. Add the following on a new line:


- mvn install, then Publish into your WTP Tomcat Server. Start.
- Try to log on:


You should get a login page.

- Insert a user in the user table.

Core stuff

- Copy core pages to src/main/webapp, and images into src/main/webapp/images
- Copy core index.jsp from web/ into src/main/webapp
- Copy core smartweb.tld into src/main/webapp/WEB-INF

- Display the following page:


and you should get the Smartweb welcome page.

Issues I had to tackle in the process

- In TomcatConfigurationStrategy, the method getSessionFactory was modified as follows:

public SessionFactory getSessionFactory(BusinessObjectFactory bof) {
        synchronized (BusinessObjectFactory.class) {
            String archive = Domain.getLastArchiveName(bof.getClass());
            URL file = Domain.getResource(bof.getClass(), new String[] {"/META-INF/" + archive + ".hcf",
            try {
                if (!factories.containsKey(file.toString())) {
                    // Session factory not found in cache
                    logger.warn("getSessionFactory() - configure hibernate without JNDI");
                    SessionFactory factory = new Configuration().configure(file).buildSessionFactory();
                    factories.put(file.toString(), factory);
                return (SessionFactory)factories.get(file.toString());
            } catch (Exception e) {
                logger.error("getSessionFactory() - error", e);
                return null;

to acommodate the fact that URL is not comparable.

- Create an authException.jsp file, as it is required by the auth module when authentication error,
- Change redirect="true" into redirect="false" in Struts config to avoid errors about
missing resource bundles.
- Change DTD in struts-auth.xml
- Change taglib references in Core base.jsp file to:

<%@ taglib uri="" prefix="html"%>
<%@ taglib uri="" prefix="bean"%>
<%@ taglib uri="" prefix="logic"%>

to be consistent with auth, but also to avoid to have to copy Struts TLD in the projects.
- Create standalone as indicated above.
- When running Core index.jsp, get the following error:

org.apache.jasper.JasperException: /index.jsp(3,0) /context.jsp(3,6) /auth/login.jsp(4,65) The prefix html specified in this tag directive has been previously used by an action in file /header.jsp line 52.

I removed the taglib definitions from login.jsp in auth, and moved them to base.jsp (core). I then deleted the existing Struts taglib definitions in base.jsp. I also removed DTD declaration and html:html tag, as this is a JSP fragment included in another JSP (and it was breaking XHTML std).
- security.png is nowhere to be found.
- Core pages are not internationalized, and there are some bits of Italian in there! ;-)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.