xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Ebert" <ceb...@pocketthis.com>
Subject RE: Class Cast Exception
Date Mon, 04 Nov 2002 19:20:15 GMT

	Hi Rob,

	You can use a ClassLoader to figure out where your classes are coming from:


	private static String buildClassURL(Class c)
	{
		if (c.getClassLoader() != null) {
			return c.getClassLoader().getResource(buildClassName(c)).getFile();
		} else {
			return ClassLoader.getSystemResource(buildClassName(c)).getFile();
		}
	}

	
	private static String buildClassName(Class c)
	{
		return c.getName().replace('.', '/') + ".class";
	}

	This is from a class I use to figure this out -- take an instance of an XML parser or some
other object that's giving you grief and get the path from it's class loader. 


	HTH 

	Chris


-----Original Message-----
From: Rob Outar [mailto:routar@ideorlando.org]
Sent: Monday, October 28, 2002 1:24 PM
To: xerces-j-user@xml.apache.org
Subject: RE: Class Cast Exception


I am beginning to think you are right, but I cannot find which jar file has
it... will keep trying, thanks again/

Rob


-----Original Message-----
From: neilg@ca.ibm.com [mailto:neilg@ca.ibm.com]
Sent: Monday, October 28, 2002 4:05 PM
To: xerces-j-user@xml.apache.org
Subject: RE: Class Cast Exception


Hi Rob,

Well, Xerces releases have existed where
org.apache.xerces.parsers.SAXParser didn't implement XMLReader.  They're
*really* old, and I can't imagine how you'd run into one, but I wonder if
it's possible that you've got some kind of strange situation where,
somehow, the first class by this name which Xerces class-loading strategy
encounters is from an  ancient xerces?

Anyway, your code works happily on my machine--IBM JDK 1.3.1, no custom
class loaders of any kind.

Cheers,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  neilg@ca.ibm.com




|---------+---------------------------->
|         |           "Rob Outar"      |
|         |           <routar@ideorland|
|         |           o.org>           |
|         |                            |
|         |           10/28/2002 03:39 |
|         |           PM               |
|         |           Please respond to|
|         |           xerces-j-user    |
|         |                            |
|---------+---------------------------->

>---------------------------------------------------------------------------
------------------------------------------------------------------|
  |
|
  |       To:       <xerces-j-user@xml.apache.org>, "Rishi Khanna"
<rishi@rishikhanna.com>
|
  |       cc:
|
  |       Subject:  RE: Class Cast Exception
|
  |
|
  |
|

>---------------------------------------------------------------------------
------------------------------------------------------------------|



Additional info, exception states:

SAX2 driver class org.apache.xerces.parsers.SAXParser does not implement
XMLReader

which makes no sense.

Thanks,

Rob
 -----Original Message-----
From: Rishi Khanna [mailto:rishi@rishikhanna.com]
Sent: Monday, October 28, 2002 3:22 PM
To: xerces-j-user@xml.apache.org
Subject: Re: Class Cast Exception

      I haven't implemented this with XMLReaderFactory, but if you're
      willing to try, you can load the class with the following code:

      XMLReader parser = (XMLReader) Class.forName
      ("org.apache.xerces.parsers.SAXParser").newInstance();


      ----- Original Message -----
       From: Rob Outar
       To: xerces-j-user@xml.apache.org
       Sent: Monday, October 28, 2002 3:13 PM
       Subject: Class Cast Exception

       I am trying to upgrade to  Xerces 2, we are trying something very
       trivial but it will not work:

       import org.apache.xerces.parsers.SAXParser;
       import org.xml.sax.XMLReader;
       import org.xml.sax.helpers.XMLReaderFactory;


       /**
        * @testcase net.onesaf.services.data.xml.sax.TestSAX
        */
       public class SAX {


           public SAX(){
               try {
                   System.out.println("In here");
               XMLReader parser = XMLReaderFactory.createXMLReader(
            "org.apache.xerces.parsers.SAXParser");
          System.out.println("out here");
               }
               catch(Exception e){
          System.out.print(e);
               }
           }

       but we keep getting a ClassCastException
       In here

       java.lang.ClassCastException

       What are we doing wrong?

       Thanks,

       Rob



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Mime
View raw message