A Mule application which uses the Jboss TX transaction manager needs a persistent Object Store to hold the objects and states of the transactions being processed (further information about different object stores can be found in the following page). By default Mule uses the ShadowNoFileLockStorem, which uses the file system to store the objects.
As one can guess, if an application does not have permission to write the object store to the file system, the Jboss Transaction Manager will not be able to work properly and will throw an exception similar to the following:
Since the object store is not created, the XA Transaction Manager is not initialised properly. This will throw a ‘Could not initialize class’ exception whenever the transaction manager is invoked.
Mule computes the default directory where to write the object store as follows : muleInternalDir = config.getWorkingDirectory(); (see the code for further analysis). If Mule is started from a directory where the user does not have write permissions, the problems mentioned above will be faced.
The easiest way to fix this issue is to make sure that the user running Mule as full write permission to the working directory. If that cannot be achieved, fear not, there is a solution.
On first analysis, one would be tempted to set the Object Store Directory by using Spring properties as follows :
Unfortunately this will not work since the Jboss Transaction Manager is a Singleton and this property is used in the constructor of the object. Hence a behaviour similar to the following will be experienced:
(Please note that “PutObjectStoreDirHere” is the default directory assigned by the JBoss TX transaction manager).
One way to go around this issue is to be sure that these properties are set before the object is initialised. There are at least two ways to be sure that this is achieved:
- Set the properties on start up as follows
- Set the properties in the wrapper.config as follows (x is the next number available in the wrapper.config by default this is 4)
Otherwise, take the easiest route and make sure that Mule can write to the start up directory.
This post first published on: http://ricston.com/blog