java - Null pointer Exception in Uploading the xml file -
i have following code:
l2schemahandler handler = getschemahandler(); // validate xmlformatvalidator validator = new xmlformatvalidator(handler.elements, handler.types, handler.root); inputstream schemainput = new fileinputstream(new file(xmlfilepath)); saxparserfactory spfactory = saxparserfactory.newinstance(); spfactory.setfeature("http://xml.org/sax/features/namespaces", true); saxparser parser = spfactory.newsaxparser(); //this line gives null pointer exception parser.parse(schemainput, validator); report.addall(validator.getreport()); this.objectslist = validator.getobjectlist(); // when know objects valid, duplicate objects db if(report.isempty()) duplicateobjectsmap = validateobjectid(validator.getobjects(),report); // here need check whether object id's exists in db if(report.isempty()){//if no errors have occurred // if(validateobjectid(validator.getobjects(),report)) validateobjectsfromfile(validator.getobjects(), report , msgreport); }
the marked line gives null pointer exception while parser
, schemainput
, validator
contaning objects not null value.
why line gives null pointer exception?
to use validating parser, make following changes:
spfactory.setvalidating(true);
by default value of set false.
Comments
Post a Comment