Isolating the JBoss package tree from the execution environm
g.tomassoni Sep 8, 2009 7:50 AMHi,
I don't know if this is the right newslist to which report this, so excuse me if it isn't and please address me to the right one.
I'm often installing JBoss with some modification in order to allow for a "tmp", a "log", a "data", a "work", and a further "deploy" directory outside of the package tree. This is to avoid messing the JBoss package tree with my application and its surroundings and lets me "switch" to new JBoss versions quite easily.
In order to accomplish this, I of course set the available JBoss runtime properties (jboss.server.log.dir, jboss.server.data.dir and catalina.base), as well as apply small changes to the "stock" conf:
These small changes are:
1) adding the following lines:
<attribute name="AttributePersistenceManagerConfig"> <data-directory>file://${jboss.server.data.dir}/xmbean-attrs</data-directory> </attribute>
to the AttributePersistenceService mbean defined in jboss-service.xml;
2) adding the url of my external deploy directory to the URLs attribute of URLDeploymentScanner in jboss-service.xml (JBoss 4.x) or as a new uri element to the property applicationURIs in bootstrap/profile.xml (JBoss 5.x).
The first change is needed in order to move the xmbean-attrs directory outside of the "stock" data directory. I think this change should be included in the JBoss distribution, otherwise the jboss.server.data.dir property looses any meaning since you can't even start JBoss. Do you agree with me?
Also, while the xmbean-attrs directory gets automatically created when running the distributed JBoss "as is", the same doesn't happen when a different <data-directory> setting is given: the xmbeans-attrs have to be created in the "new" data dir before running JBoss. Why?
The second change is meant to define a further deploy directory outside of the JBoss package tree. Of course I can't ask for the provisioning of this in the stock package, but I would like to know if I have any way of adding a further deploy uri after JBoss startup, in example through JMX. The basic idea is to let JBoss start and then use JMX or whatever to contact the running JBoss and instruct it to have a look to that furter deploy URL. Is it possible? How?
Please note that all this tweaking also improves security: I run JBoss as the jboss user in the jboss group. After these changes, the ownership of whole jboss file tree can be assigned to user root, the groupship to group jboss and all the files and dirs can be o-rwx,g-w. It works, since the whole package tree becames immutable.
For your reference, this is the diff needed under 5.1.0 for the first change:
diff -rud jboss-5.1.0.GA jboss-5.1.0.GA+datadiropt --- jboss-5.1.0.GA +++ jboss-5.1.0.GA+datadiropt @@ -34,6 +34,10 @@ xmbean-dd="resource:xmdesc/AttributePersistenceService-xmbean.xml"> <!-- the AttributePersistenceService is persistent, itself --> + <attribute name="AttributePersistenceManagerConfig"> + <data-directory>file://${jboss.server.data.dir}/xmbean-attrs</data-directory> + </attribute> + <!-- <attribute name="AttributePersistenceManagerClass">org.jboss.system.pm.XMLAttributePersistenceManager</attribute> <attribute name="AttributePersistenceManagerConfig">
It can easily be backported to other 5.x versions, or even to 4.x ones.
Thank you,
Giampaolo