Whenever I try to save a byte[] to a file using XADisk I get an XASystemNoMoreAvailableException:
org.xadisk.filesystem.exceptions.XASystemNoMoreAvailableException: The XADisk instance has encoutered a critial issue and is no more available. Such a condition is very rare. If you think you have setup everything right for XADisk to work, please consider discussing in XADisk forums, or raising a bug with details
My code is as basic as I can tell based on the examples...
public static void main(String[] args) throws Exception
{
StandaloneFileSystemConfiguration configuration = new StandaloneFileSystemConfiguration("xadiskFolder", "1");
XAFileSystem XAF = XAFileSystemProxy.bootNativeXAFileSystem(configuration);
XAF.waitForBootup(-1);
Session session = XAF.createSessionForLocalTransaction();
byte[] myByteArray = getByteArrayFromSomewhere();
File myFile = new File("outputFile.test");
session.createFile(myFile, false);
XAFileOutputStream output = session.createXAFileOutputStream(myFile, true);
output.write(myByteArray);
output.close();
session.commit();
}
Stupid mistake!!
This exception can result if you call
before you try to write/read to a file. In my actual code I had try/catch/finally with the finally block containing the code the to shutdown xadisk instead of in the catch. Don't ask me why. In any case, because the xadisk was already shutdown it resulted in an error.
What I would recommend to the folks at xadisk if it's at all possible, is to improve the exception in an update. Basically something saying the engine is not running or has already been shutdown. Yes it was my fault, but it would be great to also have a better exception message too.