Elliotte Rusty Harold wrote:

>Tech Rams wrote:
>> JDK 1.5 has xerces built-in, though under a different
>> package name (com.sun.org.apache.xerces.internal).
>>
>> Look at
>> >http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance()
>> to know how factory implementation is found. The
>> default implementation is the one that comes with JDK
>> 1.5, that is xerces.
>>

>Please don't. SAXParserFactory is a disaster waiting to happen, If you
>use it, you'll only find yourself back here in a week pleading for help
>with undiagnosable bugs. It was designed for SAX1. In 2005 nobody should
>be using SAX1, SAXParser, or SAXParserFactory. Use XMLReader and
>XMLReaderFactory instead.

If SAXParserFactory is to be avoided, then why is it used by the JDK 1.5 API?
In particular, I am wondering about this

java.beans.XMLDecoder.readObject(XMLDecoder.java:201)

Which is currently throwing a ClassCastException due to this code:


  public Object readObject() {
        if (in == null) {
            return null;
        }
        if (handler == null) {
            SAXParserFactory factory = SAXParserFactory.newInstance();

The classCastException is thrown here:

   public static SAXParserFactory newInstance() {
        try {
            return (SAXParserFactory) FactoryFinder.find(
                /* The default property name according to the JAXP spec */
                "javax.xml.parsers.SAXParserFactory",
                /* The fallback implementation class name */
                "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
        } catch (FactoryFinder.ConfigurationError e) {
            throw new FactoryConfigurationError(e.getException(),
                                                e.getMessage());
        }
    }


Why isn't the ClassCastException handled here, or in JAXP?
Is JAXP.readObject also deprecated? What should I use instead?
Is this a known issue with JAXP?

PS: I have Xerces 2.7.1 installed in $JAVA_HOME/lib/endorsed
and I am using JDK 1.5_05

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to