PermaLink Automating AppFuse on JBoss02/02/2005
I decided to refactor the AppFuse build process so you can swap between JBoss and Tomcat easily.  I can now happily do "ant setup-appserver" and "ant deploy" on JBoss and switch back to Tomcat by changing a single line in the build.xml for my AppFuse generated application

The Wiki notes on the AppFuse site for setting up JBoss were somewhat helpful, but nothing helps as much as a step-by-step, so I wrote one up below. First, I have to cover the changes I made to AppFuse's build process and files that need to be changed.

At the bottom of build.properties, add
jboss.home=c:/jboss4 (or wherever you have installed JBoss 4)
jboss.instance=default (or whatever instance you are using in JBoss: minimal or all)

Modifications to build.xml:
- extracted Tomcat-specific targets into a separate tomcat.xml file
- renamed "setup-tomcat" target to "setup-appserver" so it can be named the same in all appserver Ant files
- renamed "start.tomcat" target to "start.appserver" for the same reason
- broke out tomcat-specific metadata copying in package-web task into a "copy-metadata" task
- moved the targets: setup-appserver, start.appserver, deploy, undeploy, refresh, copy-metadata into tomcat.xml
- added <import> tag into build.xml to include either tomcat.xml or jboss.xml (comment out one or the other)
- added a property to test for JBoss's run.jar and then set the property named "jboss"
- added copy-metadata for JBoss to copy jboss-web.xml.

The build.xml file should still be refactored so that the <isset> tests are no longer needed; these can be done in appserver-specific tasks in the tomcat.xml and jboss.xml files. The only thing left is the Canoo unit tests.

The jboss-web.xml and appfuse-ds.xml files go into a jboss subdirectory in the main appfuse directory. I also put the login-config.xml file in that directory, but it's only there as an example of what you have to copy into JBoss' config file with the same name.
Note that I used PostgreSQL instead of MySQL. When you run "setup-appserver", the appfuse-ds.xml file will be copied into server/<instance>/conf so JBoss will deploy it. The jboss-web.xml file will be copied into WEB-INF by the copy-metadata task.

I was hoping that login-config.xml could be placed in the WEB-INF directory and JBoss could be configured to automatically pick the application-policy up when you deploy the war file, but you can't do this. You have to manually take the application-policy from this file and put it near the end of your server/<instance>/conf/login-config.xml file. Anyone know how to automate this using Ant so it can be added to the setup-appserver task? I googled for it and looked in JBoss' forums w/ no luck.

Once you get all these files into the right place, the step-by-step is as follows:
- verify that your data source names are correct (make sure you replace appfuse w/ your app name)
- edit JBoss' login-config.xml as described above
- edit build.properties to specify your JBoss home directory and instance
- edit build.xml to <import> the correct appserver file
- run "ant setup-appserver" to copy the JDBC driver and data source config to the right place
- run "ant deploy" to generate the war file and copy it into JBoss' deploy directory
- start JBoss4 and make sure it starts up cleanly
- try logging in to make sure JBoss can access the appfuse database (if it croaks, you didn't set up login-config.xml properly or you didn't name the data source consistently)

Todo:
- take out any more Tomcat dependencies in build.xml
- get Canoo unit tests working on JBoss

The changed/new files can be found here.

Comments :v

1. Mark Thien02/27/2006 10:29:14


how to deploy appfuse 1.9 to JBoss 4.0.3 ?
Can update your post here for deploying appfuse 1.9 to JBoss 4.0.3 ?
Thanks !




2. Matt Raible02/02/2005 14:04:44
Homepage: http://raibledesigns.com


This is good stuff Ken! Any chance you have the modified files (i.e. build.xml, tomcat.xml) available? I've updated the wiki with a link to this post.

http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseOnJBoss




Start Pages
RSS News Feed RSS Comments Feed CoComment Integrated
The BlogRoll
Calendar
December 2024
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Search
Contact Me
About Ken
Full-stack developer (consultant) working with .Net, Java, Android, Javascript (jQuery, Meteor.js, AngularJS), Lotus Domino