java - Getting NullPointerException calling methods on null values unmarshalled by JAXB -


i have xml file containing many tags. out of can missing. while reading such unmarshalled file using jaxb getting nullpointerexception missing tags.

i know 1 solution can check whether object null or not. it's not convenient check null condition each , every tag because there many tags. if handle nullpointerexception handle exception not read xml further.

is there efficient way handle situation(especially how rid of checking null each , every tag ?)

request rqstr = binfo.getrequest(); system.out.println("requester comment : "+rqstr.getcomment()); system.out.println("requester request date : "+rqstr.getdate()); system.out.println("requetser doc id :"+rqstr.getdocid()); system.out.println("requetser response date : "+rqstr.getrespondbydate()); system.out.println("supplier check box : "+rqstr.issuppliercheckbox());                    contact rqstrcontact = rqstr.getcontact(); **system.out.println("rqstr contact name : "+rqstrcontact.getname());** system.out.println("rqstr contact title : "+rqstrcontact.gettitle()); system.out.println("rqstr : "+rqstrcontact.getemail().getaddress()); for(phone rqstrphone:rqstrcontact.getphone())  {     system.out.println("requester contact phone : "+rqstrphone.getnumber()); } company rqstrcomp = rqstr.getrequestcompany(); system.out.println("requester company name : "+rqstrcomp.getname()); for(uniqueid rqstruid : rqstrcomp.getcompanyid()) {     system.out.println("requester comapny uid : "+rqstruid.getidentity()); } 

getting nullpointerexception

exception in thread "main" java.lang.nullpointerexception @ com.magnisys.eagleye.unmarshalxml.<init>(unmarshalxml.java:134) @ com.magnisys.eagleye.mainclass$13.widgetselected(mainclass.java:3805) @ org.eclipse.swt.widgets.typedlistener.handleevent(typedlistener.java:248) @ org.eclipse.swt.widgets.eventtable.sendevent(eventtable.java:84) @ org.eclipse.swt.widgets.widget.sendevent(widget.java:1053) @ org.eclipse.swt.widgets.display.rundeferredevents(display.java:4169) @ org.eclipse.swt.widgets.display.readanddispatch(display.java:3758) @ com.magnisys.eagleye.mainclass.main(mainclass.java:20226) 

getting nullpointerexception @ line marked **


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -