Contents of META-INF/services/javax.xml.parsers.DocumentBuilderFactory?
I am currently working on an applet that solves Sudoku puzzles, allowing you to build your own in a Constructor and then solve them in a seperate Solver. To do this, we are implementing the puzzles files as XML documents.
I have the code completely complied and on the server ( [sudoku.unl.edu|sudoku.unl.edu]) and it runs NEARLY perfectly, however when trying to access the server to save the xml code, the apache error_log presents this message: "File does not exist: classes/META-INF/services
/javax.xml.parsers.DocumentBuilderFactory"
Looking at the Java Doc here it says that the program should look for that in the jars. I am unsure of exactly how the applet is interacting with the server, but typing "java -version" yields:
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b16, mixed mode)Notably, the code works PERFECTLY in NetBeans, contacting the server using SCP and uploading the file and such, so the code doesn't seem to be the problem, unless I need to direct the DocumentBuilder code somehow. This is the code that I believe is causing the trouble (I have tried to include all relevant imports that are in my code):
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
DocumentBuilderFactory factoryBuilder;
DocumentBuilder builder;
Document doc;
Element docElement;
try
factoryBuilder = DocumentBuilderFactory.newInstance( );
builder = factoryBuilder.newDocumentBuilder();
doc = builder.parse( indexLocation );
docElement = doc.getDocumentElement();
NodeList children = docElement.getChildNodes();
for(int i =0; i < children.getLength(); i++)
if(children.item(i).getNodeType() == 1)
if((children.item(i).getNodeName()).equals("directory"))
if ((children.item(i).getAttributes().getNamedItem("name").getNodeValue()).equals("UsersInput")) {
Node firstChild = findNodeItem(children.item(i), "Difficulty0.." + this.upperField.getText());
Node secondChild = findNodeItem(firstChild, "Level" + this.levelField.getText());
Node thirdChild = findNodeItem(secondChild, (String)suTypeList.getSelectedItem());
Element newFile = doc.createElement("file");
newFile.setAttribute("name", fileName);
thirdChild.appendChild(newFile);
SshParameters params = new SshParameters("cse.unl.edu", "consystlab","A/tutti");
// create new Scp instance
Scp scp = new Scp(params);
// register event listener
scp.addListener(this);
// establish connection
scp.connect();
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StringWriter sw=new StringWriter();
StreamResult result = new StreamResult(sw);
transformer.transform(source, result);
String xmlString=sw.toString();
// upload file
scp.upload(xmlString.getBytes(), indexPath, "libraryIndex.xml");
// disconnect
scp.disconnect();
catch (IOException e)
System.out.println("IO ERROR7");
System.out.println(e);
catch (TransformerException tranE){
tranE.printStackTrace();
catch (ParserConfigurationException e)
System.out.println("IO ERROR8");
System.out.println(e);
catch (SAXException e)
System.out.println("IO ERROR9");
System.out.println(e);
}So my question is, what exactly are the contents of the file in the META-INF/services folder? I have manually created this file in my classes directory, where the program is searching. When I place text in it, it appends the text with .class and searches for that file, but doesn't seem to do anything with the file. I attempted directing it to the "DocumentBuilderFactory.class" file that I extracted from the classes.jar included with the JDK.
I feel like all I need is this file to contain the correct content and the code will FINALLY work, but I have not been able to find anything out there on it.
Thank for you for your help, sorry this was such a long message.
-Jason
Thanks!
Thanks for the fast reply. I don't know if I made my point clear.
I do not want to determine the parser by myself. I want the client system use the default parser, so I do not have the hit of downloading the fairly large parser jar.
However, I want it not to do an empty request to the server for nothing. This turn around time kills an Applet. I want a fast loading applet!
I'll go in trial and error mode, when I find the time next week.
Thanks again, I appreciate it!
K<o>
Similar Messages
-
Format of "META-INF/services/javax.xml.parsers.SAXParserFactory"
Hi there,
I have written an applet utilizing JAXP. Now the applet does hit the server with requests to
"META-INF/services/javax.xml.parsers.SAXParserFactory", which off course produces a 404-error.
What is the best way to get rid of this unnecessary request in an Applet?
- I can't set the property, because I do not know which xml-parser implementation is available at the client .
- I can't rely on lib/jaxp.properties, obviously!
- I could not find any conclusive information about the format of this request. It says in the Javadoc, a file at this location is used to determine the Factory? waht is the Format of this file? What should it contain?
- The applet works fine, as it defaults to the system factory anyway.
However, the request brings an extra delay in the applet, which I just do not need. I also do not want to download my preferred xml-parser, I want ot use, what ever is installed on the client.
Any idea what to do?
Thanks
Kaj
Chief Designer at Conficio.com
What is your Plan-B? We just released Plan-B 2.1Thanks!
Thanks for the fast reply. I don't know if I made my point clear.
I do not want to determine the parser by myself. I want the client system use the default parser, so I do not have the hit of downloading the fairly large parser jar.
However, I want it not to do an empty request to the server for nothing. This turn around time kills an Applet. I want a fast loading applet!
I'll go in trial and error mode, when I find the time next week.
Thanks again, I appreciate it!
K<o> -
Hi,
I have created an applet. Its running well in standalone application. But it is not getting referred in some other localhost. The JAXWS is not getting referred by the JRE. I'm getting the exception as invocation exception, and cannot find the META-INF/services/javax.xml.ws.spi.provider.
Anyone can solve, pls reply me.your problem is too stuffed to understand properly..could you elobarate a lil bit
-
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? -
i moved this thread to another location or category:
http://forums.oracle.com/forums/thread.jspa?threadID=928936&tstart=0*
Edited by: noobsaibot on Jul 14, 2009 11:58 PMi moved this thread to another location or category:
http://forums.oracle.com/forums/thread.jspa?threadID=928936&tstart=0*
Edited by: noobsaibot on Jul 14, 2009 11:58 PM -
Javax.xml.parsers.SAXParserFactory
Hi,
where i can find this parameter "javax.xml.parsers.SAXParserFactory ", i want to remove this parameter from configtool or from oslevel but i could not find this parameter.
The parameter is effecting when we are applying KM related forums in portal,so i need to remove or change that parameter
I have search in java level "lib/jaxp.properties" in the JRE directory.
And I have searched in the Services API will look for a classname in the file META-INF/services/javax.xml.parsers.SAXParserFactory in
jars available to the runtime. But I didnt get the parameter javax.xml.parser.SAXParserFactory.
The parameter is effecting when we are applying KM related forums in portal,so i need to remove or change that parameter
the thing is in portal ->system information>system properties we will find the
parameter javax.xml.parsers.SAXParserFactory =com.inqmy.lib.jaxp.SAXParserFactoryImpl
and also we have the
org.xml.sax.driver = com.sap.engine.lib.xml.parser.SAXParser
we need org.xml.sax.driver = com.sap.engine.lib.xml.parser.SAXParser
we have to remove the parameter parameter javax.xml.parsers.SAXParserFactory =com.inqmy.lib.jaxp.SAXParserFactoryImpl in system properties.
And also i want to edit system properties in portal, where we can do this.
thanks and regards,
jagadishHi Jagadishwar,
You can change this kind of configuration using the Config Tool: [Configuring Instance Properties|http://help.sap.com/saphelp_nw04s/helpdata/en/00/3ca3e81b5a4c749b860ab1ed1fb206/frameset.htm]
But please be VERY careful when changing this kind of standard configuration. Personally I would not recommend it. It's used by and likely required by the underlying J2EE engine/portal, e.g. reading configuration files when starting up. Unless you really know what you're doing, don't be surprised you get into a lot of trouble.
Kind regards,
/Sigiswald -
Multiversion config - saxparser re META-INF service provider
I have a problem with the configuration for an applet when using the SAXParser and support for browsers using JDK 1.4.2 and JDK 1.5 in specification of which SAXPaser implementation classes to use.
We had specified in the META-INF/services directory the implementation classes used for the SAXParser.
serviceprovides config file javax.xml.parsers.SAXParser contains org.apache.crimson.jaxp.SAXParserImpl
and
File javax.xml.parsers.SAXParserFactory contains org.apache.crimson.jaxp.SAXParserFactoryImpl
However in JDK 1.5 the SAXParser is now in a different package namely,
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
and similar for the SAXPaserFactory.
We don't have access to client browser JRE configuration only server side.
Would appreciate if anyone has any ideas how to provide this configuration for multiple Java client versions
This was all necessary to stop the classloader search mechanism from hitting the web server with class requests and causing 404 errors.
ThanksI had a similar problem and solved it like this :
// get version number
String strVersion = System.getProperty("java.specification.version");
// it's it version 1.5.x or not?
if (strVersion != null && strVersion.startsWith("1.5"))
// set version 1.5.x specific values
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
//org.apache.axis.utils.XMLUtils.initSAXFactory("com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl", false, false);
else
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.crimson.jaxp.SAXParserFactoryImpl");
//org.apache.axis.utils.XMLUtils.initSAXFactory("org.apache.crimson.jaxp.SAXParserFactoryImpl", false, false);
}petter -
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
Sureshhi,
<, >, &, " 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 ' as in
<element>this is an <element> tag</element>
sincerely, Michael -
META-INF/context.xml, Tomcat, META-INF/services
I presently have a Netbeans project laid out like this:
src
src\java
web
web\META-INF
web\META-INF\context.xml
etc. Tomcat finds that META-INF/context.xml OK and does what I expect with it.
I have recently added something that is loaded by java.util.ServiceLoader, which requires a META-INF/services/x.y.z file containing the name(s) of the classes that implement x.y.z. After deployment, my webapp's ServiceLoader doesn't find it, because in the target it isn't in WEB-INF/classes/META-INF/services/x.y.z. If I put it into src/java/META-INF/services/x.y.z it works correctly, as it then ends up in the right place. However I'm now concerned that either Tomcat won't find the context.xml if I put it in the same place under src, because it would then not be in /META-INF/context.xml but rather /WEB-INF/classes/META-INF/context.xml, which in turn would mean that I would then need two META-INF directories. I'm about to test that conjecture about Tomcat finding it under WEB-INF/classes/META-INF, but I'm wondering whether I'm doing something basically wrong in the first place here.You seem to think that you can have only one META-INF directory; this is simply not true. Keep both your META-INF directories and put the files where they are expected. Yay for using overlapping names :/
-
Problem deploying connector: META-INF/ejb-jar.xml not found in jar file
Has anyone seen this problem:
I built Sun's Blackbox implementation and packaged
it identical to the BlackBoxNoTx.rar included with
Weblogic's 'jconnector' sample (even using the same
ra.xml and weblogic-ra.xml). When I try to deploy
it, the server reports:
java.io.FileNotFoundException:
META-INF/ejb-jar.xml not found in jar file
I have no idea why the server thinks my connector
is an EJB. If I deploy the BlackBoxNoTx.rar included
with the sample, everything works without a hitch.
The only variable that I'm changing in my BlackBoxNoTx.rar
is that I build the Blackbox classes myself--otherwise,
the RAR packagings are identical. Any assistance is
greatly appreciated since I'm banging my head against
a wall...
Thanks,
-jason
I was finally able to resolve this one. On the odd chance that someone else encounters
the same problem, here's what went wrong:
My RAR file had two directories: 'META-INF' and 'meta-inf'. The first was created
by the jar tool and contained the manifest.mf file. The second I created manually
and it contained my ra.xml and weblogic-ra.xml. When I examined the RAR using
any tools or I extracted the contents, it looked like it only contained one directory:
META-INF (because NT is case-insensitive).
"Jason L" <[email protected]> wrote:
>
>Has anyone seen this problem:
>
>I built Sun's Blackbox implementation and packaged
>it identical to the BlackBoxNoTx.rar included with
>Weblogic's 'jconnector' sample (even using the same
>ra.xml and weblogic-ra.xml). When I try to deploy
>it, the server reports:
>
>java.io.FileNotFoundException:
>META-INF/ejb-jar.xml not found in jar file
>
>I have no idea why the server thinks my connector
>is an EJB. If I deploy the BlackBoxNoTx.rar included
>with the sample, everything works without a hitch.
>The only variable that I'm changing in my BlackBoxNoTx.rar
>is that I build the Blackbox classes myself--otherwise,
>the RAR packagings are identical. Any assistance is
>greatly appreciated since I'm banging my head against
>a wall...
>
>Thanks,
>
>-jason
-
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. -
Exception with javax.xml.parsers.FactoryConfigurationError
I have a code segment that is working in a Java standalone application environment. I've taken the same segment and ran it in Lotus Domino's environment, with the following error,
javax.xml.parsers.FactoryConfigurationError: java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
Can anyone help?I changed a switch within the Lotus Domino environment to allow class loader, but now I'm getting a different error,
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.crimson.jaxp.DocumentBuilderFactoryImpl not found
Any idea? -
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. -
Package javax.xml.parsers does not exist
When I compile the sample program for xml, DOMEcho.java, or any other xml java program, I get errors on the import statements.
For all the import statements within java.xml.* I get an error message such as: package javax.xml.parsers does not exist.
I have my path and classpath variables set as follows.
REM Java initialization
SET PATH=c:\Documents and settings\User\jwsdp-1_0_01\bin;c:\j2sdkee1.3.1\bin;c:\jdk1.3.1_01\bin;%PATH%
SET JAVA_HOME=c:\j2sdkee1.3.1_01
SET JAVA_XML_PACK_HOME=c:\java_xml
SET JAXM_HOME=c:\java_xml\java_xml_pack-summer-02_01\jaxm-1.1_01
SET JAXP_HOME=c:\java_xml\java_xml_pack-summer-02_01\jaxp-1.2_01
SET JAXR_HOME=c:\java_xml\java_xml_pack-summer-02_01\jaxr-1.0_02
SET JAXRPC_HOME=c:\java_xml\java_xml_pack-summer-02_01\jaxrpc-1.0_01
SET CLASSPATH=c:\Documents and settings\User\jwsdp-1_0_01\bin;c:\Documents and settings\User\jwsdp-1_0_01
SET CLASSPATH=%CLASSPATH%;c:\jdk1.3.1_01\bin;c:\jdk1.3.1;
SET CLASSPATH=%CLASSPATH%;c:\java_xml\java_xml_pack-summer-02_01\jaxm-1.1_01;
SET CLASSPATH=%CLASSPATH%;c:\java_xml\java_xml_pack-summer-02_01\jaxp-1.2_01;
SET CLASSPATH=%CLASSPATH%;c:\java_xml\java_xml_pack-summer-02_01\jaxr-1.0_02;
SET CLASSPATH=%CLASSPATH%;c:\java_xml\java_xml_pack-summer-02_01\jaxrpc-1.0_01
Any ideas?Now that the first program compiled I tried another sample program:
StandAlone.java and
got the same errors.
* $Id: StandAlone.java,v 1.10 2002/04/06 00:47:31 mode Exp $
* $Revision: 1.10 $
* $Date: 2002/04/06 00:47:31 $
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
This program starts with...
import java.io.*;
import javax.xml.soap.*;
import java.net.URL;
import javax.mail.internet.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import org.dom4j.*;
* A StandAlone JAXM Client.
public class StandAlone { -
Javax.xml.parsers not found in import
I have downloaded JAXP from java.sun.com. I put the jar files in ../jdk/jre/lib/ext/.
Im getting "javax.xml.parsers not found in import" when I try to compile a program with an import statement like this:
import javax.xml.parsers.*;
What am i missing? My classpath has ../jdk/jre/lib/ext/ in it..I have downloaded JAXP from java.sun.com. I put the
jar files in ../jdk/jre/lib/ext/.
Im getting "javax.xml.parsers not found in import"
when I try to compile a program with an import
statement like this:
import javax.xml.parsers.*;
What am i missing? My classpath has
../jdk/jre/lib/ext/ in it..Hi,
This seems to be a classpath problem. You can also use JDK1.4.1
which has crimson bundled with it. So you do not need to do any explicit settings for classpath.
Pls let me know if you still have problems
Thanks,
Bhakti
Maybe you are looking for
-
Bridge Help / Install Adobe Output Module is Not working
New computer so switched to the Maverick OS and moved my CS6 over. Lost my Output Module in Bridge. Went through the all of the resets and downloads recommended by Adobe and I still have not had any success in getting the module back. Would prefer no
-
Archive and Install: How to get my data back?
I did an archive/install to resolve a "computer not going to sleep" issue. It did resolve the issue but now I want my data back. I see it is all probably in the folder titled: Previous Systems. How do i get things into this new install (such as my ad
-
Digital audio adapter for analog phones
I would like to use the Toslink output and use a digital-to-analog headphone amp for my studio-quality headphones. I can find a digital to analog converter for quite a large sum of money - for me - at around $500. 1. Does anybody have any ideas for a
-
Can we call a stored procedure from a Trigger
Hello Everyone, I need some help in writing the triggers in Oracle 10g Database. Can we call a stored procedure from a trigger?
-
Printing Imediately using Shop Paper
Hi all, I have a requirement to change a standard form for IW3D. Since the form is quite complicated I decided to change the print program from using SAP SCRIPT to using SMARTFORM. I have manage to do this and all is running well, except the print pa