This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I've posted this in the xml forum, because I'm having trouble with some xml/xmlbeans, but I'm not convinced it's not a classloader issue.
I'm using an xml file as a simple data store for a web app I'm writing. I'm deploying the webapp including a default xml file for start up, but add, edit and delete operations throught we webapp will be modifying the xml file that gets exploded out of the .war file.
to load the file from what I thought would be the file system. As you might be able to detect I've been having problems where, saving the file updates the file on the file system (I can see it update in my IDE), but the next time I load the file, my updates don't appear. I'm wondering whether getResourceAsStream is returning me a reference to the file in the .war, rather than the exploded and updated one on the filesystem.
The only thing that makes me think otherwise, is that if I restart tomcat, the application loads the updated version of the file. It's like the reference to the file is cached - obviously without me intending it to be.
Does anyone recognise the symptoms? Can anyone suggest any approaches for identifying whether the problem is in the loading or in the parsing?
To start with you could use the "getResource()" method to return you a URL. That would at least answer your question about just where the resource is being loaded from.
Joined: Nov 09, 2004
Thanks Paul, that was a good tip. Unfortunately, it threw my theory out the window. Checking the URL in the way you suggested proves that I'm parsing the updated file from the filesystem everytime I access it.
That leaves the question of why the
call doesn't seem to get the up-to-date contents of the file.
I've got a work around, but it's a bit that it doesn't work as expected.
I don't know, if you were passing a URL to the parse() method I could see the possibility that it was caching the XML it read from that URL. (In some places, like for example in XSLT's document() function, it's actually mandatory for software to cache XML.) But caching the contents read from an InputStream seems more improbable to me. However I don't know much about XMLBeans, maybe you're doing something that requires caching.