cancel
Showing results for 
Search instead for 
Did you mean: 

NULL POINTER EXCEPTION

Former Member
0 Kudos

hii all,

am trying to create an ejb application : addition of two numbers....am writing the business logic in session bean n calling it from commandbean.....hav added jar of commandbean in model of webdynpro.....after deployment while i input the two numbers in input fields and press the add button get the following error......

The initial exception that caused the request to fail, was:

java.lang.NullPointerException

at com.sap.wrap.Wrap.myAddition(Wrap.java:47)

at com.sap.add.CompAddView.onActionresult(CompAddView.java:143)

at com.sap.add.wdp.InternalCompAddView.wdInvokeEventHandler(InternalCompAddView.java:150)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)

... 27 more

MY corresponding code 4my myAddition in my commandbean is as follows:

public int myAddition()

{

result = local.add(par1,par2);

return result;

}

-


and the code for action button is:

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi ,

Generally NullPointerException comes when we are trying access the memabers of class through null reference.I think local referring null .Please check once.

Thanks&Regards,

Suresh Kumar T

Former Member
0 Kudos

Hi,

Can you post the code at the line at com.sap.add.CompAddView.onActionresult(CompAddView.java:143)

Regards

Ayyapparaj

Former Member
0 Kudos

the code at line 143 is as follows:

public int myAddition()

{

result = local.add(par1,par2);

return result;

}

Former Member
0 Kudos

Hi,

is local initialized????

Whats the type of the local object? do you have an instance created before calling this method.

Regards

Ayyapparaj

Former Member
0 Kudos

VERY SORRY!!.....THE CODE AT LINE 143 IS :

public void onActionresult(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionresult(ServerEvent)

wdContext.currentWrapElement().modelObject().myAddition();

//@@end

}

Former Member
0 Kudos

Hi,

Could you please tell, what is local in this line:

result = local.add(par1,par2);

thanks & regards,

Manoj

Former Member
0 Kudos

Hi,

wdContext.currentWrapElement().modelObject().myAddition();

CurrentWrapElement is null

either you need to create an instance of this

or else you ned to set the cardinality to 1..n

If this is a model node you need to execute the model and get this done.

Regards

Ayyapparaj

Former Member
0 Kudos

local is:

Add_sessionLocal local=null;

Former Member
0 Kudos

this is where i hav created the instance of 'local' :

public Wrap ()

{

try{

itx=new InitialContext();

localhome = (Add_sessionLocalHome)itx.lookup("localejbs/Add_session");

local=localhome.create();

}

catch(Exception e)

{

}

}

Former Member
0 Kudos

Don't use empty catch blocks. Maybe an exception occured?

Armin

Former Member
0 Kudos

Hi,

Could you please post the line of code at 143 in CompAddView.

thanks & regards,

Manoj