[jdom-interest] Help
Malachi de AElfweald
malachi at tremerechantry.com
Tue Nov 12 12:11:31 PST 2002
>> But I don't know at what line it causes NULL pointer exception.
Are you doing javac with debug on? If you are, it should tell you the line number.
also, in your catches before your re-throw, put e.printStackTrace()
If all else fails, can you post your stack trace?
Thanks,
Malachi
11/12/2002 9:46:14 AM, "Joanna Chen" <joanna.chen at towers.com> wrote:
>Hi,
> I need help on the following problem with NULL Pointer Exception
>which was sent on 11/6. Any suggestions?
>
> Thanks,
> Joanna
>
>----- Forwarded by Joanna Chen/Towers Perrin on 11/12/2002 12:40 PM -----
>
>
> To: jdom-interest-request at jdom.org
> Joanna Chen cc:
> Subject: Help
> 11/05/2002 12:10
> PM
>
>
>
>
>
>Hi JDOM,
> I am facing a strange problem and need your help.
> I developed the following codes in January using JDOM 1.0 Beta 7. They
>have been run in test without any NULL Pointer Exception. When the codes
>moved to production in the mid of October, I encounter the problem with
>Null Pointer Exception; When we undeploy and deploy the class module under
>WebLogic 6.1, it works fine. Then, the problem happens again. I have been
>testing it for one week to make it fails with variation of data; However,
>I can not make it happens.
>
>I run out of idea how to fix the problem and I need your help! Do you
>think it has anything to do with classpath?
>
>Here are the codes:
>
>public void loadResourceFile(String xmlFile)
> throws Exception
> {
> if (traceFlag)
> traceService.logTrace("EnrollExtractProcess.loadResourceFile",
> "Start");
>
> try
> {
> InputStream inStream = this.getClass().getClassLoader
>().getResourceAsStream(xmlFile);
>
> if (inStream != null)
> {
> //request document building without validation
> SAXBuilder builder = new SAXBuilder(false);
> //Document doc = builder.build(new File(xmlFile));
> Document doc = builder.build(inStream);
>
> //Get the root element
> root = doc.getRootElement();
> }
> }
> catch (Exception e)
> {
> //write to error object but the program should not end
> throw new DataAccessException
>("EnrollExtractProcess.loadResourceFile " + e.toString());
> }
>
> if (traceFlag)
> traceService.logTrace("EnrollExtractProcess.loadResourceFile",
> "End");
>
> }
>
> -- end of loadResource File.
>
> I got NULL pointer exception on the following code. But I don't know at
>what line it causes NULL pointer exception. The only reason I can think of
>is the root is NULL or becomes NULL. Would you please take a quick
>look and let me know your thoughts are.
>
> private boolean getMappingFields(String table, String field)
> throws Exception
> {
> if (traceFlag)
> traceService.logTrace("EnrollExtractProcess.getMappingFields",
> "Start");
>
> try
> {
>
> List children = root.getChildren(table);
>
> if (children.size() == 0)
> return false;
>
> for (Iterator it = children.iterator(); it.hasNext(); )
> {
> org.jdom.Element currentElement = (org.jdom.Element)it.next
>();
>
> className = currentElement.getAttributeValue("name");
> classPath = currentElement.getAttributeValue("classpath");
> classId = currentElement.getAttributeValue("id");
>
> List fields = currentElement.getChildren(field);
>
> Iterator i = fields.iterator();
> while(i.hasNext())
> {
> org.jdom.Element e = (org.jdom.Element) i.next();
>
> fieldName = e.getAttributeValue("name");
> fieldType = e.getAttributeValue("type");
> }
> if (fields.size() == 0)
> return false;
> }
> }
>
> catch (Exception e)
> {
> throw new DataAccessException("getMappingFields " + e.toString
>());
> }
>
> if (traceFlag)
> traceService.logTrace("EnrollExtractProcess.getMappingFields",
> "End");
>
> return true;
> }
>
> The method loadResourceFile will only call once and getMappingFields
>will call for every field found in the database.
>
> Will the root ever become NULL when calling the getRootElement?
>
> Thanks in advance for your help,
> Joanna
>
> Here is the portion of the xml file:
><?xml version="1.0" encoding="UTF-8" ?>
><layout>
> <BENELIG name="FSAData" id="1" classpath="com.towers.bas.hw.data">
> <BE_DC_FSA_DED name="conAmt" type="double"/>
> <BE_HC_FSA_DED name="conAmt" type="double"/>
> </BENELIG>
> <BENSELECT name="BenefitData" id="2" classpath
>="com.towers.bas.hw.data">
> <BS_BEN_ID name="benId" type="DecodeField"/>
> </BENSELECT>
> <EMPLOYEE name="EmployeeIndData" id="6" classpath
>="com.towers.bas.hw.data">
> <E_DT_BORN name="birthDt" type="FormatField"/>
> <E_DT_EMP_STATUS name="empStatDt" type="FormatField"/>
> <E_DT_HIRE name="hireDt" type="FormatField"/>
> <E_ORG_ID1 name="org1" type="DecodeField"/>
> <E_ORG_ID2 name="org2" type="DecodeField"/>
> <E_ORG_ID3 name="org3" type="DecodeField"/>
> <E_OTH_ORG_ID1 name="othOrg1" type="DecodeField"/>
> <E_OTH_ORG_ID2 name="othOrg2" type="DecodeField"/>
> <E_OTH_ORG_ID3 name="othOrg3" type="DecodeField"/>
> </EMPLOYEE>
></layout>
>
>
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
>
More information about the jdom-interest
mailing list