• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassCastException

 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
java.lang.ExceptionInInitializerError: java.lang.ClassCastException: org.apache.crimson.jaxp.SAXParserFactoryImpl
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at org.apache.axis.utils.XMLUtils.initSAXFactory(XMLUtils.java:212)
at org.apache.axis.utils.XMLUtils.<clinit>(XMLUtils.java:113)

Frequently I'm getting this error when i try to run my XML application(Reading XML using DOM and give back result in string).
I'm using ServletExec with IIS 5.0. In my webapps lib folder i have latest version of xerces.jar, in the lib directroy of my ServletExec
i have crimson and jaxp jars.
Is that the reason ??
Please note that i can't delete crimson and jaxp jars.
These are the imports i use in my java file.
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;

Please help me to solve this problem.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are your settings in jaxp.properties file? Make sure the names of the class and property are spelt correctly and are fully qualified with package name etc.
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajith Kallambella:
What are your settings in jaxp.properties file? Make sure the names of the class and property are spelt correctly and are fully qualified with package name etc.


Hi Ajith,
I searched for that file in harddisk but there is no such file.Am I missing some basics here ??
Is thata file that i shd creat and put it under webapps ? if so where i can find more info on that.
thanks for replying.
Regards
Balaji
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you are missing a key point. JAXP requires you to set certain values( as properties ) that it queries at runtime to figureout where the parser is, and what kind of parser it is. This is how JAXP allows a seamless and standardized parser access that is implementation independent.
The properties can be statically defined in jaxp.properties or could be done in the program.
SAX Parser example

DOM Parser example

I suggest that you read the JAXP FAQ by Sun and all the links from that page to get a better understanding.
Cheers,
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajith Kallambella:
Yes, you are missing a key point. JAXP requires you to set certain values( as properties ) that it queries at runtime to figureout where the parser is, and what kind of parser it is.


Thats really a helpful reply.
God!. I'm really missing many basics on xml Parsing.
I started reading them now.
Thanks a lot Ajith.
Regards
Balaji
 
reply
    Bookmark Topic Watch Topic
  • New Topic