Skip to Content
0
May 26, 2020 at 02:55 PM

WDJ NullpointerException

271 Views Last edit May 26, 2020 at 02:59 PM 2 rev

Hello,

I've created a WDJ Application to display documents stored in the KM of the enterprise portal (7.4).

When running the application I'm getting the following error:

[EXCEPTION]
com.sapportals.portal.prt.component.PortalComponentException: Error in service call of Portal Component
Application name : ut_km_asset_report
Component : pcd:portal_content/IP/Finanzen/Rollen/de.gisa.Finanzen/Berichte_2/Verzeichnis_Anlageng_ter/ut_km_asset_report
Component class : ut_km_asset_report
User : portaladmin
at com.sap.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:776)
at com.sap.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:235)
at com.sap.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:97)
at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable.run(AsyncIncludeRunnable.java:119)
at com.sap.engine.core.thread.execution.Executable.run(Executable.java:122)
at com.sap.engine.core.thread.execution.Executable.run(Executable.java:101)
at com.sap.engine.core.thread.execution.CentralExecutor$SingleThread.run(CentralExecutor.java:328)
Caused by: java.lang.NullPointerException: while trying to invoke the method com.sap.tc.webdynpro.services.task.ITask.getApplicationSession() of a null object returned from com.sap.tc.webdynpro.services.session.Utils.getCurrentTask()
at com.sap.tc.webdynpro.services.session.Utils.getCurrentApplicationSession(Utils.java:57)
at com.sap.tc.webdynpro.services.session.Utils.getScopeMaintainer(Utils.java:68)
at com.sap.tc.webdynpro.services.sal.datatransport.core.ResourceManager.getResources(ResourceManager.java:470)
at com.sap.tc.webdynpro.services.sal.datatransport.core.ResourceManager.getResourceCache(ResourceManager.java:455)
at com.sap.tc.webdynpro.services.sal.datatransport.core.ResourceManager.addResource(ResourceManager.java:227)
at com.sap.tc.webdynpro.services.sal.datatransport.core.Resource.<init>(Resource.java:55)
at com.sap.tc.webdynpro.services.sal.datatransport.core.DownloadResource.<init>(DownloadResource.java:90)
at com.sap.tc.webdynpro.services.sal.datatransport.core.DownloadResource.<init>(DownloadResource.java:75)
at com.sap.tc.webdynpro.progmodel.mime.ResourceFactory.createResource(ResourceFactory.java:195)
at com.sap.tc.webdynpro.progmodel.api.WDResourceFactory.createResource(WDResourceFactory.java:104)
at ut_km_asset_report.doContent(ut_km_asset_report.java:72)
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:213)
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:129)
at com.sap.portal.prt.core.RequestDispatcherFactory$PortalComponentRequestDispatcher$5.service(RequestDispatcherFactory.java:308)
at com.sap.engine.services.servlets_jsp.server.deploy.impl.module.IRequestDispatcherImpl.dispatch(IRequestDispatcherImpl.java:292)
at com.sap.portal.prt.core.RequestDispatcherFactory$PortalComponentRequestDispatcher.service(RequestDispatcherFactory.java:298)
at com.sap.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:219)

The RID, Inputstream and content is determined correctly:

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

IUser user = UMFactory.getAuthenticator().getLoggedInUser();
String userID = user.getUniqueName().toUpperCase();
IResourceContext rCtx = ResourceContext.getInstance(user);
RID data= RID.getRID("/turm-ablage/ANLAGEN/BERICHTE/"+userID+"/"+userID+"_Anlagegut.html");
IResource new_resource = null;
try
{
new_resource = ResourceFactory.getInstance().getResource(data, rCtx);
}
catch (ResourceException e)
{ // TODO Auto-generated catch block
e.printStackTrace();
}
if(new_resource != null)
{
IContent cont = null;
try
{
cont = new_resource.getContent();
}
catch (AccessDeniedException e)
{ // TODO Auto-generated catch block
e.printStackTrace();
}
catch (ResourceException e)
{ // TODO Auto-generated catch block
e.printStackTrace();
}
InputStream inputStream = null;
try
{
inputStream = cont.getInputStream();
}
catch (ContentException e)
{ // TODO Auto-generated catch block
e.printStackTrace();
}
IWDResource wd_resource = WDResourceFactory.createCachedResource(inputStream, "FileName.html", WDWebResourceType.HTML, true);

if(wd_resource != null)
{
String url = wd_resource.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal());
}

Any conclusions or notes?

Best regards
Robert