cancel
Showing results for 
Search instead for 
Did you mean: 

Error NullPointerException

Former Member
0 Kudos

Hi people

I be making a project in WebDynpro, when I put to run the application, to the same one gives an error of javaNullPointer and specifically the error is that it is not executing a function. Next I place draws up to them:

Error stacktrace:

java.lang.NullPointerException

at com.inelectra.f2.component.ControllerRF2.executeZpct_Get_Uni_Orgs_Input(ControllerRF2.java:132)

at com.inelectra.f2.component.wdp.InternalControllerRF2.executeZpct_Get_Uni_Orgs_Input(InternalControllerRF2.java:183)

at com.inelectra.f2.view.F2View.wdDoInit(F2View.java:151)

at com.inelectra.f2.view.wdp.InternalF2View.wdDoInit(InternalF2View.java:155)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)

at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:274)

at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.getView(ViewManager.java:540)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.bindRoot(ViewManager.java:422)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.init(ViewManager.java:130)

at com.sap.tc.webdynpro.progmodel.view.InterfaceView.initController(InterfaceView.java:41)

at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)

at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.displayToplevelComponent(ClientComponent.java:134)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:373)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:608)

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

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:252)

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.doGet(DispatcherServlet.java:48)

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

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

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

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

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

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

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

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

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:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

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:95)

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

The line of code of line 132 is the following one:



String number = wdContext.currentOutput_EMPElement().getP_Employeenumber();


Next I place all the code to them of my ControllerRF2 controller:

// -

-


// This file has been generated partially by the Web Dynpro Code Generator.

// MODIFY CODE ONLY IN SECTIONS ENCLOSED BY @@begin AND @@end.

// ALL OTHER CHANGES WILL BE LOST IF THE FILE IS REGENERATED.

// -

-


package com.inelectra.f2.component;

//

// IMPORTANT NOTE:

// ALL IMPORT STATEMENTS MUST BE PLACED IN THE FOLLOWING SECTION ENCLOSED

// BY @@begin imports AND @@end. FURTHERMORE, THIS SECTION MUST ALWAYS CONTAIN

// AT LEAST ONE IMPORT STATEMENT (E.G. THAT FOR IPrivateControllerRF2).

// OTHERWISE, USING THE ECLIPSE FUNCTION "Organize Imports" FOLLOWED BY

// A WEB DYNPRO CODE GENERATION (E.G. PROJECT BUILD) WILL RESULT IN THE LOSS

// OF IMPORT STATEMENTS.

//

//@@begin imports

import com.inelectra.f2.component.wdp.IPrivateControllerRF2;

import com.inelectra.f2.modelo.Zpct_Get_Uni_Orgs_Input;

import com.inelectra.f2.modelo.Zpct_Getempdata_From_User_Input;

import com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException;

import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;

//@@end

//@@begin documentation

//@@end

public class ControllerRF2

{

/**

  • Logging location.

*/

private static final com.sap.tc.logging.Location logger =

com.sap.tc.logging.Location.getLocation(ControllerRF2.class);

static

{

//@@begin id

String id = "$Id$";

//@@end

com.sap.tc.logging.Location.getLocation("ID.com.sap.tc.webdynpro").infoT(id);

}

/**

  • Private access to the generated Web Dynpro counterpart

  • for this controller class. </p>

*

  • Use <code>wdThis</code> to gain typed access to the context,

  • to trigger navigation via outbound plugs, to get and enable/disable

  • actions, fire declared events, and access used controllers and/or

  • component usages.

*

  • @see com.inelectra.f2.component.wdp.IPrivateControllerRF2 for more details

*/

private final IPrivateControllerRF2 wdThis;

/**

  • Root node of this controller's context. </p>

*

  • Provides typed access not only to the elements of the root node

  • but also to all nodes in the context (methods nodeXYZ())

  • and their currently selected element (methods currentXYZElement()).

  • It also facilitates the creation of new elements for all nodes

  • (methods createXYZElement()). </p>

*

  • @see com.inelectra.f2.component.wdp.IPrivateControllerRF2.IContextNode for more details.

*/

private final IPrivateControllerRF2.IContextNode wdContext;

/**

  • A shortcut for <code>wdThis.wdGetAPI()</code>. </p>

  • Represents the generic API of the generic Web Dynpro counterpart

  • for this controller. </p>

*/

private final com.sap.tc.webdynpro.progmodel.api.IWDController wdControllerAPI;

/**

  • A shortcut for <code>wdThis.wdGetAPI().getComponent()</code>. </p>

  • Represents the generic API of the Web Dynpro component this controller

  • belongs to. Can be used to access the message manager, the window manager,

  • to add/remove event handlers and so on. </p>

*/

private final com.sap.tc.webdynpro.progmodel.api.IWDComponent wdComponentAPI;

public ControllerRF2(IPrivateControllerRF2 wdThis)

{

this.wdThis = wdThis;

this.wdContext = wdThis.wdGetContext();

this.wdControllerAPI = wdThis.wdGetAPI();

this.wdComponentAPI = wdThis.wdGetAPI().getComponent();

}

//@@begin javadoc:wdDoInit()

/** Hook method called to initialize controller. */

//@@end

public void wdDoInit()

{

//@@begin wdDoInit()

//$$begin Service Controller(-1045065812)

wdContext.nodeZpct_Getempdata_From_User_Input().bind(new Zpct_Getempdata_From_User_Input());

//$$end

//$$begin Service Controller(-1519323284)

wdContext.nodeZpct_Get_Uni_Orgs_Input().bind(new Zpct_Get_Uni_Orgs_Input());

//$$end

//@@end

}

//@@begin javadoc:wdDoExit()

/** Hook method called to clean up controller. */

//@@end

public void wdDoExit()

{

//@@begin wdDoExit()

//@@end

}

//@@begin javadoc:executeZpct_Get_Uni_Orgs_Input()

/** Declared method. */

//@@end

public void executeZpct_Get_Uni_Orgs_Input( )

{

//@@begin executeZpct_Get_Uni_Orgs_Input()

//$$begin Service Controller(-1748031726)

IWDMessageManager manager = wdComponentAPI.getMessageManager();

wdContext.nodeZpct_Get_Uni_Orgs_Input().currentZpct_Get_Uni_Orgs_InputElement();

try{

String number = wdContext.currentOutput_EMPElement().getP_Employeenumber();

wdContext.currentZpct_Get_Uni_Orgs_InputElement().modelObject().setP_Supervisor(number);

wdContext.currentZpct_Get_Uni_Orgs_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

} catch(WDDynamicRFCExecuteException ce) {

manager.reportException(ce.getMessage(), false);

}

//$$end

//@@end

}

//@@begin javadoc:executeZpct_Getempdata_From_User_Input()

/** Declared method. */

//@@end

public void executeZpct_Getempdata_From_User_Input( )

{

//@@begin executeZpct_Getempdata_From_User_Input()

//$$begin Service Controller(240966885)

IWDMessageManager manager = wdComponentAPI.getMessageManager();

try{

String empNum = wdContext.currentContextElement().getUsuarioSAP();

wdContext.currentZpct_Getempdata_From_User_InputElement().modelObject().setP_Username(empNum);

wdContext.currentZpct_Getempdata_From_User_InputElement().modelObject().execute();

wdContext.nodeOutput_EMP().invalidate();

} catch(WDDynamicRFCExecuteException ce) {

manager.reportException(ce.getMessage(), false);

}

//$$end

//@@end

}

/*

  • The following code section can be used for any Java code that is

  • not to be visible to other controllers/views or that contains constructs

  • currently not supported directly by Web Dynpro (such as inner classes or

  • member variables etc.). </p>

*

  • Note: The content of this section is in no way managed/controlled

  • by the Web Dynpro Designtime or the Web Dynpro Runtime.

*/

//@@begin others

//@@end

}[/code]

