You can compile and deploy all the labs without writting a single line of code
by using ANT and the build.xml scripts provided!
This is what you need to do:
|
Setting the env. variables
|
- SET JAVA_HOME=/opt/j2sdk1.4.1_01 (or whatever path or jdk you have)
- SET PATH=$PATH:/opt/j2sdk1.4.1_01/bin
- Open a DOS console or a Xterm, and cd into the ZeLabs/_tools/jboss-3.2.3/bin folder.
- Then type run.bat on Windows or ./run.sh on UNIX-like systems
You should see:
|
Compiling and deploying the 6-SessionBean-Standalone lab
|
- cd into ZeLabs/6-SessionBean-Standalone/eclipse/sessionbean/build
- Type ../../../../_tools/apache-ant-1.6.0/bin/ant -f build.xml, and you should see:
....
deploy:
[echo] Deploying in jBoss ...
[copy] Copying 1 file to C:\J2EE\ZeLabs\_tools\jboss-3.2.3\server\default\deploy
all:
BUILD SUCCESSFUL
And in the jBoss console:
....
12:38:19,453 INFO [Engine] StandardManager[/webejb]: Seeding random number generator class java.security.SecureRandom
12:38:19,453 INFO [Engine] StandardManager[/webejb]: Seeding of random number generator has been completed
12:38:19,453 INFO [Engine] StandardWrapper[/webejb:default]: Loading container servlet default
12:38:19,453 INFO [Engine] StandardWrapper[/webejb:invoker]: Loading container servlet invoker
12:38:19,656 INFO [EARDeployer] Started J2EE application: file:/C:/J2EE/ZeLabs/_tools/jboss-3.2.3/server/default/deploy/Cart.ear
12:38:19,656 INFO [MainDeployer] Deployed package: file:/C:/J2EE/ZeLabs/_tools/jboss-3.2.3/server/default/deploy/Cart.ear
|
Running the standalone client
|
- Type ../../../../_tools/apache-ant-1.6.0/bin/ant -f build.xml run-client, and you should see:
C:\J2EE\ZeLabs\6-SessionBean-Standalone\eclipse\sessionbean\build>..\..\..\..\_tools\apache-ant-1.6.0\bin\ant -f build.xml run-client
Buildfile: build.xml
run-client:
[java] Got initial context: javax.naming.InitialContext@12d15a9
[java] Got CartHome: org.jyperion.sample.sessionbean.CartBeanHome
[java] Livre numero 1: Apres l'Empire
[java] Livre numero 2: L'Illusion economique
[java] Livre numero 3: Le langage silencieux
[java] Livre numero 4: Hyperion
BUILD SUCCESSFUL
Total time: 1 second
And in the jBoss console:
12:43:07,734 ERROR [STDERR] setSessionContext org.jboss.ejb.StatefulSessionEnterpriseContext$StatefulSessionContextImpl@1abcd9b
12:43:07,750 ERROR [STDERR] ejbCreate()
12:43:07,796 ERROR [STDERR] Adding book Apres l'Empire
12:43:07,812 ERROR [STDERR] Adding book L'Illusion economique
12:43:07,812 ERROR [STDERR] Adding book Le langage silencieux
12:43:07,812 ERROR [STDERR] Adding book Hyperion
12:43:07,812 ERROR [STDERR] Returning list... 4 elements!
12:43:07,828 ERROR [STDERR] ejbRemove()
|
Compiling, Deploying, Running from Eclipse
|
Using Eclipse, create a new Java Project for the lab SessionBean standalone:
We need to use ANT from Eclipse.
Go to Window -> Show View -> Other, then pick-up Ant and click on OK:
Then click on the small 'lamp' icon in the ANT panel:
You should see a Search for Buildfiles window. Click on Search
Then, you should see the found build.xml files targets in the ANT panel:
You just have to double-click on the all[default] target to compile and deploy the EAR file
into jBoss:
, and double-click on run-client to run the client!
Voila!
The best way to understand J2EE is still to practise it.
Even though you do not need to write a line of code, there is an exercise to do
at the end of each lab.
For each exercise, you must:
- Create a new Java project
- Import the needed libraries (mainly jboss-j2ee.jar and javax.servlet.jar in jboss/server/default/lib) for the server code
- Use jbossall-client.jar to execute the client (in jboss/client)
- Create the needed modules: ear-module, ejb-module, client-module, web-module
- Develop the EJB code using XDoclet tags
- Create the build.xml script used by ANT
You can obviously glance at the existing code to give you an idea on how to do things.
Bonne chance!