learntechnology.netsimplifying information technology |
learntechnology-maven-jee source code Introduction
I wasn't having much luck finding a good simple example application that uses JPA, EJB3, and Maven2,
so I figured I'd create a simple skeleton application
that hopefully others will find useful. This blog entry http://famvdploeg.com/blog/?p=41
along with the Better Builds With Maven pdf (just google it) got me started. (I'm still new to Maven so I'm not sure I'm doing everything correct, so those with more experience please let me know
if there are modifications I should make.)
Setup and Running The Demo On JBoss
The final ear that is generated should run in most application servers. You might have to add a speicfic xxx-web.xml file for your particular
server in the web module and if your underlying ORM framework is not hibernate, you'll need to modify the persistence.xml in the
ejb module. This tutorial will describe the setup using JBoss5, but it shouldn't take much to have it working in Glassfish, OC4J, etc
NOTE ABOUT TESTING: mvn install will run the simple unit test. It also uses a log4j.properties file in test/resources and will output a log file ejb-jar-testing.log inside the lt-ejb module root. The test results will show up in lt-ear/target/surefire-reports. If you want to generate a nicer report, type mvn surefire-report:report from the command line. This will generate an html report called surefire-report.html under lt-ejb/target/site directory. (Running mvn site should generate that file as well, including a larger more complete report. See mvn docs for more info.) The Project Structure
Here is how the project structure is laid out:
Basic: ![]() Expanded: ![]() The pom.xml files
project parent pom.xml
4.0.0
net.learntechnology
learntechnology-maven-jee
1.0
pom
Sample Maven2 JEE Project
lt-ejb-jar
lt-web
lt-ear
maven2-repository.dev.java.net
Java.net Repository for Maven
http://download.java.net/maven/2/
default
org.apache.maven.plugins
maven-compiler-plugin
1.5
1.5
false
test.log
debug
true
log4j
log4j
1.2.13
provided
commons-collections
commons-collections
3.2
true
commons-lang
commons-lang
2.3
true
commons-logging
commons-logging
1.1.1
true
javax.ejb
ejb-api
3.0
provided
javax.persistence
persistence-api
1.0
provided
org.testng
testng
5.8
test
jdk15
ear pom.xml
4.0.0
net.learntechnology
learntechnology-maven-jee
1.0
net.learntechnology
lt-ear
1.0
ear
learntechnology-maven-jee :: lt-ear
learntechnology-maven-jee-${pom.version}
maven-ear-plugin
true
commons-collections
commons-collections
true
commons-logging
commons-logging
true
commons-lang
commons-lang
true
net.learntechnology
lt-ejb-jar
net.learntechnology
lt-web
/lt-web
codehaus snapshot repository
http://snapshots.repository.codehaus.org/
true
commons-collections
commons-collections
3.2
provided
commons-lang
commons-lang
2.3
provided
commons-logging
commons-logging
1.1.1
provided
net.learntechnology
lt-ejb-jar
ejb
1.0-SNAPSHOT
|