Java.lang.NullPointerException javax.xml.parsers.DocumentBuilder.parse

Hi all,
i have a problem by solving an error in my code. The Code is mainly from Ian Darwin.
The code i am running works with j2sdk1.4.2_04. But now i have to bring it to work with jdk1.6.0_13.
The code parses xml documents. With small xml documents the code works. With large xml documents i get the following error while running the produced class file.
Exception in thread "main" java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.setChunkIndex(DeferredDocumentImpl.java:1944)
at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.appendChild(DeferredDocumentImpl.java:644)
at com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser.characters(AbstractDOMParser.java:1191)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.characters(XMLDTDValidator.java:862)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:463)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)
at XParse.parse(XParse.java:38)
at XParse$JFileChooserrv.<init>(XParse.java:119)
at XParse.main(XParse.java:213)
I know what a java.lang.NullPointerException mens. But i don't know where i have to look for. Specially i don't know what or where "com.sun.org.apache...." is.
Is there a package that a have to add to the environment? Can some one tell my where i can find this package?
I wrote the code for some years ago, 2006 or so. With the knew jdk1.6.0_13 some thinks chance in the environment. Couldn't find what exactly.
The code has only 215 lines, but some how i can't add it to this Message, because Maximum allowed is only 7500.
Is there an other Forum, which may is better for my question?

