exception - SAXParseException and UnmarshalException -
i trying deal these exception. example when user, loads invalid xml file, saxparseexception thrown , asked load file.
it seems "catch" won't work here.
here's code:
public void parsexml_from_file (file xml_file) { try { jaxbcontext jc = jaxbcontext.newinstance ("generated"); //creating unmarshaller. unmarshaller u = jc.createunmarshaller (); //using file approach system.out.println("using file approach:"); jaxbelement element = (jaxbelement) u.unmarshal(xml_file); test_class maintest = (test_class) element.getvalue (); } catch (jaxbexception e) { e.printstacktrace (); }catch (saxparseexception e) //do }catch (unmarshalexception e) //do } }
even, wont work
catch (jaxbexception,saxparseexception,unmarshalexception e) { //do }
@don robi
this get:
exception in thread "main" java.lang.error: unresolved compilation problems: type jaxbexception not generic; cannot parameterized arguments <saxparseexception, unmarshalexception> syntax error on token ",", < expected syntax error, insert ">" complete referencetype1 @ xml_parser.parsexml_from_file(xml_parser.java:64) @ main_class.main(main_class.java:13)
the exception indicates compilation exception. once errors fixed in xml_parser class should jaxb behaviour expecting.
exception in thread "main" java.lang.error: unresolved compilation problems: type jaxbexception not generic; cannot parameterized arguments <saxparseexception, unmarshalexception> syntax error on token ",", < expected syntax error, insert ">" complete referencetype1 @ xml_parser.parsexml_from_file(xml_parser.java:64) @ main_class.main(main_class.java:13)
Comments
Post a Comment