cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.NullPointerException

Former Member
0 Kudos

Hi All,

I get a null pointer exception when trying to run my web dynpro app, here are the details:

java.lang.NullPointerException

at com.sap.tc.webdynpro.progmodel.context.MappedNodeElement.wdGetObject(MappedNodeElement.java:350)

at com.sap.tc.webdynpro.progmodel.context.NodeElement.getAttributeAsText(NodeElement.java:888)

Here is the code in component controller


public void wdDoInit()
  {
    //@@begin wdDoInit()

    subjAreaInput = new Zep_Get_Infoprovider_Status_Input();	
    wdContext.nodeZep_Get_Infoprovider_Status_Input().bind(subjAreaInput);
           
    executeSubjAreaInput();
      
    
    //@@end
  }

public void executeSubjAreaInput( )
  {
    //@@begin executeSubjAreaInput()
    try
    {
	subjAreaInput.execute();
	wdContext.nodeOutputSubjArea().invalidate();
    }
    catch(Exception e)
    {
	e.printStackTrace();
    }
    //@@end
  }

Here is the line where the code fails:


public void setDescriptions( )
  {
    //@@begin setDescriptions()
    int elemCount = wdContext.nodeZep_Ent_Subj_Status().size();
    if( elemCount > 0 ) //elemCount is 7, I have verified this
    {
	for( int i=0; i<elemCount; i++)
	{
             // code fails at this line with the above exception
	String compare = wdContext.nodeZep_Ent_Subj_Status().getElementAt(i).getAttributeAsText("SUBJECT_AREA");
                }
    }
  }

Please help!! I've been trying to debug for 2 days now!!

Thanks

TM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I figured it out.

Former Member
0 Kudos

What was it?

Former Member
0 Kudos

Hi,

i think your executing the model and your invalidating the output node so that when your trying to get the value from the node or sub node available under the output will return nothing right because it is already invalidated, i thnnk you need to write this line before executing the model right. wdContext.nodeOutputSubjArea().invalidate();

try

{

subjAreaInput.execute();

wdContext.nodeOutputSubjArea().invalidate();

}

if you varified that node size, then there may be problem with this line

String compare = wdContext.nodeZep_Ent_Subj_Status().getElementAt(i).getAttributeAsText("SUBJECT_AREA");

it means nothing, i think you are trying to get the value of a field at a ith position row right

please use this code insted of your's

String compare = wdContext.nodeZep_Ent_Subj_Status().getElementAt(i).getAttributeValue("SUBJECT_AREA");

may be it help you

Cheers,

Appu

Former Member
0 Kudos

Hi Apparao,

You always call the invalidate method after calling the execute method. The invalidate method synchronises the context model nodes with what is in the actual model itself.

Secondly, I cannot use the method getAttributeValue as the return type for this method is an Object and not a string. getAttributeAsText returns the desired String object.

Any other suggestions? Anyone?

As a test, I quickly created a Table UI and mapped it to the outputNode nodeZep_Ent_Subj_Status.

All the values returned show up in the table fine. This is what is making it so difficult to narrow the null pointer exception.