Loading ...
Sorry, an error occurred while loading the content.
 

Linkage exception .... with XML DOM

Expand Messages
  • tsmets@altern.org
    I ve done an program that uses some infos defined in XML files. As I m Trying NOW to make the code bug - free I m writting the Junit test cases for that class.
    Message 1 of 5 , Mar 1, 2001
      I've done an program that uses some infos defined in XML files. As I'm Trying NOW to make the code bug - free I'm writting the Junit test cases for that class. My very first test being to always validate the construction of an instance of the object, After setUp doing simply a super.setUp(), I created a first test that simply creates an instance of the targetted class, doing :
      <pre>
      MyInstance = new ReadXMLwithDOM();
      asssert("Could not instanciate class", MyInstance);
      </pre>

      the problem is finally that it seems that there's a linkage Exception being thrown rather stupidly with the DOM parser does effectively the PARSING.
      <pre>
      factory = DocumentBuilderFactory.newInstance();
      input = new InputSource(new FileReader(aFileName));
      builder = factory.newDocumentBuilder();
      doc = builder.parse(input);
      ER = ExitRule.parseDocument(doc, Log); <--- Line giving the problem
      </pre>

      The ExitRule class has a static method to automatically do the parsing. I've added to my excluded/properties file the following :

      excluded.6=org.xml.*
      excluded.7=org.xml.sax.*
      excluded.8=be.telenet.sacramento.cafe.*
      excluded.9=com.sun.xml.parser.*

      I gess exclusion is recursive (?).

      Still the method fails miserably with a rather long trace that starts with
      java.lang.LinkageError Class org.xml.sax.InputSource violates loader constraints at ...
      ...
      ...
      ...



      Thomas,

      p.s. : Here below the reference found on the current ML

      <pre>
      <snip>
      Subject Author Date
      424 Re: ClassLoader constraints violation Rupert Fri 2/9/2001
      420 Re: ClassLoader constraints violation john prince Fri 2/9/2001
      419 Re: ClassLoader constraints violation Erik Hanson Thu 2/8/2001
      400 ClassLoader constraints violation Rupert Wed 2/7/2001
      </snip>
      </pre>
      ---

      Thomas SMETS - Application Engineer
      Sydney-Tristar Devlopment Cpy
    • Brian Button
      See if starting running junit with the -noloading flag fixes the problem. If it does, then you need to make additional changes to your excluded.properties
      Message 2 of 5 , Mar 1, 2001
        See if starting running junit with the -noloading flag fixes the problem. If
        it does, then you need to make additional changes to your
        excluded.properties file.

        bab

        ----
        Brian Button bbutton@...
        Senior Consultant Object Mentor, Inc.
        St. Louis, MO http://www.objectmentor.com

        > -----Original Message-----
        > From: tsmets@... [mailto:tsmets@...]
        > Sent: Thursday, March 01, 2001 3:39 AM
        > To: junit@yahoogroups.com
        > Subject: [junit] Linkage exception .... with XML DOM
        >
        >
        >
        > I've done an program that uses some infos defined in XML
        > files. As I'm Trying NOW to make the code bug - free I'm
        > writting the Junit test cases for that class. My very first
        > test being to always validate the construction of an instance
        > of the object, After setUp doing simply a super.setUp(), I
        > created a first test that simply creates an instance of the
        > targetted class, doing :
        > <pre>
        > MyInstance = new ReadXMLwithDOM();
        > asssert("Could not instanciate class", MyInstance);
        > </pre>
        >
        > the problem is finally that it seems that there's a linkage
        > Exception being thrown rather stupidly with the DOM parser
        > does effectively the PARSING.
        > <pre>
        > factory = DocumentBuilderFactory.newInstance();
        > input = new InputSource(new FileReader(aFileName));
        > builder = factory.newDocumentBuilder();
        > doc = builder.parse(input);
        > ER = ExitRule.parseDocument(doc, Log); <--- Line giving
        > the problem
        > </pre>
        >
        > The ExitRule class has a static method to automatically do
        > the parsing. I've added to my excluded/properties file the following :
        >
        > excluded.6=org.xml.*
        > excluded.7=org.xml.sax.*
        > excluded.8=be.telenet.sacramento.cafe.*
        > excluded.9=com.sun.xml.parser.*
        >
        > I gess exclusion is recursive (?).
        >
        > Still the method fails miserably with a rather long trace
        > that starts with
        > java.lang.LinkageError Class org.xml.sax.InputSource violates
        > loader constraints at ...
        > ...
        > ...
        > ...
        >
        >
        >
        > Thomas,
        >
        > p.s. : Here below the reference found on the current ML
        >
        > <pre>
        > <snip>
        > Subject Author Date
        > 424 Re: ClassLoader constraints violation Rupert Fri 2/9/2001
        > 420 Re: ClassLoader constraints violation john prince Fri
        > 2/9/2001
        > 419 Re: ClassLoader constraints violation Erik Hanson Thu
        > 2/8/2001
        > 400 ClassLoader constraints violation Rupert Wed 2/7/2001
        > </snip>
        > </pre>
        > ---
        >
        > Thomas SMETS - Application Engineer
        > Sydney-Tristar Devlopment Cpy
        >
        > ------------------------ Yahoo! Groups Sponsor
        > ---------------------~-~>
        > Find software faster. Search more than 20,000
        > software solutions on KnowledgeStorm. Register
        > now and get started.
        > http://us.click.yahoo.com/7u_SwA/zMSCAA/Ig4EAA/N0AVlB/TM
        > --------------------------------------------------------------
        > -------_->
        >
        > To unsubscribe from this group, send an email to:
        > junit-unsubscribe@yahoogroups.com
        >
        >
        > Your use of Yahoo! Groups is subject to
        > http://docs.yahoo.com/info/terms/
        >
        >
        >
      • tsmets@altern.org
        OK, this is what I ve come to with the problem. My command line is now %runner% -cp %cp%;%classes_root%ejb;%classes_root%kernel junit.swingui.TestRunner
        Message 3 of 5 , Mar 1, 2001
          OK,
          this is what I've come to with the problem.
          My command line is now
          %runner% -cp %cp%;%classes_root%ejb;%classes_root%kernel
          junit.swingui.TestRunner -noloading org.xml.* <customer_url>.cafe.%1

          This didn't work but the Exception ended-up with a
          NullPointerException instead of a LinkageException.

          What is weird is the fact that the
          -noloading flag is made availble
          via the excluded.properties file
          but that option didn't have any effect ?

          What I then did is migrate the faulty statement to another method
          (see source code herebelow) ?

          Things seems to work now.
          I however don't get a decent explaination for the second type of call
          to work while the first is not...
          Can someone help ?
          Or, could someone give me a hint over the matter's possible origins ?

          Tx,

          Thomas,



          <code>

          void init()
          throws Exception
          {
          try
          {
          factory = DocumentBuilderFactory.newInstance();
          input = new InputSource(new FileReader(FileName));
          builder = factory.newDocumentBuilder();
          doc = builder.parse(input);
          // ER = ExitRule.parseDocument(doc, null);

          } catch (IOException ioe) {
          ioe.printStackTrace();
          System.exit(EXCEPTION_IN_CONTRUCTOR);
          } catch (SAXException SAXe) {
          SAXe.printStackTrace();
          System.exit(EXCEPTION_IN_CONTRUCTOR);
          } catch (ParserConfigurationException pce) {
          pce.printStackTrace();
          System.exit(EXCEPTION_IN_CONTRUCTOR);
          } catch (Exception e) {
          e.printStackTrace();
          System.exit(EXCEPTION_IN_CONTRUCTOR);
          }
          return;
          }

          /**
          *
          */
          void createExitRule()
          {
          ER = ExitRule.parseDocument(doc, null);
          return;
          }

          </code>



          --- In junit@y..., <tsmets@a...> wrote:
          >
          > I've done an program that uses some infos defined in XML files. As
          I'm Trying NOW to make the code bug - free I'm writting the Junit
          test cases for that class. My very first test being to always
          validate the construction of an instance of the object, After setUp
          doing simply a super.setUp(), I created a first test that simply
          creates an instance of the targetted class, doing :
          > <pre>
          > MyInstance = new ReadXMLwithDOM();
          > asssert("Could not instanciate class", MyInstance);
          > </pre>
          >
          > the problem is finally that it seems that there's a linkage
          Exception being thrown rather stupidly with the DOM parser does
          effectively the PARSING.
          > <pre>
          > factory = DocumentBuilderFactory.newInstance();
          > input = new InputSource(new FileReader(aFileName));
          > builder = factory.newDocumentBuilder();
          > doc = builder.parse(input);
          > ER = ExitRule.parseDocument(doc, Log); <--- Line giving the
          problem
          > </pre>
          >
          > The ExitRule class has a static method to automatically do the
          parsing. I've added to my excluded/properties file the following :
          >
          > excluded.6=org.xml.*
          > excluded.7=org.xml.sax.*
          > excluded.8=be.telenet.sacramento.cafe.*
          > excluded.9=com.sun.xml.parser.*
          >
          > I gess exclusion is recursive (?).
          >
          > Still the method fails miserably with a rather long trace that
          starts with
          > java.lang.LinkageError Class org.xml.sax.InputSource violates
          loader constraints at ...
          > ...
          > ...
          > ...
          >
          >
          >
          > Thomas,
          >
          > p.s. : Here below the reference found on the current ML
          >
          > <pre>
          > <snip>
          > Subject Author Date
          > 424 Re: ClassLoader constraints violation Rupert Fri 2/9/2001
          > 420 Re: ClassLoader constraints violation john prince Fri
          2/9/2001
          > 419 Re: ClassLoader constraints violation Erik Hanson Thu
          2/8/2001
          > 400 ClassLoader constraints violation Rupert Wed 2/7/2001
          > </snip>
          > </pre>
          > ---
          >
          > Thomas SMETS - Application Engineer
          > Sydney-Tristar Devlopment Cpy
        • harmony2@swbell.net
          I just upgraded to 3.5 and I m getting the same error. Code that worked with 3.2 gets the linkage error with 3.5. I m using Xerces 1.2 and the error is
          Message 4 of 5 , Mar 12, 2001
            I just upgraded to 3.5 and I'm getting the same error. Code that
            worked with 3.2 gets the linkage error with 3.5. I'm using Xerces
            1.2 and the error is triggered when I try to load the DocumentBuilder
            class.


            --- In junit@y..., tsmets@a... wrote:
            >
            >
            > OK,
            > this is what I've come to with the problem.
            > My command line is now
            > %runner% -cp %cp%;%classes_root%ejb;%classes_root%kernel
            > junit.swingui.TestRunner -noloading org.xml.* <customer_url>.cafe.%1
            >
            > This didn't work but the Exception ended-up with a
            > NullPointerException instead of a LinkageException.
            >
            > What is weird is the fact that the
            > -noloading flag is made availble
            > via the excluded.properties file
            > but that option didn't have any effect ?
            >
            > What I then did is migrate the faulty statement to another method
            > (see source code herebelow) ?
            >
            > Things seems to work now.
            > I however don't get a decent explaination for the second type of
            call
            > to work while the first is not...
            > Can someone help ?
            > Or, could someone give me a hint over the matter's possible
            origins ?
            >
            > Tx,
            >
            > Thomas,
            >
            >
            >
            > <code>
            >
            > void init()
            > throws Exception
            > {
            > try
            > {
            > factory = DocumentBuilderFactory.newInstance();
            > input = new InputSource(new FileReader(FileName));
            > builder = factory.newDocumentBuilder();
            > doc = builder.parse(input);
            > // ER = ExitRule.parseDocument(doc, null);
            >
            > } catch (IOException ioe) {
            > ioe.printStackTrace();
            > System.exit(EXCEPTION_IN_CONTRUCTOR);
            > } catch (SAXException SAXe) {
            > SAXe.printStackTrace();
            > System.exit(EXCEPTION_IN_CONTRUCTOR);
            > } catch (ParserConfigurationException pce) {
            > pce.printStackTrace();
            > System.exit(EXCEPTION_IN_CONTRUCTOR);
            > } catch (Exception e) {
            > e.printStackTrace();
            > System.exit(EXCEPTION_IN_CONTRUCTOR);
            > }
            > return;
            > }
            >
            > /**
            > *
            > */
            > void createExitRule()
            > {
            > ER = ExitRule.parseDocument(doc, null);
            > return;
            > }
            >
            > </code>
            >
            >
            >
            > --- In junit@y..., <tsmets@a...> wrote:
            > >
            > > I've done an program that uses some infos defined in XML files.
            As
            > I'm Trying NOW to make the code bug - free I'm writting the Junit
            > test cases for that class. My very first test being to always
            > validate the construction of an instance of the object, After setUp
            > doing simply a super.setUp(), I created a first test that simply
            > creates an instance of the targetted class, doing :
            > > <pre>
            > > MyInstance = new ReadXMLwithDOM();
            > > asssert("Could not instanciate class", MyInstance);
            > > </pre>
            > >
            > > the problem is finally that it seems that there's a linkage
            > Exception being thrown rather stupidly with the DOM parser does
            > effectively the PARSING.
            > > <pre>
            > > factory = DocumentBuilderFactory.newInstance();
            > > input = new InputSource(new FileReader(aFileName));
            > > builder = factory.newDocumentBuilder();
            > > doc = builder.parse(input);
            > > ER = ExitRule.parseDocument(doc, Log); <--- Line giving the
            > problem
            > > </pre>
            > >
            > > The ExitRule class has a static method to automatically do the
            > parsing. I've added to my excluded/properties file the following :
            > >
            > > excluded.6=org.xml.*
            > > excluded.7=org.xml.sax.*
            > > excluded.8=be.telenet.sacramento.cafe.*
            > > excluded.9=com.sun.xml.parser.*
            > >
            > > I gess exclusion is recursive (?).
            > >
            > > Still the method fails miserably with a rather long trace that
            > starts with
            > > java.lang.LinkageError Class org.xml.sax.InputSource violates
            > loader constraints at ...
            > > ...
            > > ...
            > > ...
            > >
            > >
            > >
            > > Thomas,
            > >
            > > p.s. : Here below the reference found on the current ML
            > >
            > > <pre>
            > > <snip>
            > > Subject Author Date
            > > 424 Re: ClassLoader constraints violation Rupert Fri 2/9/2001
            > > 420 Re: ClassLoader constraints violation john prince Fri
            > 2/9/2001
            > > 419 Re: ClassLoader constraints violation Erik Hanson Thu
            > 2/8/2001
            > > 400 ClassLoader constraints violation Rupert Wed 2/7/2001
            > > </snip>
            > > </pre>
            > > ---
            > >
            > > Thomas SMETS - Application Engineer
            > > Sydney-Tristar Devlopment Cpy
          • harmony2@swbell.net
            ... DocumentBuilder ... More info: Using -noloading helped, but now it fails with this error: java.lang.AbstractMethodError at
            Message 5 of 5 , Mar 12, 2001
              --- In junit@y..., harmony2@s... wrote:
              > I just upgraded to 3.5 and I'm getting the same error. Code that
              > worked with 3.2 gets the linkage error with 3.5. I'm using Xerces
              > 1.2 and the error is triggered when I try to load the
              DocumentBuilder
              > class.

              More info: Using -noloading helped, but now it fails with this error:

              java.lang.AbstractMethodError
              at junit.framework.TestResult.addFailure(TestResult.java:46)
              at junit.framework.TestResult.runProtected
              (TestResult.java:120)
              at junit.framework.TestResult.run(TestResult.java:103)
              at junit.framework.TestCase.run(TestCase.java:120)
              at junit.framework.TestSuite.run(TestSuite.java:144)
              at junit.framework.TestSuite.run(TestSuite.java:144)
              at junit.swingui.TestRunner$18.run(TestRunner.java:634)

              Looks like 3.5 needs more testing.
            Your message has been successfully submitted and would be delivered to recipients shortly.