• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.ArrayIndexOutOfBoundException: -1 error while using selectNodeList(contextNode,string)

 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guyz,

we have implemented the XML parsing using the Apache XML API (xalan.jar) in our web application and in the production environment.

Some times when load on the server is heavy we are getting the "ArrayIndexOutOfBoundException -1" error messages during the XML parsing process and this is leading to the severe server problems. The error messages are appeared when huge number of users are accessing the application at the same time and number of instances are accessing the "selectNodeList(contextnode, string)" method of CachedXPathAPI" class.

Upon rigorous investigation I am able to reproduce this error in a sample java program in Eclipse.

I designed the java program very similar to our program in the application and tested it in the ecilipse. To replicate the scenario I implemented multi threading and created 100 threads and accessed the method selectNodeList(contextNode,string) simultaniously.

The error is as below



This error is not reproducible always. similarly in our production environment also we are getting this message when server load is heavy.

My sample program is as below:



The XML file content has this data



The class "com.philips.sc.impulse.util.xml.XMLHelper" is our own proprietery class file

How to solve this problem. Can anybody help us here please...
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me like the CachedXPathAPI object is not thread-safe. Have you tried synchronizing access to it?
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

You are correct. It was mentioned in the CachedXPathAPI class API that :

"Any particular instance of CachedXPathAPI must not be operated upon by multiple threads without synchronization."

The methods of CachedXPathAPI class are not thread safe. By synchronizing the code it worked fine for any number of threads. The execution is always successful

The code should be as below. This is working good




I have to try implementing the same in our production server and let you know the result
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic