Re: [javaCompiler-users] compiles and executes but throws java exception --help
Status: Beta
Brought to you by:
soapy
From: Steven B. <dud...@gm...> - 2007-02-14 06:34:14
|
On 2/13/07, Marco Trudel <mt...@gm...> wrote: > > Sorry, forgot to CC you since you're not on the mailinglist... So here > my forwarded answer... > > Steven Blade wrote: > > hi > > i have used JNC to compile a java app that does some xml parsing and > > transformation. > > my app references the javax.xml.parsers and javax.xml.transform, nothing > > fancy in there. > > it compiles fine but whenever i try to instantiate a > > SAXTransformerFactory in my java code, i get the following error > > (Trs_Main is the .exe) > > Exception in thread "main" > > javax.xml.transform.TransformerFactoryConfigurationError: > > gnu.xml.transform.TransformerFactoryImpl > > at java.lang.VMThrowable.fillInStackTrace(Trs_Main.exe) > > at java.lang.Throwable .<init>(Trs_Main.exe) > > at javax.xml.transform.TransformerFactory.newInstance(Trs_Main.exe) // i > > guess this is where the error comes from > > at asy.TrsToXML.split(Trs_Main.exe) > > > > also when i try to instantiate a SAXParserFactory object using > > "SAXParserFactory factory=SAXParserFactory.newInstance();" > > i get another error, probably related : > > Exception in thread "main" java.lang.NoClassDefFoundError : > > gnu.xml.stream.SAXParserFactory > > at javax.xml.parsers.SAXParserFactory.newInstance(Trs_Main.exe) > > > > im using jdk1.4.12 > > > > does this occur because JNC supports gnu's and not sun's SAX > implementation? > > please tell me what to do, do i have to use gnu's SAX in order to get it > > to work? > > and if so please tell me where to find it. > > Can you please provide two meaningful minimal examples for the described > two cases? I never got around to test XML myself, so that would be a > help... > > > Marco > > > Thank you. > > Steven > > > > > > ------------------------------------------------------------------------ > > > > > ------------------------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, > security? > > Get stuff done quickly with pre-integrated technology to make your job > easier. > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > javaCompiler-users mailing list > > jav...@li... > > https://lists.sourceforge.net/lists/listinfo/javacompiler-users > > > public void trsToXml(String ofile) { SAXTransformerFactory factory=(SAXTransformerFactory)SAXTransformerFactory.newInstance(); //the exception points to this line try{ FileWriter fw=new FileWriter(ofile); PrintWriter pw=new PrintWriter(fw,true); StreamResult stream=new StreamResult(pw); handler=factory.newTransformerHandler(); Transformer trans=handler.getTransformer(); trans.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1"); trans.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"trs_xml.dtd"); trans.setOutputProperty(OutputKeys.INDENT,"yes"); handler.setResult(stream); handler.startDocument(); AttributesImpl atts=new AttributesImpl(); handler.startElement("", "", "test", atts); atts.clear(); handler.startElement("", "", "foo", atts); handler.characters(new char[]{'a','b','c'}, 0, 3); handler.endElement("", "", "foo"); handler.endElement("", "", "test"); handler.endDocument(); pw.flush(); pw.close(); }catch(Exception _){_.printStackTrace();} this one throws the first exception } public void xmlToTrs(File sfile,String oFileName) { PrintWriter pWriter=null; try{ SAXParserFactory factory=SAXParserFactory.newInstance(); // the exception points to this line factory.setValidating(true); SAXParser parser=factory.newSAXParser(); boolean proceed=true; File trs=new File(oFileName); if(trs.isFile() && trs.exists()) { System.out.println("the file \""+oFileName+"\" already exists\nDo you wish to overwrite it ? Y/N\n"); BufferedReader input=new BufferedReader(new InputStreamReader(System.in )); proceed=input.readLine().equalsIgnoreCase("y"); } if(proceed) { parser.parse(sfile, new DefaultHandler()); pWriter=new PrintWriter(new FileWriter(trs),true); pWriter.write(sHeading.toString ()+sGeneral.toString()+sItems.toString()); pWriter.flush(); } } catch(Exception _){_.printStackTrace();} finally{if(pWriter!=null) pWriter.close();} } and this one the second -- |