Solved

Wierd EmptyStackException from SAX

Posted on 2002-05-07
8
422 Views
Last Modified: 2013-11-23
Hello,

I have written a class which utilizes the SAX api in JDK 1.4 in order to parse XML files. When running a small TesterUtility which I wrote to test it through the IDE everything works fine, however when running from the command line I kept on getting a java.util.EmptyStackException thrown somwhere within org.apache.crimson.Parser2.java.

Since generally such problems come from  a bad classpath, I added:
System.out.println(System.getProperty("java.class.path"));
in the begginning of the tester, and then began checking dir by dir which one was lacking.

After a while I found the when placing one of Fortes modules ('wasp-advanced.jar') in the classpath solved the problem and allowed the program to run from the command line as well. Now this is odd for two reasons:

a) I have absolutley no dependencies on wasp-advanced.jar, as does the SAX api. I have verified this by running a verbose output

b) The exception thrown was a java.util.EmptyStackException - which is a runtime exception, not a class not found exception, or any other exception one would expect to find when the VM doesn't find a class.

Unfortunatley the problem was not solved by simply adding the module into the classpath. I also need this to run under Tomcat, and placing the aforementioned module into Tomcats 'lib' directory does not help, and I still receive the same error.

So just to sum it all up:
a) The program worked fine under the IDE

b) Did not work under console until a single jar, wasp-advanced.jar, one of Forte's modules, was placed into the classpath. There are no dependencies on the jar file *verified* by running verbose output.

c) Adding this module into tomcat lib directory does not help, and the same EmptyStackException is still thrown, as if running from command prompt without correct classpath.

If anybody has any insight as to the origin of this error and/or suggestions for a solution they would be very much appreciated.
0
Comment
Question by:Solfire
8 Comments
 
LVL 7

Expert Comment

by:yoren
Comment Utility
Maybe there is a SAX parser in wasp-advanced.jar that you're using instead of Crimson when it's in your path.

How are you instantiating the parser? Try adding a line to see what parser you're using. Assuming you have a line like:

[XMLReader reader = ....]

Add:
System.out.println("Parser: "
  + reader.getClass().getName());

As far as the EmptyStackException, that's not a classpath issue but rather an error parsing your document. It might be a bug in Crimson, and adding wasp-advanced.jar might be fixing it by using a different parser altogether.
0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
another option - try recompiling your project with command line javac.
0
 

Author Comment

by:Solfire
Comment Utility
voren:
Well, I have already verified by using verbose output that nothing is being loaded from wasp-advanced.jar (everything comes from rt.jar, as is expected). The check you suggested returns the same result. Also, wouldn't the interpreter report any ambigous classes in it's classpath? i.e. when attempting to load classes with same name?

heyhey:
Unfortunatley by the time I read your message I had already rewritten the class to use a different XML package (namely EXML, www.themindelectric.com) which works fine. When I get home and a backup copy is available I will try a command line compile.
0
 

Author Comment

by:Solfire
Comment Utility
voren:
Well, I have already verified by using verbose output that nothing is being loaded from wasp-advanced.jar (everything comes from rt.jar, as is expected). The check you suggested returns the same result. Also, wouldn't the interpreter report any ambigous classes in it's classpath? i.e. when attempting to load classes with same name?

heyhey:
Unfortunatley by the time I read your message I had already rewritten the class to use a different XML package (namely EXML, www.themindelectric.com) which works fine. When I get home and a backup copy is available I will try a command line compile.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 7

Expert Comment

by:yoren
Comment Utility
Solfire,

I have worked quite a bit with Crimson and have never encountered an XML file that gives an EmptyStackException. Can you post or email (yuval@bluecast.com) the file?

Regarding the ambiguous class question, the class names for the parsers are not the same. If you're using XMLReaderFactory or JAXP to instantiate the parser, it uses a system property (org.xml.sax.driver) or service identitifer (META-INF/services/javax.xml.parsers/SAXParserFactory) to determine which class to load.

0
 
LVL 7

Expert Comment

by:yoren
Comment Utility
Ignore that last comment. You specifically said the class name was Crimson. In this case, you've got one of the following:

- corrupt bytecode (fixed as heyhey said)
- a corrupt JDK (would need to reinstall)
- an actual bug in Crimson
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- To be PAQ'ed and points NOT refunded

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0
 

Accepted Solution

by:
PashaMod earned 0 total points
Comment Utility
Per Recommendation,

PashaMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now