Now I place the part to them of the code of the Vista (F2View) in where are estan executing the functions that I use:

public void wdDoInit()

{

//@@begin wdDoInit()

// Inicializa el campo mes y el campo año

GregorianCalendar g = new GregorianCalendar();

int mes = g.get(g.MONTH)+1;

String mesSel = (mes<10) ? "0"mes : ""mes;

wdContext.currentContextElement().setMes(mesSel);

wdContext.currentContextElement().setRBPeriodo("MA");

wdContext.currentContextElement().setHabilitaMA(true);

wdContext.currentContextElement().setHabilitaDH(false);

wdContext.currentContextElement().setDesde(null);

wdContext.currentContextElement().setHasta(null);

IWDAttributeInfo attributeInfo =

wdContext.getNodeInfo().getAttribute("Anio");

ISimpleTypeModifiable simpleType = attributeInfo.getModifiableSimpleType();

IModifiableSimpleValueSet valueSet =

simpleType.getSVServices().getModifiableSimpleValueSet();

valueSet.keySet().removeAll(valueSet.keySet());

int anioAct = g.get(g.YEAR);

int anioTope= anioAct + 15;

for(int a=1998; a<=anioTope; a++){

valueSet.put(new Integer(a), ""+a);

}

wdContext.currentContextElement().setAnio(anioAct);

try{

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user = wdUser.getSAPUser();

if (user != null){

IUserAccount[] acct = user.getUserAccounts();

if(acct[0] != null){

String strUserid = acct[0].getLogonUid();

wdContext.currentContextElement().setUsuarioSAP(strUserid);

wdThis.wdGetControllerRF2Controller().executeZpct_Getempdata_From_User_Input();

}

}

} catch(Exception e){

wdComponentAPI.getMessageManager().reportException(e.getMessage(),true);

}

wdThis.wdGetControllerRF2Controller().executeZpct_Get_Uni_Orgs_Input();

attributeInfo = wdContext.getNodeInfo().getAttribute("UnidadOrganizativa");

simpleType = attributeInfo.getModifiableSimpleType();

valueSet = simpleType.getSVServices().getModifiableSimpleValueSet();

valueSet.keySet().removeAll(valueSet.keySet());

int sizeUO = wdContext.nodeP_Uniorgs().size();

for(int j=0; j<sizeUO; j++){

IPrivateF2View.IP_UniorgsElement uoE = wdContext.nodeP_Uniorgs().getP_UniorgsElementAt(j);

valueSet.put(uoE.getObject_Id(),uoE.getShort_Text()" - "uoE.getLong_Text());

}

//@@end

}[/code]

<b>Specifically what they make the functions, is that I want to take the SAP User from the user who enters to the system and with this data he shows the Organizativas Units to me of he himself.</b>

I have tried and proven of everything but I do not give with the solution, I need its aid urgently

Thanks and regards

Daniela

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

My suggestion is bebug the application.

As you said the EMP_Outputnode may not contain any data.

This could be bcose the user that you are trying to pass to the execute() method may be worng.In that case EMP Outputnode will not contain any data !!!

So try to debug and check whats the EMP Outputnode size after executig the executeZpct_Getempdata_From_User_Input() method

Regards,ANilkumar