Rupert Woodman *nix forums beginner
Joined: 21 Jun 2006
Posts: 5
|
Posted: Fri Jun 30, 2006 7:38 pm Post subject:
Newbie BerkeleyDB XML question
|
|
|
I'm having some problems getting started with BerkeleyDB XML and I'd really
appreciate some help or guidance.
I've written a java application which reads some XML from a file and writes
it to a container.
Unfortunately, I have a couple of peoblems.
The first one, is than unless I enable auto-open, it tells me the container
is closed. I've looked at the source and it's failing somewhere in the
native methds which makes it difficult to resolve. This is less of a
problem to me at the minute, tho I note that someone from Sleepycat said
it's a slow way of doing things.
The other problem is more of a show-stopper:
Opening container TestMetadata.dbxml
Container - TestMetadata.dbxml - Node storage container opened.
Opening container TestMetadata.dbxml
Indexer - XML Indexer: Fatal Parse error in document at line, 1, char 23.
Parser message: An exception occurred! Type:UTFDataFormatException,
Message:invalid byte 1 (?) of a 1-byte sequence.
The XML data file is valid (if slightly dull):
<?xml version="1.0" ?>
<metadata>
<test id="1" name="test1">
</test>
<test id="2" name="test2">
</test>
</metadata>
I don't see why this should fail with such an error.
The method I'm using to write the data is as follows:
public boolean write(String strDocKey, String strXmlDoc) throws
XmlException
{
boolean boolRetVal = true;
try {
semWriteAccess.acquire();
openContainer();
// Do write
XmlTransaction xtTrans = xmManager.createTransaction();
XmlUpdateContext xucUpdate =
xmManager.createUpdateContext();
xcContainer.putDocument(xtTrans, strDocKey, strXmlDoc,
xucUpdate);
xtTrans.commit();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
boolRetVal = false;
} finally {
semWriteAccess.release();
}
return boolRetVal;
}
I'm setting up as follows:
Environment envCurrent =
getEnvironment(BERKELEY_TEST_REPOSITORY_HOME);
XmlManagerConfig xmc = new XmlManagerConfig();
xmc.setAllowAutoOpen(true);
xmManager = new XmlManager(envCurrent, xmc);
xmManager.setLogLevel(XmlManager.LEVEL_ALL, true);
xmManager.setLogCategory(XmlManager.CATEGORY_ALL, true);
public Environment getEnvironment(String strBase) throws
FileNotFoundException, DatabaseException
{
File f = new File(strBase);
EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setMaxLocks(10000);
envConf.setMaxLockers(10000);
envConf.setMaxLockObjects(10000);
envConf.setCacheSize(50 * 1024 * 1024);
envConf.setAllowCreate(true);
envConf.setInitializeCache(true);
envConf.setTransactional(true);
envConf.setInitializeLocking(true);
envConf.setInitializeLogging(true);
envConf.setErrorStream(System.err);
Environment myEnv = new Environment(f, envConf);
return myEnv;
}
Any ideas, please let me know - I'm really keen to get this going.
Thanks |
|