java - XML serializer error -


i getting following error when prepare document , return.

please find code below

        public static document requestparammissing (string params, string codeexception, string message, string apimethod, exception e, subscriberid, string udid, stringbuilder listparams, string requestid, string apiurl){      document doc = null;      string errorcodenumber = '';     documentbuilderfactory docfactory = documentbuilderfactory.newinstance();     documentbuilder docbuilder = docfactory.newdocumentbuilder();     doc = docbuilder.newdocument();     element rootelement = doc.createelement("error");     doc.appendchild(rootelement);     element errorcode = doc.createelement("code");     element errormessage = doc.createelement("message");     if(codeexception.equals('requestexception')){         errorcodenumber = '1000';         errorcode.appendchild(doc.createtextnode('1000'));         errormessage.appendchild(doc.createtextnode(message));     }else{         if(e?.tostring()?.contains('unknownhostexception')){             errorcodenumber = '2000';             errorcode.appendchild(doc.createtextnode('2000'));             errormessage.appendchild(doc.createtextnode('unknownhostexception'));         }else if(e?.tostring()?.contains('sockettimeoutexception')){             errorcodenumber = '3000';             errorcode.appendchild(doc.createtextnode('3000'));             errormessage.appendchild(doc.createtextnode('sockettimeoutexception'));         }else if(e?.tostring()?.contains('clientexception')){             errorcodenumber = '4000';             errorcode.appendchild(doc.createtextnode('4000'));             errormessage.appendchild(doc.createtextnode('clientexception'));         }else if(e?.tostring()?.contains('httpresponseexception')){             errorcodenumber = '5000';             errorcode.appendchild(doc.createtextnode('5000'));             errormessage.appendchild(doc.createtextnode("httpresponseexception"));         }else{             errorcodenumber = '6000';             errorcode.appendchild(doc.createtextnode('6000'));             errormessage.appendchild(doc.createtextnode(e.tostring()));         }     }      rootelement.appendchild(errorcode);     rootelement.appendchild(errormessage);      element errorapimethod = doc.createelement("apimethod");     errorapimethod.appendchild(doc.createtextnode(apimethod));     rootelement.appendchild(errorapimethod);      element errorapiurl = doc.createelement("apiurl");     errorapiurl.appendchild(doc.createtextnode(apiurl));     rootelement.appendchild(errorapiurl);      element errorexception = doc.createelement("exception");     if(e != null){         errorexception.appendchild(doc.createtextnode(e.tostring()));     }else{         errorexception.appendchild(doc.createtextnode(''));     }     rootelement.appendchild(errorexception);      element errormissingparam = doc.createelement("missingparamvalue");     errormissingparam.appendchild(doc.createtextnode(params));     rootelement.appendchild(errormissingparam);     logger.error('ef response time: errors [api request url method:' + apimethod + ';error code :' + errorcodenumber + ';status:' +             'failure in teleflora ' + apiurl +' request;params:' + listparams +';exception:' + e +             ';udid:' + udid + ';requestid:' + requestid + ']---> subscriberid:'+ subscriberid);      return doc; } 

error:

     java.lang.nullpointerexception @ org.apache.xml.serializer.treewalker.dispatachchars(treewalker.java:246) @ org.apache.xml.serializer.treewalker.startnode(treewalker.java:416) @ org.apache.xml.serializer.treewalker.traverse(treewalker.java:145) @ org.apache.xalan.transformer.transformeridentityimpl.transform(transformeridentityimpl.java:390) @ com.sun.jersey.core.impl.provider.entity.documentprovider.writeto(documentprovider.java:120) @ com.sun.jersey.core.impl.provider.entity.documentprovider.writeto(documentprovider.java:70) @ com.sun.jersey.spi.container.containerresponse.write(containerresponse.java:306) @ com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest(webapplicationimpl.java:1437) @ com.sun.jersey.server.impl.application.webapplicationimpl.handlerequest(webapplicationimpl.java:1349) @ com.sun.jersey.server.impl.application.webapplicationimpl.handlerequest(webapplicationimpl.java:1339) @ com.sun.jersey.spi.container.servlet.webcomponent.service(webcomponent.java:416) @ com.sun.jersey.spi.container.servlet.servletcontainer.service(servletcontainer.java:537) @ com.sun.jersey.spi.container.servlet.servletcontainer.service(servletcontainer.java:708) @ javax.servlet.http.httpservlet.service(httpservlet.java:722) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:225) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:169) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:168) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:98) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:927) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:999) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:565) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:309) @ java.util.concurrent.threadpoolexecutor$worker.runtask(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) 

fwiw, it's caused appending null text value. check message not null. newer serializer may fix issue.


Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -