File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xmlbeans caching document during parse?

 
Andy Westley
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

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.

For neatness I've been using the code

MyUtitlityClass.class.getResourceAsStream("/my_data_file.xml")

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?

Cheers
aw
 
Paul Clapham
Sheriff
Pie
Posts: 20184
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Andy Westley
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

XDocument.Factory.parse(myInputStream)

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.

Cheers
aw
 
Paul Clapham
Sheriff
Pie
Posts: 20184
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic