cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.NullPointerException Problem

Rodrigo-Giner
Active Contributor
0 Kudos

I started to get this error after pushing a search button (with a adaptive RFC) in a webdynpro created by me. The ivew worked just fine... dont know why started this problem.

java.lang.NullPointerException
	at sap.com.ot.SearchView.onActionSearch(SearchView.java:205)
	at sap.com.ot.wdp.InternalSearchView.wdInvokeEventHandler(InternalSearchView.java:174)
	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.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
	at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
	at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:659)
	at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
	at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
	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:390)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
	at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
	at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
	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(Native Method)
	at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
	at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

BTW, the search button sometimes works... sometimes not.. any idea ??

Message was edited by:

Rodrigo Ariel Giner de la Vega

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Just change the if-statement into

if ( wdContext.nodeOutput().getLeadSelection()!=-1 && "x".equalsIgnoreCase( wdContext.currentOutputElement().getSubrc() ) )

Avinash

Former Member
0 Kudos

Hi Vega

wdContext.currentOutputElement().getSubrc()

This is throwing Exception.

Can you comment and Check?

Rgds

SS

Rodrigo-Giner
Active Contributor
0 Kudos

Yes, u guys were right.

This is the problem

if (wdContext.currentOutputElement().getSubrc().matches("X"))

But now I have a problem... How can I check if the node were filled ?

My iview page... make a validation, the RFC search for a person, if doesnt find him I have to put it into a message, if does find him I bring values in a table to show them.

before I used this if, so when some1 searched with certanly values and nothing is return. (because the user put the values wrong)

if (wdContext.nodeTable_Ot().size() == 0)

{

wdComponentAPI.getMessageManager().reportWarning(

"Registry doest found, check the values");

}

else

continue... with the Iview.

So I check if the tables were filled... the problem is that sometimes and I dont know WHY, if the user put the values right and SHOULD return info the tables the message that nothing was found is rised.

I tought that could be some problem with delay...so in R3 after I check the person and before starting to search for data. I pass this "Subrc" value if the person doesnt exits. This worked... until...yesterday.

Some1 could tell me the way to handle this kind of validation with adaptive RFC ?

Former Member
0 Kudos

Just change the if-statement into

if ( "x".equalsIgnoreCase( wdContext.currentOutputElement().getSubrc() ) )

Armin

Former Member
0 Kudos

Hi Vega,

When ever you are taking current attribute from any node.

Good Practice is check that node is size is greater than zero or not ,If not zero proceed.

For you :

<b>if(wdContext.nodeOutput().size > 0)</b>{

if (wdContext.currentOutputElement().getSubrc().matches("X"))

{

}

}

Rgds

SS

Former Member
0 Kudos

Hi Rodrigo

Like i had mentioned earlier.

Whenever you are dealing with data elements of an RFC, the first step is to always check if its value is null or not.

Another good practice is to check if that node size is greater than zero.

Regards,

Hanoz

Former Member
0 Kudos

Hi,

i think the null pointer exception must be getting triggered in the <i>if</i> statements.

This usually happens when the application does not get any value from the RFC node, and so it ends up taking a <i>null value</i>

Try debugging and check whether the <i>if</i> statements are getting executed!!

Also, try using

.equalsIgnoreCase()

to compare the values in the <i>if</i> statements, in place of

.matches()

Former Member
0 Kudos

Hi Rodrigo,

Note the exception, it shows that exception was at line number 205 of SearchView.java.. So please, highlight the statement at line number 205 in the code..

Regards,

Prabhakaran.

Former Member
0 Kudos

Post the code on "onActionSearch"

Regards,Anilkumar

Rodrigo-Giner
Active Contributor
0 Kudos

Here is the code... I dont think that the problem is in the code... this worked just fine until a moment.

The only thing that I touch was the JCO connector I have to change it because the user to the backend system changed. Can be related to that ? Oo

	//@@begin onActionSearch(ServerEvent)
	this.CheckMandatory("Numot");
	this.CheckMandatory("Cod");
		

	wdComponentAPI
		.getComponent()
		.getMessageManager()
		.raisePendingException();
		
		wdThis.wdGetMultiCustController().executeZtrae_Ot_Input();
		
			if (wdContext.currentOutputElement().getSubrc().matches("X"))
			{ 
			wdComponentAPI.getMessageManager().reportWarning(
			"Registro no encontrado, verificar los datos ingresados");
			}						
 				else{
				String ESTA = wdContext.nodeTable_Ot().currentTable_OtElement().getEstado();
				String MAIL = wdContext.nodeTable_Ot().currentTable_OtElement().getMail();
                                if (MAIL.matches("")){	                wdThis.wdFirePlugToMailView();
					}
					else{
						if (ESTA.matches("ENTR")){
							wdThis.wdFirePlugToEntrView();}
						if (ESTA.matches("TERM")||ESTA.matches("ST05")){
								wdThis.wdFirePlugToTermView();}
						if (ESTA.matches("ESPE")){
							wdThis.wdFirePlugToEspeView();}
						if (ESTA.matches("PREP")){
								wdThis.wdFirePlugToPrepView();}
						if (ESTA.matches("ABIE")){
								wdThis.wdFirePlugToAbiertaView();}
						if (ESTA.matches("PREA")||ESTA.matches("PRER")){
								wdThis.wdFirePlugToPrexView();}		
						ESTA = "";
					}
			}
	MultiModel empModel = (MultiModel) WDModelFactory.getModelInstance(MultiModel.class);
	empModel.disconnectIfAlive();

former_member182372
Active Contributor
0 Kudos

Rodrigo, where is line number 205 ?