Here is the code:
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.Container;
import javax.swing.JTextArea;
* This code is mainly from @author Ian Darwin, [email protected]
public class XParse {
     /** Convert the file */
     public static void parse(File file, boolean validate) {
          try {
               System.err.println("");
               String fileName = file.getAbsolutePath();
               System.err.println("Parsing " + fileName + "...");
               // Make the document a URL so relative DTD works.
               //String uri = new File(fileName).getAbsolutePath();
               //System.err.println(uri);
               DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
               if (validate)
               f.setValidating(true);
               DocumentBuilder p = f.newDocumentBuilder();
               p.setErrorHandler(new MyErrorHandler(System.err));
               //XmlDocument doc = XmlDocument.createXMLDocument(file);
               boolean vaild =  p.isValidating();
               if (vaild) {
                    System.out.println("yes parsing");
                    Document doc = p.parse(file); // <<<< ERROR
               System.out.println("Parsed OK");
          } catch (SAXParseException ex) {
               System.err.println("+================================+");
               System.err.println("|       *SAX Parse Error*        |");
               System.err.println("+================================+");
               System.err.println(ex.toString());
               System.err.println("At line " + ex.getLineNumber());
               System.err.println("+================================+");
          } /**catch (RuntimeException ex) {
               System.err.println("+================================+");
               System.err.println("|       *SAX Parse Error*        |");
               System.err.println("+================================+");
               System.err.println(ex.toString());
               //System.err.println("At line " + ex.getLineNumber());
               //System.err.println("At line " + ex.getMessage());
               System.err.println("+================================+");
          }**/ catch (SAXException ex) {
               System.err.println("+================================+");
               System.err.println("|          *SAX Error*           |");
               System.err.println("+================================+");
               System.err.println(ex.toString());
               System.err.println("+================================+");
          /*}} catch (SAXNotRecognizedException  ex) {
               System.err.println(" no SAX");*/
          } catch (ParserConfigurationException ex) {
               System.err.println(" ???");
           } catch (IOException ex) {
               System.err.println("+================================+");
               System.err.println("|           *XML Error*          |");
               System.err.println("+================================+");
               System.err.println(ex.toString());
private static class JFileChooserrv {
     JFileChooserrv(JFrame f, boolean vverabreiten) {
          String openfile;
          String verror;
          boolean validate = true;
          final JFrame frame = f;
          String vFilename = "Z:\\Boorberg\\parsen_vista\\daten";
          //String vFilename = "C:\\";
          File vFile = new File(vFilename);
          final JFileChooser chooser = new JFileChooser(vFile);
          JFileFilter filter = new JFileFilter();
          filter.addType("xml");
          filter.addType("sgml");
          filter.addType("html");
          filter.addType("java");
          filter.setDescription("strukturfiles");
          chooser.addChoosableFileFilter(filter);
          boolean vjeas = true;
          chooser.setMultiSelectionEnabled(vjeas);
          int returnVal = chooser.showOpenDialog(frame);
          if (returnVal == JFileChooser.APPROVE_OPTION) {
               //Array  filearry[] = chooser.getSelectedFiles();
               //if (vFile = chooser.getSelectedFiles()) {
               //File  file[] = chooser.getSelectedFiles();
               File  vfile[] = chooser.getSelectedFiles();
               //String openfile = new String();
               int vlenght = vfile.length;
               if (vlenght>1) {
                    int x=0;
                    while (x< vlenght) {
                              parse(vfile[x], validate);
                              x = x +1;
               if (vlenght<=1) {
                    File v2file = chooser.getSelectedFile();
                         parse(v2file, validate);
          } else {
               System.out.println("You did not choose a filesystem           object.");
     System.exit(0);
private static class JFileFilter extends javax.swing.filechooser.FileFilter {
     protected String description, vnew;
     protected ArrayList<String> exts = new ArrayList<String>();
     protected boolean vtrue;
     public void addType(String s) {
          exts.add(s);
     /** Return true if the given file is accepted by this filter. */
     public boolean accept(File f) {
          // Little trick: if you don't do this, only directory names
          // ending in one of the extentions appear in the window.
          if (f.isDirectory()) {
               return true;
          } else if (f.isFile()) {
               Iterator it = exts.iterator();
               while (it.hasNext()) {
                    if (f.getName().endsWith((String)it.next()))
                         return true;
          // A file that didn't match, or a weirdo (e.g. UNIX device file?).
          return false;
     /** Set the printable description of this filter. */
     public void setDescription(String s) {
          description = s;
     /** Return the printable description of this filter. */
     public String getDescription() {
          return description;
private static class MyErrorHandler implements ErrorHandler {
        // Error handler output goes here
        private PrintStream out;
        MyErrorHandler(PrintStream out) {
            this.out = out;
         * Returns a string describing parse exception details
        private String getParseExceptionInfo(SAXParseException spe) {
            String systemId = spe.getSystemId();
            if (systemId == null) {
                systemId = "null";
            String info = "URI=" + systemId +
                " Line=" + spe.getLineNumber() +
                ": " + spe.getMessage();
            return info;
        // The following methods are standard SAX ErrorHandler methods.
        // See SAX documentation for more info.
        public void warning(SAXParseException spe) throws SAXException {
               //System.exit(0);
            //out.println("Warning: " + getParseExceptionInfo(spe));
        public void error(SAXParseException spe) throws SAXException {
               //System.exit(0);
            String message = "Error: " + getParseExceptionInfo(spe);
            throw new SAXException(message);
        public void fatalError(SAXParseException spe) throws SAXException {
               //System.exit(0);
            String message = "Fatal Error: " + getParseExceptionInfo(spe);
            throw new SAXException(message);
     public static void main(String[] av) {
          JFrame vframe = new JFrame("chose files to pars");
          boolean vverabreiten = true;
          boolean validate = true;
          JFileChooserrv vdateienwaehlen = new JFileChooserrv(vframe, vverabreiten);
}The Stack Trace i posted in the last Message. But i couldn't read it, i am not a programmer.

Similar Messages

  • URGENT:  javax.xml.parsers.DocumentBuilder.parse() method issue

    Hi folks,
    I have an urgent parsing problem. I developed an app with JDK1.4 and now it needs to run on JDK1.3.1. The problem is this:
    If I use the DocumentBuilder.parse() method shipped with JDK1.4 it will parse a document containing namespaces WITHOUT a namespace declaration in the root element. However, since XML support doesn't ship with JDK1.3.1 I need to use JAXP. If I try this with the DocumentBuilder.parse() version shipped with JAXP (latest version) the parse method throws a NullPointerException. If I put the namespace declaration in the document it will parse fine. I tried setting the DocumentBuilderFactory.setNamespaceAware() explicitly to false (should be the default) but no luck. Any ideas other than adding the declaration (long story why I don't want it there...)
    thanks

    example, with declaration of namespace:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root xmlns:inn="http://blablabla/inn/version/1.0/">
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    example, without declaration:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root>
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    this may help...

  • Javax.xml.parsers.SAXParser parser() error

    Hi,
    I've got some code that works fine in the Forte for Java IDE but just will not work when running as a stand-alone Windows application. I think it's to do with the filename having spaces in the pathname?
    Any help would be great!
    Regards.
    Gary Revell
    [email protected]
    [email protected]
    I've attached the code and the error(s) I get
    ------------------CODE FRAGMENT------------------
    // loadCE.java
    // Created on 25 April 2001, 15:43
    // @author RevellG
    // @version V1.0
    // This class is used to load the Standard Call Reporting XML document
    // and to allow the easy interrogation of the contents. The data can
    // then be used to populate fields in the Call Reporting GUI.
    import java.util.Vector;
    import java.io.*;
    import java.util.*;
    import java.util.Collections;
    import org.xml.sax.*;
    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    public class loadCallElement extends Object
    private static loadCall loadCall = null;
    private static boolean DEBUG = false;
    // Creates new loadCE
    public loadCallElement(boolean debugFlag )
    this.DEBUG = debugFlag;
    public void parseDoc( String docName ) throws Throwable
    // Use the default (non-validating) parser
    SAXParserFactory factory = null;
    try
    // Parse the input
    factory = SAXParserFactory.newInstance();
    SAXParser saxParser = factory.newSAXParser();
    loadCall = new loadCall(DEBUG);
    saxParser.parse( new File( docName ), loadCall );
    catch (Throwable t)
    // catch ( Exception t )
    System.err.println( t.getMessage() +" - <"+docName+">");
    t.printStackTrace ();
    loadCall.ceTree.clear();
    throw t;
    ------------------Error and Stack Trace---------------
    E:\Support\Call Logs\bin>java -classpath .\SCM_GUI.jar;%CLASSPATH%;%XML_HOME%\jaxp.jar;%XML_HOME%\parser.jar M
    anagerInterface > g.g
    CWD /Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: 550 /Telecom/Support/Call Logs/Logs/
    Open/BBC PICS/001$revellg$qwerty.xml: The system cannot find the path specified.
    - <\\Reoclu1\Telecom\Support\Call Logs\Logs\Open\BBC PICS\001$revellg$qwerty.xml>
    java.io.FileNotFoundException: CWD /Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: 550 /
    Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: The system cannot find the path specified
    at sun.net.ftp.FtpClient.readReply(Unknown Source)
    at sun.net.ftp.FtpClient.issueCommand(Unknown Source)
    at sun.net.ftp.FtpClient.issueCommandCheck(Unknown Source)
    at sun.net.ftp.FtpClient.cd(Unknown Source)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
    at java.net.URL.openStream(Unknown Source)
    at com.sun.xml.parser.InputEntity.init(InputEntity.java:141)
    at com.sun.xml.parser.Parser.parseInternal(Parser.java:463)
    at com.sun.xml.parser.Parser.parse(Parser.java:284)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:126)
    at loadCallElement.parseDoc(loadCallElement.java:52)
    at SCMView.create(SCMView.java, Compiled Code)
    at EventController$5.actionPerformed(EventController.java:116)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    Thanks Jim,
    I've installed JDK V1.3.1 and the problem HAS gone away..... However now JDK V1.3.1 won't install on other Win 2K machines.....
    Gary.

  • Java.lang.NoClassDefFoundError: javax/xml/rpc/soap/SOAPFaultException

    I have created webservice client using jwsdp-2.0 + JDK 1.5
    in Netbeans 4.1 IDE it
    works perfectly in the netbeans and also works at the command prompt but when i
    create a Jar file from the netbeans and run at the command prompt with following
    i have included all the jar files from the jwsdp-2.0 pack in the manifest file and have
    also specified the main class
    java -jar test.jar it gives following error
    java.lang.NoClassDefFoundError: javax/xml/rpc/soap/SOAPFaultException

    You need the JAX-RPC classes in your class path.

  • Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/soap/S

    Hi,
    I have created a class JaxmClient.java. When I compile the class with appropriate jar files assigned to -classpath it compiles successfully with no errors. But when I run the classe "java JaxmClient" it produces the following exception:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/soap/SOAPElement
    Can someone help me I am knew to this technology.
    Thanks in advance

    I tried to use in my execution all the jar files that I used for compilation.
    java -cp jaxm-jar; etc.jar Request
    but it still gives me this execption
    Exception in thread "main" java.lang.NoClassDefFoundError: Request
    I am in the right directory where is the Request.class file is and it is present in this directory....
    Thanks appreciate your help...

  • Jaxb with weblogic -- java.lang.NoClassDefFoundError: javax/xml/bind/MarshallableRootElement

    I am trying to use jaxb with Weblogic 6.1. I kept both the jaxb jar file in weblogic
    classpath in setEnv script. I am getting the following error, when I am trying
    to use jaxb
    java.lang.NoClassDefFoundError: javax/xml/bind/MarshallableRootElement
    I tried other options also like coping both jar file in jre/ext dir but then I
    got security error.
    I will appreciate if someone in this newsgroup comments or suugest some solution.
    Thanks
    Jeewan

    On 06 Aug 2002, Jeewan wrote:
    >
    I am trying to use jaxb with Weblogic 6.1. I kept both the jaxb jar
    file in weblogic classpath in setEnv script. I am getting the
    following error, when I am trying to use jaxb
    java.lang.NoClassDefFoundError: javax/xml/bind/MarshallableRootElement
    I tried other options also like coping both jar file in jre/ext dir
    but then I got security error.
    I will appreciate if someone in this newsgroup comments or suugest
    some solution. Put the jaxb jar file in in your webapp's WEB-INF/lib directory and it
    should work fine.
    Barry

  • Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream

    I am trying to develop a web service client for amazon webservice.but i am getting this error while running the app. Can anyone please help me. I have installed the JWSDP and but could not understand why i have to locate all the jar files in the classpath?Please help.
    ===== error=========================================
    C:\abr\classes>java -classpath c:\abr\test.jar;C:\abr\jaxrpc-api.jar;C:\abr\jaxrpc-impl.jar;C:\abr\jaxrpc-spi.jar;c:\abr\classes\amazon.jar;C:\abr\mail.jar;C:\a
    br\saaj-api.jar;C:\abr\activation.jar;c:\abr\FastInfoset.jar;%classpath% Client
    [b]Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream/XMLS
    treamWriter
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.sun.xml.rpc.client.StreamingSender._writeRequest(StreamingSender.
    java:672)
    at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:87)
    at amazon.AmazonSearchPort_Stub.authorSearchRequest(AmazonSearchPort_Stu
    b.java:988)
    at Client.main(Client.java:21)

    I'm assuming you're using JWSDP 1.6 as I see Fastinfoset.jar in your list. You are missing some jar files in your classpath there. The best way to know what you need is to look at the release notes for JWSDP 1.6. Since you're building a web serivce start with the table in there and lookup JAX-RPC. It'll show you what jar files are needed and what other libraries are needed. Now depending on what you're doing you don't really need all those.
    For sure you're missing jsr173_api.jar which is where I believe that class you need is located. This is in the JWSDP_1_6\sjsxp\lib directory. You will probably need the other jar thats in there too. Best bet is to follow the dependancy chart in the release notes.
    This should get you going.
    Ryan

  • Java.lang.NoClassDefFoundError: javax/xml/rpc/Service

    Hi,
    I have created client stubs for a webservice using axis wsdl2java tool. When I try calling these stubbed methods from JUnit tests, they are working fine but when I try to execute the jar (it is a swing) I get the following exception:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/Service
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
            at com.Gudds.SeCURE.MainUI.<init>(MainUI.java:76)
            at com.Gudds.SeCURE.Main.Start(Main.java:62)
            at org.owasp.webscarab.WebScarab.main(WebScarab.java:34)I have put the jaxrpc.jar in the classpath and I suppose this jar has the java.xml.rpc.service class but I donot understand why it fails while executing the jar but works fine from the eclipse IDe. Plase help me.
    Regrdas,
    Kundan

    1. Build jar file with MAINFEST.MF and Export of Eclipse , which has content:
    suppose in folder:
    c:\client.jar ( client of web service )
    c:\contrib/lib/ axis apis
    Main-Class: com.MainClassName
    Class-Path: contrib\axis\jaxrpc.jar contrib\axis\activation.jar con
    trib\axis\axis.jar contrib\axis\axis.jar contrib\axis\commons-disco
    very.jar contrib\axis\wsdl4j.jar contrib\axis\saaj.jar contrib\axi
    s\soap.jar contrib\axis\commons-logging.jar contrib\axis\log4j.jar
    contrib\axis\mail.jar
    2. build jar with ant: make sure the their are at least one blank between
    values of Class-Path.
              <jar destfile="../Client/client.jar" >
                   <fileset dir="${build.dir}"/>
              <manifest>
              <attribute name="Built-By" value="${user.name}"/>
                   <attribute name="Main-Class" value="com.MainClass"/>
              <attribute name="Class-Path" value=" contrib\axis\jaxrpc.jar contrib\axis\activation.jar .. "/>
              </manifest>
              </jar>
    3. If you haven't pack you class file in jar, create a bat to set CLASSPATH
    exactly to all jars.
    Hope this helps

  • XML error "java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext"

    Hi Experts,
    We are developing a WebDynpro for java application in NWDI for XML File Uploading, we have followed the below given process for that
    1) Created one XSD as per the client table structure.
    2) Developed one java webserver for the XSD file using jwsdp1.6
    3) Copied that generated folder in WebDynpro application
    4) Included all the required JAX-B jars as External jar files
    5) Finally Compiles the application
    When running the application it is throwing the below exception
    500 Internal Server Error   Web Dynpro Container/SAP J2EE Engine/6.40     
    Failed to process request. Please contact your system administrator.
    Error Summary 
    While processing the current request, an exception occured which could not be handled by the application or the framework.
    If the information contained on this page doesn't help you to find and correct the cause of the problem, please contact your system administrator. To facilitate analysis of the problem, keep a copy of this error page. Hint: Most browsers allow to select all content, copy it and then paste it into an empty document (e.g. email or simple text file).
    Root Cause    
    The initial exception that caused the request to fail, was:
    java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
    at com.ae.energy.scm.wdp.InternalXMLFileUpload.<init>(InternalXMLFileUpload.java:403)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    We checked entire application to ensure all the required files included, Could you please give us the cause for this exception and please explain us the solution to resolve it.
    We are very thankful for all the people who can give their support in resolving this issue.
    Thanks in advance,
    Sandeep Bonam

    Hi Sandeep,
    If you are following DC developemnt for your project, then adding the required JAR files as External Jars will not suffice.
    As at deployment, these "External Jars" are not considered.
    You will need to create and External Library project, for incorporating the required jars.
    For creation and use of External Library Project kindly follow Valery's blog:
    /people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro
    Hope it Helps.
    Regards,
    Alka.

  • Javax.xml.parsers.DocumentBuilder to skip invalid XML characters?

    Hi,
    I convert XML files into flat files. In doing so I call the API DocumentBuilder.parse(File f). If the XML file f contains an invalid XML character, the API throws a SAXException.
    My question is: while I know that certain invalid XML chars are not part of the data and therefore can be safely ignored in the conversion, is there a way to tell the API to skip those chars?

    Nope. Compliant XML parsers are required to parse the XML as it is and not to "repair" it in any way. Your best option is not to have badly-formed XML in the first place, so if you are the one generating the XML, you should fix that process. But if you have bozo customers generating it, and you can't make them do it right, then pre-process the XML to drop the bad characters.

  • How can I parser a String with javax.xml.parsers.DocumentBuilder?

    Normally the DocumentBuilder can parse files, InputSource,InputStream or uri. but what if I want to parse an editing String the user created in an EditPane or JTextComponent?

    new InputSource(new StringReader(theString))

  • ParserConfigurationException with javax.xml.parsers.DocumentBuilderFactory

    Like many people, I am trying to just read in the contents of a XML file. My code compiles in WS studio and I publish it to the server. However, I keep getting a ParserConfigurationException when I try to get a DocumentBuilder from the factory. Below is my code:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    try {
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse( new File(XMLFILE) );
    Any idea why?

    The xmlfile is valid and here is the partial stacktrace
    Root Error-1: javax/xml/parsers/ParserConfigurationException
    java.lang.Exception: javax/xml/parsers/ParserConfigurationException
    at Search5F_Results_jsp_5._jspService(_Search_5F_Results_jsp_5.java:206)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:127)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:390)
    at org.apache.jasper.runtime.JspServlet.serviceJspFile
    Do I need to set some system property?

  • NoSuchMethod: javax.xml.parsers.SAXParserFactory.getSchema()

    Hi All,
    In a servlet I have created a SOAPMessage object based on the request received, and when I execute
    message.getSOAPBody I get the message:
    java.lang.NoSuchMethodError: javax.xml.parsers.SAXParserFactory.getSchema()
    I am running tomcat with jdk 1.5 and I am using saaj-api.jar, saaj_imp.jar and Fastinfoset.jar from jwsdp 1.6
    Anyone got any ideas what to do ?
    Kind regards,
    Marco Laponder

    Along with jdk1.4.2, Sun has bundled a currently ancient version of JAXP.
    So, get a recent version of a JAXP implementation (e.g. with JWSDP1.6), probably contained in jar-files called jaxp-api.jar, dom.jar, sax.jar, xalan.jar and xercesImpl.jar, and add these to your classpath when you're compiling/running.
    You're not done yet! Because the old jaxp libraries are bundled with your JVM, the classloader will find them through your bootclasspath, and they will be prefered above the new implementation you just added to the classpath. To resolve this, the JVM creators came up with the endorsed mechanism. This allows you to provide new classes for a list of predefined packages. These classes are already included in the jvm distribution, but are foreseen to be updated. See for more information about the endorsed mechanism: http://java.sun.com/j2se/1.4.2/docs/guide/standards/ .
    So to be short, you also have to make the jvm recognise them as endorsed libraries. E.g. by adding them to the <java-home>/lib/endorsed directory or by setting the java.endorsed.dirs property to the directories which include the new jar files.
    Your commandline to run app.class would become: java -Djava.endorsed.dirs=/home/endorsedDir;/anotherDir app

  • Java.lang.NullPointerException no protocol: database.xml

    * In Order To Handle XML Operations
    package edu.yeditepe.cse.util;
    import java.util.*;
    import java.io.File;
    import java.io.IOException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    * @author xx
    public class XMLHandler {
         public final static String ATTRIBUTE           = "value";
         public final static String DOCTYPE_PUBLIC   = "databases";
         public final static String DOCTYPE_SYSTEM   = "database.dtd";
         public final static String ParentElement    = "variable";
         public final static String databaseName          = "databasename";
         public final static String urlName            = "urlname";
         public final static String userName           = "username";
         public final static String passWord           = "password";
         public XMLHandler()
         //     This Function returns the XML File .
         private static Document getDocument(){
                    try {             
                     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                     factory.setIgnoringComments(true);
                     factory.setIgnoringElementContentWhitespace(true);
                     factory.setValidating(true);
                     DocumentBuilder builder = factory.newDocumentBuilder();
                      builder.setErrorHandler(new MyErrorHandler());
                     return builder.parse(new InputSource("database.xml"));
                 } catch (Exception e) {
                     System.out.println(e.getMessage());
              return null;
         //Adds new Element to The database.Xml File.
         public boolean addElement(String databasename , String urlname, String username , String password ){
              Document doc = getDocument();
              Element root = doc.getDocumentElement();
              Element parentElement = (Element)doc.createElement(ParentElement);//Take parent Element. We have to take this parent Element since we will add new Element to this Parent Element.
              Element databaseNameElement = (Element)doc.createElement(databaseName);//Create Name Element To Bind Value of New Element.
              databaseNameElement.setAttribute(ATTRIBUTE , databasename );//set the attribute of this child.
              Element urlnameElement = (Element)doc.createElement(urlName);//Create Name Element To Bind Value of New Element.
              urlnameElement.setAttribute(ATTRIBUTE , urlname );//set the attribute of this child.
              Element usernameElement = (Element)doc.createElement(userName);//Create Value Element To Bind Value of the new Element.
              usernameElement.setAttribute(ATTRIBUTE , username );//set the attribute of this second child.
              Element passwordElement = (Element)doc.createElement(passWord);//Create Value Element To Bind Value of the new Element.
              passwordElement.setAttribute(ATTRIBUTE , password );//set the attribute of this second child.
              //Form New Variable  via appending its name and value child to itself.
              parentElement.appendChild(databaseNameElement);
              parentElement.appendChild(urlnameElement);
              parentElement.appendChild(usernameElement);
              parentElement.appendChild(passwordElement);
              //Add This Variable To The Root Element.
              root.appendChild(parentElement);
              try{          
                   saveDocument(doc);//Save And Close The XML File. Catch any Exception Occured.
                   return true;
              }catch(Exception e){
                   System.out.println("##error: " + e);     
                   e.printStackTrace();
                   return false;
         }//add Element Function.
         //     Save changes of the Document doc.
         private boolean saveDocument(Document doc){
              try{
                Transformer xformer = TransformerFactory.newInstance().newTransformer();
              xformer.setOutputProperty(OutputKeys.INDENT, "yes");//For INDENTED PRINTING OF THE FILE
              xformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-9");//Determining Encoding Type.
              xformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, DOCTYPE_PUBLIC);//PRESERVE ROOT ELEMENT
              xformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, DOCTYPE_SYSTEM);//REFERENCE TO DTD FILE
              Source source = new DOMSource(doc);
              Result result = new StreamResult(new File("database.xml"));
              xformer.transform(source, result);
                return true;
              }catch(TransformerConfigurationException e){
                   System.out.println(e);
              }catch(TransformerException e){
                   System.out.println(e);
              return false;
         }//Save
    package edu.yeditepe.cse.util;
    * @author xx
    public class Deneme {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              XMLHandler xh = new XMLHandler();     
              System.out.println(xh.addElement("dasd","asda","adadad","das"));
    }it gives error in linse "Element root = doc.getDocumentElement();"
    i am using jre 1.5.0_ 09
    xalan-2.7.0.jar
    Error on the console is :
    no protocol: database.xml
    Exception in thread "main" java.lang.NullPointerException
         at edu.yeditepe.cse.util.XMLHandler.addElement(XMLHandler.java:69)
         at edu.yeditepe.cse.util.Deneme.main(Deneme.java:16)
    Problem is related with
    return builder.parse(new InputSource("database.xml"));
    when i am trying to type file:///database.xml instead of database.xml
    it adds some more path therefore it doesn't work
    Any help appreciated..

    It seems that the file you are trying to parse is not in your current working directory. The solution, if that is the problem, would be to specify the full path of the file.

  • Javax.xml.parsers Parser Failes at URGENT..URGENT.

    Hai,
    I am using JAVA PARSER to parse my xml file. My XML file is :
    <QUERY>SELECT * FROM EMP WHERE EMP_DATE > 18/10/2000</QUERY>.
    My Sample Code is:
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.DOMException;
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    fistream = new FileInputStream(fileName);
    document = builder.parse(fistream);
    e=document.getDocumentElement();
    curElm = (Element)nodeList.item(0);
    return_Value =((Text)curElm.getFirstChild()).getData().trim();
    Giving wrong output:
    SELECT * FROM EMP WHERE EMP_DATE
    Activally, I had to get
    SELECT * FROM EMP WHERE EMP_DATE > 18/10/2000.
    I do not know what's went wrong ?
    Please help me. It is very urgent to my project.
    Thanks a lot
    Regards
    Suresh

    hi,
    <, >, &, " and ' are XML control characters and do not belong to the data an XML document reflects. if you want to use these special characters, try a different notation, i.e. < > & " or &apos; as in
    <element>this is an <element> tag</element>
    sincerely, Michael

Maybe you are looking for