Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to test portal user from webdynpro ?

Hi:

I'm trying to get the current user from portal (the one who is logged). I deployed my app and obviously thows an exception as new instance of explorer is opened outside the portal so there is not a User portal while the app is running. To test it I try putting my app inside the portal and running, so a user portal exists after login myself on the portal and call the app. The null exception remains and I can't debug the app if I'm inside of the portal...

It's obviously that something is wrong but I'm run off ideas.

My webdynpro code is:

//@@begin javadoc:wdDoInit()

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

//@@end

public void wdDoInit()

{

//@@begin wdDoInit()

Hashtable env = new Hashtable();

try{

// getting the SAP user.

IUser currentUser = WDClientUser.getCurrentUser().getSAPUser();

//Hashtable env = new Hashtable();

env.put(Context.SECURITY_PRINCIPAL, currentUser);

InitialContext context = new InitialContext(env);

Object obj = context.lookup("pcd:/com.sap.portal.system/applications/com.sap.portal.ivs.global/services/producer");

<b>/Is something missing here?/</b>

} catch (NamingException e) {

//handle the exception

System.out.print(e.getMessage());

System.out.print(e.getStackTrace());

} catch(WDUMException e1){

// handle the exception

System.out.print(e1.getMessage());

System.out.print(e1.getStackTrace());

}

//@@end

}

The error is:

java.lang.NullPointerException

at java.util.Hashtable.put(Hashtable.java:393)

at com.repsol.pepue.PepUEView.wdDoInit(PepUEView.java:113)

at com.repsol.pepue.wdp.InternalPepUEView.wdDoInit(InternalPepUEView.java:114)

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

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

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

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

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

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

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

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

Thanks a lot for the time to read my post.

Not what you were looking for? View more on this topic or Ask a question