@EJB
annotation);
maven-eclipse-plugin
allowing a smooth project integration within eclipse simply by typing mvn eclipse:clean eclipse:eclipse
at
the root of the project. This command creates the eclipse project files (.project
, .classpath
,
etc.).
CommunityBoard | The agregation module: this one agregates the 3 other modules to produce a Java EE ear file containing the 3 other modules. |
CommunityBoard_data | The entity module (data layer). This one is a JPA project which
provides the Java EE entity beans used by the project. This modules is packaged as a java .jar
and defined as a jar module within the agregation ear. |
CommunityBoard_services | The services module (business layer). This modules provides
the various business services used by the CommunityBoard application. This modules is packaged as a java
.jar file on its own and defined as an ejb module within the agregation ear. |
CommunityBoard_presentation | The Web module (presentation layer). This modules provides
the front controller as well as various JSPs used to present the data and provides the user with ways to
manipulate the data. This module is packaged as a java EE .war file on its own and defined as
a web module within the agregation ear. |
pom.xml | The root maven POM file. |
docs | A few files (mostly images) used by this README file. |
<dependency> <groupId>org.apache.derby</groupId> <artifactId>derbyclient</artifactId> <version>10.6.1.0</version> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0-SNAPSHOT</version> <scope>provided</scope> </dependency>
cd
into
the root folder of the project and build the application with the usual maven command :
user@notebook:/data/.../workspace$ mvn clean install [INFO] Scanning for projects... [INFO] Reactor build order: [INFO] Niceideas CommunityBoard project [INFO] Niceideas CommunityBoard - data layer [INFO] Niceideas CommunityBoard - business layer [INFO] Niceideas CommunityBoard - presentation layer [INFO] Niceideas CommunityBoard - Agregate EAR [INFO] ------------------------------------------------------------------------ [INFO] Building Niceideas CommunityBoard project [INFO] task-segment: [clean, install] [INFO] ------------------------------------------------------------------------ ... ... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] ------------------------------------------------------------------------ [INFO] Niceideas CommunityBoard project ...................... SUCCESS [3.103s] [INFO] Niceideas CommunityBoard - data layer ................. SUCCESS [6.652s] [INFO] Niceideas CommunityBoard - business layer ............. SUCCESS [2.206s] [INFO] Niceideas CommunityBoard - presentation layer ......... SUCCESS [4.780s] [INFO] Niceideas CommunityBoard - Agregate EAR ............... SUCCESS [1.459s] [INFO] ------------------------------------------------------------------------ [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 18 seconds [INFO] Finished at: Sun Oct 24 09:47:18 CEST 2010 [INFO] Final Memory: 28M/119M [INFO] ------------------------------------------------------------------------The above is what should be displayed on the console if the build is successful (really there's no reason for it not to be successful). The build ends up with the project
ear
file located at
./CommunityBoard/target/CommunityBoard-1.0-SNAPSHOT.ear
. This is the file we will be deploying within
Glassfish.
$ glassfish/bin/startserv domain2
)
In addition to the glassfish application server, the glassfish embedded derby database server should be started as well.
(Just as a sidenote, the embedded derby is typically started by : $ glassfish/bin/asadmin start-database --dbport 1527
--dbhome glassfish/databases
)
jdbc/CommunityBoardDS
in the JDNI tree is required for the CommunityBoard application to
work properly. Under glassfish the datasource is easily defined through the admin console by using the 2 links under the
Resource/jdbc menu on the left :
CommunityBoardPool
for a Derby database. The type of
the resource is javax.sql.Datasource
:
DatabaseName | : CommunityBoard |
User | : admin |
Password | : whatever |
whatever
above).
Then one should create a new JDBC resource named jdbc/CommunityBoardDS
and using the provided Derby Pool :
CommunityBoard_data/src/main/ddl/create_db.sql
and a little SQL
file containing the test data located at CommunityBoard_data/src/main/ddl/insert_test_data.sql
.
The reader is free to use pretty much any SQL client she is used to. With DBVisualizer for instance, the SQL
statements from the SQL files can be easily executed (only one after the other when using the free version of
the tool though).
CommunityBoard/target/CommunityBoard.ear
One only needs to select the Applications item in the menu on the left and then click on Deploy. http://localhost:8080/CommunityBoard_presentation/controller/login.do
.
The test data insertion script should have created a few users, the first one is
Username | : user1 |
Password | : pwd1 |
Just a few concerns :
@EJB
annotation work from within the servlet or the
JSP pages once I put them and the EJBs in separated projects.