[jdom-interest] Problem with Beta 7 and WebLogic 6.1

Daniel Hoppe hoppe at sitewaerts.de
Thu Aug 16 09:20:20 PDT 2001


Hi all,

I'm experiencing a problem when combining JDom Beta 7 and the WebLogic 6.1
application server. I'm including a piece of sample code so that someone
could maybe point out if this is likely to be

- a problem in my code
- a problem in WebLogic 6.1
- a problem in JDom Beta 7

I am trying to build a Document with a SAXBuilder with a JAXP configured SAX
parser. WebLogic provides an own SAXParserFactory which can dispatch to
different parsers depending on the dtd or the root element. In my code I'm
doing something like this :

      SAXBuilder saxb = new SAXBuilder();
      Document doc = saxb.build(new StringReader(sAnXMLDocument));

This works fine. But if I use the same instance of SAXBuilder - I did not
find any remarks that this should be avoided - to build a second XML
document, e.g.

      SAXBuilder saxb = new SAXBuilder();
      Document doc1 = saxb.build(new StringReader(sAnXMLDocument));
      Document doc2 = saxb.build(new StringReader(sAnotherXMLDocument));

I get the following exception:

org.jdom.JDOMException: 
	Error in building: SAX2 driver class
weblogic.xml.jaxp.RegistryXMLReader loaded but cannot be instantiated 
		(no empty public constructor?) 	
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:306) 	
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:650) 	
	at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.thisDoesNotWork(JDOMvsWL61.java:
57) 	
	at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.main(JDOMvsWL61.java:73) 
Root cause: 
java.lang.InstantiationException: weblogic.xml.jaxp.RegistryXMLReader 	
	at
org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:1
24) 	
	at org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:360) 	
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:283) 	
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:650) 	
	at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.thisDoesNotWork(JDOMvsWL61.java:
57) 	
	at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.main(JDOMvsWL61.java:73) 

I had a look at SAXBuilder and found that the classname of the
saxDriverClass is being cached. If the classname has been formerly cached,
createParser calls     

	parser = XMLReaderFactory.createXMLReader(saxDriverClass);

which in fact expects an empty public constructor. The class
weblogic.xml.jaxp.RegistryXMLReader does not have any public constructors,
it seems that it needs to be obtained from the SAXParser instance which
comes from the factory. I'm in fact no SAX/JAXP-adept, so I don't have a
clue if 
- WebLogic is doing something wrong
- JDom is relying on the behaviour of the default parser of it's core
developers which is most probably Xerces.

If someone could please point out where the problem lies and - if it's a
WebLogic problem - which specification (I know there is none for SAX...) is
not observed - that would help me a lot. If it's a WebLogic problem I'll
open a support case with BEA and - if there is interest on this topic - keep
you up-to-date with any progress.

Thanks for your support!

Cheerios,

Daniel


In case someone is using WebLogic 6.1 and wants to reproduce this problem:

- Put jdom.jar and weblogic.jar into the classpath
- Run the following class:

package de.sitewaerts.futuna.reproducers;

import java.io.StringReader;

import org.jdom.*;
import org.jdom.input.*;

public class JDOMvsWL61
{
  String sAnXMLDocument = "<?xml
version=\"1.0\"?><testroot><testelement>testcontent</testelement></testroot>
";

  public JDOMvsWL61()
  {
  }

  public void thisWorksFine()
  {
    System.out.println("\nthisWorksFine():");
    try
    {
      SAXBuilder saxb = new SAXBuilder();
      System.out.print("First attempt to parse: ");
      Document doc = saxb.build(new StringReader(sAnXMLDocument));
      System.out.println("alright!");
      saxb = new SAXBuilder();
      System.out.print("Second attempt to parse: ");
      doc = saxb.build(new StringReader(sAnXMLDocument));
      System.out.println("alright!");
    }
    catch (JDOMException jde)
    {
      System.out.println("error!");
      jde.printStackTrace();
    }
  }

  public void thisDoesNotWork()
  {
    System.out.println("\nthisDoesNotWork():");
    try
    {
      SAXBuilder saxb = new SAXBuilder();
      System.out.print("First attempt to parse: ");
      Document doc = saxb.build(new StringReader(sAnXMLDocument));
      System.out.println("alright!");
      // No new SAXBuilder this time, reuse the old one.
      System.out.print("Second attempt to parse: ");
      doc = saxb.build(new StringReader(sAnXMLDocument));
      System.out.println("alright!");
    }
    catch (JDOMException jde)
    {
      System.out.println("error!");
      jde.printStackTrace();
    }  }

  public static void main(String [] sa)
  {
    System.setProperty("javax.xml.transform.TransformerFactory",
"weblogic.xml.jaxp.RegistrySAXTransformerFactory");
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"weblogic.xml.jaxp.RegistryDocumentBuilderFactory");
    System.setProperty("javax.xml.parsers.SAXParserFactory",
"weblogic.xml.jaxp.RegistrySAXParserFactory");
    JDOMvsWL61 rep = new JDOMvsWL61();
    rep.thisWorksFine();
    rep.thisDoesNotWork();
  }
}


<<<<<<<<<<<<<<<<<<<<<<<<<<<
sitewaerts GmbH
Hebelstraße 15
D-76133 Karlsruhe

Tel: +49 (721) 920 918 0
Fax: +49 (721) 920 918 29
http://www.sitewaerts.de
>>>>>>>>>>>>>>>>>>>>>>>>>>>





More information about the jdom-interest mailing list