I am creating a custom function in ant, while in creating it, I'm facing ExceptionInInitializer exception. I have put jdom-2.0.2.jar in my antibi directory so that the custom work can be successfully compiled. Below is my custom work code
import java.io. *; Import org.apache.tools.ant.BuildException; Import org.apache.tools.ant.Task; Import org.jdom2.Document; Import org.jdom2.Element; Import org.jdom2.JDOMException; Import org.jdom2.input.SAXBuilder; Import org.jdom2.output.format; Import org.jdom2.output.xmlOutputter; Expansion of public-class demo work {Private string Init; @ Override execute public zeros () Build exclamation exceeds (if! (Init.isEmpty ()) and init! = Null {display (); } And {new buildEXTION throw ("Please enter attribute init"); }} Public Zero SetInt (string init) {this.init = init; } Public Zero Exposure () {System.out.println ("init value is" + init); {SAXbuilder saxBuilder = Try new SAXBuilder (); } Hold (exception e) {e.printStackTrace (); New Build Execution Throw ("Jodiaphone Captured"); }}} this is my ant file
& lt; "." Name of this project = "XMLUpdate" default = "main" basedir = & gt; & Lt; Target name = "main" dependent = "compilation, jar, runtask" & gt; & Lt; / Target & gt; & Lt; Target name = "compilation" & gt; & Lt; Javac srcdir = "." "." DESTDIR = / & gt; & Lt; / Target & gt; & Lt; Target name = "jar" & gt; & Lt; Jar destfile = "./ Demo.jar" basedir = "." Included = ". * Class" /> & Lt; / Target & gt; & Lt; Target name = "runtask" & gt; & Lt; Taskdef name = "dem" classname = "demo" /> & Lt; Dem init = "BOM.xml" /> & Lt; / Target & gt; & Lt; / Project & gt; I am facing ExceptionInInitializer exception
I think the error is hit when the compiler is parsing the line
SAXbuilder saxbuilder = new SAXbuilder (); Honestly, till now I have not encountered this exception in Java what is wrong here?
I met with the same problem, and resolved accordingly
Use:
SAXBuilder saxBuilder = new SAXBuilder (new XMLReaderSAX2Factory (incorrect, "org.apache.xerces.parsers.SAXParser")); Instead of no-arg constructor,
Comments
Post a Comment