cancel
Showing results for 
Search instead for 
Did you mean: 

invalidate() throws null pointer exception

Former Member
0 Kudos

Hi experts,

Any idea why calling invalidate will throw a null pointer exception.

if (detailNode != null)

detailNode.invalidate();

This is the stack trace:

java.lang.NullPointerException

at com.sap.tc.webdynpro.progmodel.controller.MessageManager.setAttributeValidbyContext(MessageManager.java:656)

at com.sap.tc.webdynpro.progmodel.context.NodeElement.clearPendingInput(NodeElement.java:297)

at com.sap.tc.webdynpro.progmodel.context.NodeElement.exit(NodeElement.java:132)

at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.exit(Node.java:1859)

at com.sap.tc.webdynpro.progmodel.context.Node.clearElements(Node.java:1560)

at com.sap.tc.webdynpro.progmodel.context.Node.onNodeInvalidating(Node.java:1447)

at com.sap.tc.webdynpro.progmodel.context.Node.fireNodeInvalidating(Node.java:1410)

at com.sap.tc.webdynpro.progmodel.context.Node.clearElements(Node.java:1556)

at com.sap.tc.webdynpro.progmodel.context.Node.onNodeInvalidating(Node.java:1447)

at com.sap.tc.webdynpro.progmodel.context.Node.fireNodeInvalidating(Node.java:1410)

at com.sap.tc.webdynpro.progmodel.context.Node.clearElements(Node.java:1556)

at com.sap.tc.webdynpro.progmodel.context.Node.invalidate(Node.java:583)

at com.sap.tc.webdynpro.progmodel.context.Node.invalidate(Node.java:580)

at com.diagonal.mmm.component.MenuDetailsController.save(MenuDetailsController.java:281)

at com.diagonal.mmm.component.wdp.InternalMenuDetailsController.save(InternalMenuDetailsController.java:1250)

at com.diagonal.mmm.view.MenuDetailsView.onActionSave(MenuDetailsView.java:965)

at com.diagonal.mmm.view.wdp.InternalMenuDetailsView.wdInvokeEventHandler(InternalMenuDetailsView.java:999)

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

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

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)

at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)

at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:313)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666)

at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)

at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(AccessController.java:215)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

Accepted Solutions (1)

Accepted Solutions (1)

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi Danial

May be there are no elements in the node to invalidate the node ,because am surprising that the error is coming even though you are checking for the null or not.Please refresh the server once again and deploy the application.Also please check whether there are some other null values u are using in the code.

Regards

Kalyan

Answers (13)

Answers (13)

Former Member
0 Kudos

Hello,

we are having the save Exception.

We are not working with modelNodes only with valueNodes.

We can reproduce the Exception, when doing the same as Daniel

I get the exception after doing the following:

1. The data from detailNode are displayed in a table.

2. I changed the value of one the field to an invalid text and attempt to save the application. I got a validation error.

3. I changed back to the original value and save again and i got the exception.

How did you solve it?

What are we doing wrong?`

Can somebody help me please?

Former Member
0 Kudos

Hi guys,

Somehow i tried again the same case and the null pointer is not coming anymore. Very strange. I will monitor and take your helpful suggestions into consideration. Thanks everyone.

Regards,

Daniel

nikhil_bose
Active Contributor
0 Kudos

could you check in onActionSave() method?

I think it shows NPE in that function

snippet you posted raise little exception.

nikhiL

Former Member
0 Kudos

Hi danial

why dont u check the size of the node first and then perform invalidate operation.

if (detailNode.size() !=0)

detailNode.invalidate();

Former Member
0 Kudos

Hello Daniel,

Check the following things:

(1) You have bind the the entire model context to controller context.

(2) bind the input node and output node separately to the view node.

(3) initialize the Bapi/RFC class at the controller context and bind the object to the input node.

I believe the problem is caused at the 3 part of the description.

Hard code some value to the input at controller context and test the size of the result node.

the chance is that you haven't initialized the result node yet

Regards

Vinod V

Former Member
0 Kudos

Hi,

I think automatic validation is activated with the action which saves your application.

you can try selecting "without validation" check box for that action and build and deploy it.

You can see that checkbox as:

open your view, click the actions tab, locate your action for save, check "without validation" check box.

manual validation can be added as per your requirement in the code.

Kiran

Former Member
0 Kudos

Hi,

Is their any madatory attributes or any calculated attributes used to make some values mandatory which raises a contextexception.

regards

ayyapparaj

Former Member
0 Kudos

Hi ayyapparaj,

The node is a model node and there is no calculated attribute and no mandatory attribute.

I get the exception after doing the following:

1. The data from detailNode are displayed in a table.

2. I changed the value of one the field to an invalid text and attempt to save the application. I got a validation error.

3. I changed back to the original value and save again and i got the exception.

I got no clue what is causing this exception.

Why should the invalidate method throw exception. I thought it is meant to just clear the node ?

Thanks v m.

Regards,

Daniel

Former Member
0 Kudos

Hi guys,

Actually the invalidate method is being executed as can be seen from the stack trace and the exception is coming from the method setAttributeValidbyContext of the class MessageManager . So what could be the reason that the method is throwing a null pointer exception ?

My detailNode variable is not null. Thats for sure.

Thanks.

Regards,

Daniel

Former Member
0 Kudos

Hi Daniel,

There is a problem in your condition.You are allowing to go inside the condition even if node is null.So calling a method(invalidate) on a node which is null is definetely going to give null pointer exception.So you can change your condition as per your requirement.I can help you in framing the condition but i need some more inputss about your exact requirement.

Regards,

Amit Bagati

Former Member
0 Kudos

Hi,

Check whether any supplyFunction or SupplyRelationsRole defined for this node.

Kiran

former_member201361
Active Contributor
0 Kudos

hi,

May be the problem with the conditional statement if.

better get the size of the node element using size() method and store the result in the int variable .

now u can check in the if conditional statement.

if(var==0){

//node.invalidate();

}

else{

//node.invalidate();

}

thanks and regards

fistae

Former Member
0 Kudos

hi...

the problem is with the cheching of "null".

because once it is checking null...it is throwing the nullpointer exception. It is not throwing nullpointer exception because of the invalidate() method.

val1 = value of the node


 int length = (val1==null)?0:val1.length();       
		
 if(length==0)
    {
               //use invalidate here
}

regards,

pinki

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi Danial