• Post Reply Bookmark Topic Watch Topic
  • New Topic

org.xml.sax.SAXException: FWK005 parse may not be called while parsing  RSS feed

 
sanjeev c mehra
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Sometimes I do  get error org.xml.sax.SAXException: FWK005 parse may not be called while parsing

Existing code, had following at Class level (static instances of XPath)



I have updated and removed these instances and started creating with in method call (local level), but still I am getting same error some time?
Any suggestion would be much appreciated... thanks...

 
sanjeev c mehra
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it mandatory to have a synchronization utility operation to parse for each request / call ?

Shouldn't local XPath object be enough?
 
sanjeev c mehra
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions please?
 
sanjeev c mehra
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any suggestion to avoid following?

 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patience is a virtue. Please don't bump threads after just a few hours.
Content minimized. Click to view
 
g tsuji
Ranch Hand
Posts: 697
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of focusing on this line:
org.xml.sax.SAXException: FWK005 parse may not be called while parsing.

you should look rather trying to locate the possible xpath expression(s) leading to XPathExpressionException:
Caused by: javax.xml.xpath.XPathExpressionException
    at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:298)
 
sanjeev c mehra
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
g tsuji wrote:Instead of focusing on this line:
org.xml.sax.SAXException: FWK005 parse may not be called while parsing.

you should look rather trying to locate the possible xpath expression(s) leading to XPathExpressionException:
Caused by: javax.xml.xpath.XPathExpressionException
    at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:298)



Thanks for your reply. But I had to enforce all requests in sequence :(

Existing code,

Was getting errors.


I updated to following ,




I was still getting error, finally I had to change it to following, which I resisted as it puts all request in sequence, but I am not aware of other option,




No more errors.
 
g tsuji
Ranch Hand
Posts: 697
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you posted above means you're completely mystifying the subject matter...

In the supposedly original block, InputStream should not be the argument for the evaluate() method, should it? Furthermore, modulo all kinds of typos to your favor, when you use InputStream you shouldn't trying to re-use it once you hand it to parse method implicitly or explicitly as the InputStream would then have been closed out "as part of the end-of-parse cleanup" (quote documentation of InputSource). Hence as I see re-use all over, I wouldn't be surprised it won't work one point or another... What you should do is to make a persistent copy in the memory such as a byte array or even a Document by parsing it if prefer, from the InputStream and reuse the byte array or Document again and again feeding to XPath's evaluate()...

In the supposedly block made work, again, you are freely placing InputStream to InputSource etc... I don't see how things could work that way, but you say it work. Hence, I cannot comment.

Also, "request in sequence"? You meant getY must follow getX not before, getZ must follow getY not before,... or something of the kind? Where do you want to demonstrate this is the case from what you show? I don't see the meaning with that kind of free use of Inputstream vs InputStream, and InputSource, so again, I cannot comment.
 
sanjeev c mehra
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
g tsuji you are absolutely correct that I messed-up in last post. Thank you for your time and mentioning about my stupidity. I typed things in hurry, not an excuse and accept my mistake.

Original

error org.xml.sax.SAXException: FWK005 parse may not be called while parsing


changed to following, but continue to get error - org.xml.sax.SAXException: FWK005 parse may not be called while parsing


No errors with following

 
g tsuji
Ranch Hand
Posts: 697
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The XPathFactory class is not thread-safe. So if you've a multi-threaded application, move the instantiation of them (the factory and the xpath) to the class(es) implementing Runnable or extending Thread and eliminate their static access, you should be safe as you've each time newInstance() etc and the scope will be limited to the thread. If you insist on the private/public static access, it is the coder's responsibility "to ensure that at most one thread is using a XPathFactory object at any given moment." (to quote the documentation).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!