Contents
Generate Maven Archetype List
mvn archetype:generate > mvn_types.txt
Ctrl C
Y
* Search for trinidad20
208: remote -> org.apache.myfaces.buildtools:myfaces-archetype-trinidad20 (Archetype to create a new webapp based on Trinidad and JSF 2.0)
Generate myfaces-archetype-trinidad20
mvn archetype:generate Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 192: 208 Choose org.apache.myfaces.buildtools:myfaces-archetype-trinidad20 version: 1: 1.0.2 2: 1.0.4 Choose a number: 2: Define value for property 'groupId': : test.mvn.trinidad20 Define value for property 'artifactId': : demoapp Define value for property 'version': 1.0-SNAPSHOT: 1.0.0 Define value for property 'package': test.mvn.trinidad20: Confirm properties configuration: groupId: test.mvn.trinidad20 artifactId: demoapp version: 1.0.0 package: test.mvn.trinidad20 Y:
Modify pom.xml
* Change dependency scope from provided to runtime except for junit.
* Add
<dependency> <groupId>org.apache.myfaces.core</groupId> <artifactId>myfaces-impl</artifactId> <version>${jsf-myfaces.version}</version> <scope>runtime</scope> </dependency>
Generate Eclipse Project
mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0
* From Eclipse,
– Select File > Import… > Existing Projects into Workspace
– Browse to demoapp directory
– Click Finish
* Modify faces-config.xml and change
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
to
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
* Add to web.xml
<!-- Listener --> <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener>
* Add weblogic.xml to src/main/webapp/WEB-INF directory if deploying to WebLogic
<?xml version="1.0" encoding="UTF-8"?> <wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.2/weblogic-web-app.xsd"> <wls:weblogic-version>10.3.5</wls:weblogic-version> <wls:context-root>demoapp</wls:context-root> <wls:container-descriptor> <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes> </wls:container-descriptor> </wls:weblogic-web-app>
* Create a new folder src/main/resources to hold property files such as log4j.properties and application.properties
* Create a new folder src/main/resources/META-INF to hold beans.xml or persistence.xml files if applicable
* Add src/main/resources folder to build path
Deploy and Test
* Deploy to Tomcat or WebLogic
* Point browser to http://locahost:8080/demoapp