Solved

javax.xml.stream.FactoryConfigurationError: Provider  com.bea.xml.stream.MXParserFactory not found

Posted on 2004-11-02
17,646 Views
Last Modified: 2011-08-18
import javax.xml.*;       
import javax.xml.namespace.*;       
import javax.xml.stream.*;       
import javax.xml.stream.events.*;       
import javax.xml.stream.util.*;       

import java.util.*;
import java.io.*;

class StaxExample1
{
      public static void main(String[] args)
                        throws FileNotFoundException, XMLStreamException {
      // Use the reference implementation for the XML input factory
      System.setProperty("javax.xml.stream.XMLInputFactory",
                                  "com.bea.xml.stream.MXParserFactory");
      // Create the XML input factory
      XMLInputFactory factory = XMLInputFactory.newInstance();
      // Create the XML event reader
      FileReader reader = new FileReader(args[0]);
      XMLEventReader r =
         factory.createXMLEventReader(reader);
      // Loop over XML input stream and process events
      while(r.hasNext()) {
         XMLEvent e = (XMLEvent)r.next();
         processEvent(e);
      }
   }
/**
 * Process a single XML event
 * @param e - the event to be processed
 */
  private static void processEvent(XMLEvent e) {
     if (e.isStartElement()) {
        QName qname = ((StartElement) e).getName();
        String namespaceURI = qname.getNamespaceURI();
        String localName = qname.getLocalPart();
        Iterator iter = ((StartElement) e).getAttributes();
        while (iter.hasNext()) {
           Attribute attr = (Attribute) iter.next();
           QName attributeName = attr.getName();
           String attributeValue = attr.getValue();
        }
     }
     if (e.isEndElement()) {
        QName qname = ((EndElement) e).getName();
     }
     if (e.isCharacters()) {
        String text = ((Characters) e).getData();
     }
     if (e.isStartDocument()) {
        String version = ((StartDocument) e).getVersion();
        String encoding = ((StartDocument) e).getCharacterEncodingScheme();
        boolean isStandAlone = ((StartDocument) e).isStandalone();
     }
  }
}



Here is an exception
Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider
com.bea.xml.stream.MXParserFactory not found
        at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
        at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:120)
        at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
        at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
        at StaxExample1.main(StaxExample1.java:22)



Please help me to resolve this problem

Thanks
Sudhakar  
0
Question by:sudhakar_koundinya
    6 Comments
     
    LVL 13

    Accepted Solution

    by:
    is this "com.bea.xml.stream.MXParserFactory" in ur Classpath?
    0
     
    LVL 14

    Author Comment

    by:sudhakar_koundinya
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    it is a jar called xbean.jar, I found this jar on my hard disk
    0
     
    LVL 14

    Author Comment

    by:sudhakar_koundinya
    thanks I am able to resolve the issue

    BTW,

    will you have a glance on this link too

    http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21191121.html#12470383

    0
     
    LVL 14

    Author Comment

    by:sudhakar_koundinya
    I need to have following jars

    http://dist.codehaus.org/stax/jars/

    But I just download wls_stax.jar
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now