Run appfuse with Maven

I wanted to refresh my skill in Maven. AppFuse is a very popular open source JavaEE framework built based on Maven hence I use AppFuse as the tool to refresh my Maven skill.

Install the following prerequisite:
1. Install JDK 7. I have done this step when I installed Jenkins. How to find out a process PID on Windows
C:\Users\luhuang>java -version
java version “1.7.0_45”
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)


2. Install MySQL5.6.
C:\Users\luhuang>mysql –version
mysql Ver 14.14 Distrib 5.6.19, for Win64 (x86_64)


3. Install Maven.
C:\Users\luhuang>mvn –version
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T21:51:4
Maven home: D:\apache-maven-3.2.2\bin\..
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: C:\glassfish4\jdk7\jre
Default locale: zh_CN, platform encoding: Cp1252
OS name: “windows 7”, version: “6.1”, arch: “amd64”, family: “windows”

4. Run command to pull down source code for AppFuse:
mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring-archetype -DarchetypeVersion=3.0.0 -DgroupId=com.mycompany -DartifactId=myproject -DarchetypeRepository=

[If you are behind a firefox, you have to set your proxy in settings.xml under apache-maven-3.2.2\conf\settings.xml. E.g,

[INFO] Downloading:
[INFO] Downloaded:
pfuse-basic-spring-archetype/3.0.0/appfuse-basic-spring-archetype-3.0.0.pom (2 K
B at 1.5 KB/sec)
[INFO] ————————————————————————-

[INFO] Using following parameters for creating project from Archetype: appfuse-b
[INFO] ————————————————————————-

[INFO] Parameter: groupId, Value: com.luohuahuang
[INFO] Parameter: artifactId, Value: releng
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.luohuahuang
[INFO] Parameter: packageInPathFormat, Value: com/luohuahuang
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.luohuahuang
[INFO] Parameter: groupId, Value: com.luohuahuang
[INFO] Parameter: artifactId, Value: releng
[INFO] project created from Archetype in dir: D:\Source\releng
[INFO] ————————————————————————
[INFO] ————————————————————————
[INFO] Total time: 04:08 min
[INFO] Finished at: 2014-06-28T18:11:31+08:00
[INFO] Final Memory: 12M/154M
[INFO] ————————————————————————

5. Run the application, mvn jetty:run.

Jetty is using 8080 by default however Jenkins has already used 8080 as its server port. To avoid conflicting, update it to 8088 in the pom.xml before running mvn jetty:run. AppFuse uses root user to connect MySQL without password, update the password accordingly,

<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">


<!-- Database settings -->
<jdbc.validationQuery>SELECT 1 + 1</jdbc.validationQuery>

6. While you run mvn jetty:run, it might fail with error,

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm
2ddl (default) on project : Execution default of goal org.codehaus.mojo:hi
bernate3-maven-plugin:2.2:hbm2ddl failed

: Could not parse configuration: file:/D
:/Source/releng/src/main/resources/hibernate.cfg.xml: Connection timed out: conn
ect Nested exception: Connection timed out: connect -> [Help 1]

Go to releng\src\main\resources, edit hibernate.cfg.xml,

<!-- NOTE: If you're working offline, you might have to change the DOCTYPE to the following:-->
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<!--!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

<mapping class="org.appfuse.model.User"/>
<mapping class="org.appfuse.model.Role"/>


7. Run mvn jetty:run again,

pse.jdt.core/3.7.1/org.eclipse.jdt.core-3.7.1.jar (1708 KB at 72.3 KB/sec)
[INFO] Configuring Jetty for project: AppFuse Spring MVC Application
[INFO] webAppSourceDirectory not set. Defaulting to D:\Source\releng\src\main\we
[INFO] Reload Mechanic: automatic
[INFO] Classes = D:\Source\releng\target\classes
[INFO] Context path = /
[INFO] Tmp directory = D:\Source\releng\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:/D:/Source/releng/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = D:\Source\releng\src\main\webapp
2014-06-28 18:50:53.083:INFO:oejs.Server:jetty-8.1.14.v20131031
2014-06-28 18:50:55.977:INFO:oejpw.PlusConfiguration:No Transaction manager foun
d – if your webapp requires one, please configure one.
2014-06-28 18:51:04.607:INFO:/:No Spring WebApplicationInitializer types detecte
d on classpath
2014-06-28 18:51:05.761:INFO:/:Initializing Spring root WebApplicationContext
WARN [main] DTDEntityResolver.resolveEntity(74) | HHH000223: Recognized obsolete
hibernate namespace Use namespace http://www instead. Refer to Hibernate 3.6 Migration Guide!
WARN [main] DirectoryProviderHelper.makeSanityCheckedDirectory(258) | HSEARCH000
041: Index directory not found, creating: ‘D:\Source\releng\target\index’
WARN [main] DirectoryProviderHelper.makeSanityCheckedDirectory(258) | HSEARCH000
041: Index directory not found, creating: ‘D:\Source\releng\target\index\
DEBUG [main] LookupDaoHibernate.getRoles(39) | Retrieving all role names…
WARN [main] StartupListener.contextInitialized(96) | META-INF/MANIFEST.MF not fo
2014-06-28 18:51:18.509:INFO:/:Initializing Spring FrameworkServlet ‘dispatcher’

2014-06-28 18:51:20.037:WARN:oejsh.RequestLogHandler:!RequestLog
2014-06-28 18:51:20.218:INFO:oejs.AbstractConnector:Started SelectChannelConnect
[INFO] Started Jetty Server