problem with SAXParserFactory.newInstance() !

X

Xavier Seneque

hi everybody !

i'm making a little program to parse an xml stream, and learn how it works,
but i have some troubles with it...

i first looked on the sun.com site :

http://developers.sun.com/sw/building/codesamples/sax/index.html

i did lots of cut&past, changed a little, it compiles, but while running,
it miserably fails :)

[java] Provider
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl not found
[java] javax.xml.parsers.FactoryConfigurationError: Provider
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl not found
[java] at
javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:113)
[java] at sheepim.servrep.ClientHandler.create(Unknown Source)
[java] at sheepim.servrep.ClientHandler.run(Unknown Source)
[java] java.lang.NullPointerException
[java] at sheepim.servrep.ClientHandler.parse(Unknown Source)
[java] at sheepim.servrep.ClientHandler.run(Unknown Source)

if i have understood the error, it's because my jre can't create a
SAXParserFactory object with the static method newInstance() ...

@see :
http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance()

their is my create method :
private void create() {
try {
// Obtain a new instance of a SAXParserFactory.
SAXParserFactory factory = SAXParserFactory.newInstance();
// Specifies that the parser produced by this code will
provide support for XML namespaces.
factory.setNamespaceAware(true);
// Specifies that the parser produced by this code will
validate documents as they are parsed.
factory.setValidating(true);
// Creates a new instance of a SAXParser using the
currently configured factory parameters.
saxParser = factory.newSAXParser();
}
catch( FactoryConfigurationError e ){
System.err.println(e.getMessage());
System.err.println();
e.printStackTrace();
}
catch (Throwable t) {
System.err.println("Erreur dans la creation du parseur SAX");
t.printStackTrace();
}
}

so it's just a cut & paste from sun.com... so it shouldnt come from their !

after looking on the api documentation, it seems that in order for newInstance()
to work, the javax.xml.parsers.SAXParserFactory property must be properly
configured... but how ? and what do i put in it .

or i can also configur the lib/jaxp.properties file in the jre,
but same problem, what do i put it in ?

info on my box :
java -version
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

javac -version
javac 1.5.0_01

debian linux 2.6.8

thanks in advance for everyone having the patience to give some
interest in my problem !
xs
 
J

John C. Bollinger

Xavier said:
i'm making a little program to parse an xml stream, and learn how it works,
but i have some troubles with it...

i first looked on the sun.com site :

http://developers.sun.com/sw/building/codesamples/sax/index.html

i did lots of cut&past, changed a little, it compiles, but while running,
it miserably fails :)

[java] Provider
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl not found
[java] javax.xml.parsers.FactoryConfigurationError: Provider
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl not found
[java] at
javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:113)
[java] at sheepim.servrep.ClientHandler.create(Unknown Source)
[java] at sheepim.servrep.ClientHandler.run(Unknown Source)
[java] java.lang.NullPointerException
[java] at sheepim.servrep.ClientHandler.parse(Unknown Source)
[java] at sheepim.servrep.ClientHandler.run(Unknown Source)

Your Java configuration is broken. I don't know whether it came broken
out of the box, or whether you have done something to break it. One
possibility is that you managed to perform an incomplete upgrade from
1.4.x to 1.5.0. If you have both versions of Java installed in parallel
then it may just be that your JAVA_HOME environment variable needs to
point to the correct directory for the Java version you are actually using.
 
X

Xavier Seneque

John said:
Xavier said:
i'm making a little program to parse an xml stream, and learn how it
works,
but i have some troubles with it...

i first looked on the sun.com site :

http://developers.sun.com/sw/building/codesamples/sax/index.html

i did lots of cut&past, changed a little, it compiles, but while running,
it miserably fails :)

[java] Provider
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl not found
[java] javax.xml.parsers.FactoryConfigurationError: Provider
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl not found
[java] at
javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:113)
[java] at sheepim.servrep.ClientHandler.create(Unknown Source)
[java] at sheepim.servrep.ClientHandler.run(Unknown Source)
[java] java.lang.NullPointerException
[java] at sheepim.servrep.ClientHandler.parse(Unknown Source)
[java] at sheepim.servrep.ClientHandler.run(Unknown Source)


Your Java configuration is broken. I don't know whether it came broken
out of the box, or whether you have done something to break it. One
possibility is that you managed to perform an incomplete upgrade from
1.4.x to 1.5.0. If you have both versions of Java installed in parallel
then it may just be that your JAVA_HOME environment variable needs to
point to the correct directory for the Java version you are actually using.


well i did no upgrade, i install the 1.5.0_01 version with the file from
the sun site.. and this is the only version i hava...

echo $JAVA_HOME
/opt/java

ls -l $JAVA_HOME
lrwxr-xr-x 1 root root 12 2005-01-25 00:40 /opt/java -> jdk1.5.0_01/


echo $PATH
/home/xavier/Mes_Applications:/opt/jwsdp-1.5/apache-ant/bin:/opt/jwsdp-1.5/jwsdp-shared/bin:/opt/java/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
# for java web services, i tried to install this thinking it could help
me... :)

which java
/opt/java/bin/java

which javac
/opt/java/bin/javac

so those are the good ones !

i don't see ... you think i should download the jdk again and try it ?

thanks
xs
 
X

Xavier Seneque

damn found it...

just had ton include /usr/share/java/xercesImpl.jar in the CLASSPATH...
that is so lame :)

thanks anyway !
xs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top