USING JUMPSTART IN JBOSS 6.0.0
These notes apply to JumpStart 5.4.1 onwards.
ContentsPrepare JBoss
Build and deploy JumpStart
Build and deploy and integration test JumpStart
Use JumpStart
How to run integration tests from Eclipse
How to debug the client side
How to debug the server side
Prepare JBoss
These instructions prepare JBoss with the following elements:
Web Server | Business Server | Persistence | Database Server | Logger |
---|---|---|---|---|
Tomcat | JBoss's EJB3 | Hibernate | HSQLDB | Log4j |
(JBoss's default) | (JBoss's default) | (JBoss's default) | (JBoss's default) | (JBoss's default) |
- Start by doing a normal working JBoss 6.0.0 installation...
- To get it, go to JBoss Application Server Downloads, locate 6.0.0.Final and choose the Download link. Choose to download jboss-as-distribution-6.0.0.Final.zip.
- Once downloaded, unzip it. Move it to a suitable location, eg. /devel/jboss-6.0.0.Final.
- Create a jumpstart server:
- Duplicate JBoss's server/default/ directory and name it jumpstart.
- Set JVM options:
- Here are some JVM options to consider:
-Dhibernate.hbm2ddl.auto=update ESSENTIAL for JumpStart initially. Great during development, but
NOT RECOMMENDED IN A PRODUCTION ENVIRONMENT because data can be lost. Tells Hibernate to automatically bring the database structure into line with the app's entity definitions at every restart. See hibernate optional configuration properties.-Dtapestry.production-mode=false Tells the Tapestry ExceptionReport page to display full details of the exception, which is great during development. When set to true (which is the default since T5.0.10), Tapestry's ExceptionReport page will display an abbreviated report so as to avoid disclosing details of your application's internals. See Configuring Tapestry. -Dtapestry.compress-whitespace=false Tells Tapestry not to compress whitespace as it generates a page from a template. Makes the generated page source much easier to read eg. when you tell your browser to display the page source. See Configuring Tapestry. -Xms512m -Xmx512m Recommended. Gives JBoss more memory for its heap, avoiding "out of memory" errors. -XX:MaxNewSize=192m -XX:MaxPermSize=192m Gives JBoss more Perm Gen memory. If you encounter Perm Gen memory errors then consider this or an even higher setting. -Djava.net.preferIPv4Stack=true Might speed up JBoss startup on some Unixes (clustered AIX?) or other operating systems that have IPv6 enabled by default. - You can set them from the command line:
...eg. in Windows:- set JAVA_OPTS=-Dhibernate.hbm2ddl.auto=update -Dtapestry.production-mode=false -Dtapestry.compress-whitespace=false -Xms512m -Xmx512m -XX:MaxNewSize=192m -XX:MaxPermSize=192m
- setenv JAVA_OPTS "-Dhibernate.hbm2ddl.auto=update -Dtapestry.production-mode=false -Dtapestry.compress-whitespace=false -Xms512m -Xmx512m -XX:MaxNewSize=192m -XX:MaxPermSize=192m -Djava.net.preferIPv4Stack=true"
- Or you can modify JBoss's run.conf or properties-service.xml:
- Here are some JVM options to consider:
- Start JBoss, eg.
...in Windows:- cd /devel/jboss-6.0.0.Final/bin
- run.bat -c jumpstart
- cd /devel/jboss-6.0.0.Final/bin
- ./run.sh -c jumpstart
- When you start JBoss you might wish to enable remote access to the web site from other computers:
- Starting with JBoss 4.2.0, remote access is turned off by default (is this still true in JBoss 5?). JBoss does this by binding all its services to localhost (127.0.0.1). A quick way to enable remote access is to bind JBoss to all available network interfaces (0.0.0.0), which is what JBoss used to do.
- To enable remote access, when you start JBoss you specify -Djboss.bind.address=0.0.0.0 as a parameter, eg.
run.bat -c jumpstart -Djboss.bind.address=0.0.0.0
./run.sh -c jumpstart -Djboss.bind.address=0.0.0.0
You cannot specify this in JAVA_OPTS - it won't work. - Security risk: There is a security risk with this setting: it exposes various parts of JBoss including the jmx-console and web-console to remote access. Depending on your needs you may wish to secure the JMX Console and Web Console.
- Clustering is not affected: the clustering address is specified by a different system property,
bind.address, eg.
run.bat -Djboss.bind.address=10.10.10.1 -Dbind.address=10.10.10.2 .
- Enhance Tapestry's classpath resolver: in the JumpStart project's web/src/main/java/jumpstart/web/services/AppModule.java file, ensure the ClasspathURLConverterJBoss60 line is active and the alternatives are not active, like this:
// configuration.add(ClasspathURLConverter.class, new ClasspathURLConverterJBoss5());
configuration.add(ClasspathURLConverter.class, new ClasspathURLConverterJBoss60());
// configuration.add(ClasspathURLConverter.class, new ClasspathURLConverterJBoss61());
- Set the build properties: in the JumpStart project's build.properties file, edit the value of these properties:
- deployment.server.type
- deployment.persistence.descriptor
- deployment.web.descriptor
- deployment.server.dir
Build and deploy JumpStart
Here we use Ant to clean, compile, unit test, package, deploy to the server, and wait for it to load.
The deployed package is jumpstart.ear.
- In Eclipse, drag build.xml to the Ant view and run its target clean-compile-test-package-deploytoserver-checkactive.
- If you get an error about JAVA_HOME, read this. Use a JDK 1.6 tools.jar.
Build and deploy and integration test JumpStart
Here we use Ant to clean, compile, unit test, package, deploy to the server, wait for it to load, and run the business integration test suite.
The deployed package is jumpstart.ear. The tests remotely call the JumpStart business layer services exposed by the server.
- In Eclipse, drag build.xml to the Ant view and run its target clean-compile-test-package-deploytoserver-integrationtest.
- If you get an error about JAVA_HOME, read this. Use a JDK 1.6 tools.jar.
Use JumpStart
Ensure the command line is using Java 1.6: the commands java -version and javac -version must return a variant of 1.6, eg. 1.6.0_26.
If JBoss is not running, start it (as above).
Before you use JumpStart for the first time in a new server, you need to build it, deploy it, and run the integration tests.
Populate the Hypersonic database (HSQLDB) within JBoss with data. JBoss provides a handy way to open the HSQL Database Manager:
- Point your web browser at http://localhost:8080/jmx-console/
- Click on database=localDB,service=Hypersonic
- Find the section labelled startDatabaseManager
- Click on Invoke.
- In a few moments a Java GUI called HSQL Database Manager will start up. Note that it can start only on the machine that JBoss is in. It cannot be used on a "headless" server.
- In Eclipse, locate business/src/test/data/initial_data.sql in the project. Open it.
- Copy and paste its contents into the HSQL Database Manager
- Click on Execute SQL.
How to run integration tests from Eclipse
First, build and deploy JumpStart as described above.
Second, create a User Library over JBoss:
- In Eclipse, choose Window > Preferences > Java > Build Path > User Libraries (or in OS X, choose Eclipse > Preferences > Java > Build Path > User Libraries), and
- Create a new user library called jboss-6.0.0-client-lib, then
- Add JBoss's client/jbossall-client.jar file to the new user library.
|
|
|
- Click Run.
- Watch the results in the JUnit View panel. In the Console View you might see lots of exceptions but that's normal. The JUnit View will tell you quickly whether the tests succeeded or not.
- Problems? Eclipse might not be ready for junit - see Could not create task or type of type: junit.
How to debug the client side
To debug, for example, the client side of the integration tests, use Run > Debug Configurations... instead of Run > Run Configurations....
Eclipse will then stop at breakpoints, display variables, enable single-stepping, etc. in the test suite.
How to debug the server side
To debug any part of JumpStart as it runs in the server you'll need to be running JBoss in debug mode. There are a couple of ways to do it:
- Start JBoss in debug mode
We'll use port 8787 in this explanation, but it's OK to use any free port.
Earlier, we described setting various JVM options. To run JBoss in debug, include these JVM options:
-
-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
-
Listening for transport dt_socket at address: 8787
In Eclipse, right-click on your project and choose Debug As > Debug Configurations... and the Debug Configurations window will appear.
- Right-click on Remote Java Application and choose New.
- Set the Port to 8787.
- Enable Allow termination of remote VM.
- Click on Debug.
JBoss resumes startup, and Eclipse will now stop at breakpoints, display variables, do single-stepping, etc. on any Java in the project.
- Control JBoss server from Eclipse
In Eclipse's Server view, add your JBoss 5.0 server.
You can set the JVM options, as described above, by right-clicking on the server entry and choosing Open > Open launch configuration > Arguments.
You can start the server by right-clicking on the server entry and choosing Start or Debug.