Você está na página 1de 9

Root Cause Analysis for the Portal

Runtime Error in Portal


Applications

Applies to:
SAP Enterprise Portal 6.0 onwards. For more information, visit the Portal and Collaboration homepage.

Summary
This article explains how to analyze the root cause for the Portal Runtime Error in portal applications. It
provides a step-by-step guide to locate the line of code that has caused the error.
Author:

Melwyn Monis

Company: L&T Infotech


Created on: 2 March 2010

Author Bio
Melwyn Monis is a SAP Certified NetWeaver Portal Consultant from L&T Infotech with over 3.5 years of SAP
experience. Has worked in various SAP NetWeaver areas such as Portal, KM, Web Dynpro for Java, Adobe
Forms and VC. Has experience in Btexx easyWCM 2.0 a third party Content Management tool that
provides and manages any service or content within the SAP NetWeaver Portal.

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


1

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Table of Contents
Background ......................................................................................................................................................... 3
Assumptions ....................................................................................................................................................... 3
Viewing the Error in the SAP NetWeaver Administrator ..................................................................................... 4
Understanding the JSP Class Concept .............................................................................................................. 5
Locating the Java file .......................................................................................................................................... 5
Step 1 Accessing the Tool ........................................................................................................................... 5
Step 2 Locating the Application ................................................................................................................... 5
Step 3 Fetching the Correct file .................................................................................................................... 6
Step 4 Copying the Source Code ................................................................................................................ 6
Step 5 Finding the Exception in the Source Code ....................................................................................... 7
Conclusion .......................................................................................................................................................... 8
Related Content .................................................................................................................................................. 8
Disclaimer and Liability Notice ............................................................................................................................ 9

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


2

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Background
While viewing the output of portal applications at runtime we often come across the Portal runtime error
message on the screen. This error message may indicate either a logical exception or a syntax exception or
some other general exception which has stalled the execution and hence the display of the output. For an
application developer it is now a task of analyzing and resolving the error.
The problem here is, finding out the root cause of the error is not as easy as it seems. The error message
that is displayed on the portal screen is as follows:

It does not provide the line number or cause of the error. To get the details about the exception, one needs
to lookup the error either in the Log Viewer or the NWA.

Assumptions
This article assumes the reader has a good understanding of the following topics and hence will not be a part
of this article:

Creating Portal Applications

Using the SAP NetWeaver Developer Studio (SAP NWDS)

Usage of the SAP NetWeaver Administrator tool (SAP NWA) / Log Viewer

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


3

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Viewing the Error in the SAP NetWeaver Administrator


To fetch the details about the error you will need to use the SAP NetWeaver Administrator (NWA) or the Log
Viewer. This article uses the NWA approach for viewing the error details.
Log on to the NWA using the URL http(s)://<server>:<port>/nwa. You need to provide a valid user id and
password for which access is provided to view the logs and traces.
Under System Management tab > Select Monitoring > Select link Logs and Traces. This tool displays the log
files which contains the error details. Log files can be accessed using the Default Trace option, Last 24
Hours option as well as the SAP Logs option by selecting the appropriate value from the dropdown box. This
article uses the Default Trace option. You will now see the errors/warnings/information texts that are entered
into the log files as table entries.
Using the Exception ID of the error message displayed on the portal screen, you may locate the entry in the
Default Trace table. The resulting table entry corresponds to the details of the error message that has
occurred.

The error message displayed in the figure above only provides us with the exception type that has occurred
i.e. java.lang.NullPointerException. It does not provide us with detailed information about the error though.
This is true especially in portal applications containing Java Server Pages (jsp). These are typically portal
applications of type JSPDynPage components.
If an error occurs due to code in the .jsp file, the log file entry does not provide us with the line number in the
jsp code that has caused the error. Instead, it provides the line number of the internally generated files. In
this case _sapportalsjsp_SampleJSP.java file as shown in the above figure.

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


4

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Understanding the JSP Class Concept


When the JSP is first accessed, the portal creates a .java file that defines a class that extends
AbstractPortalComponent that is based on the JSP page, and then compiles the file into a .class file. When
the JSP is called, it is this class that is executed, not the JSP. The name of the java file is
_sapportalsjsp_[name of JSP file].java. In this article, it corresponds to _sapportalsjsp_SampleJSP.java
where SampleJSP is the name of the .jsp file in which the error has occurred.
The portal places the .java and .class files in a new folder called work in the /WEBINF/portal/portalapps/<application name> folder, where application name is the portal application in which
the JSP is packaged.
In order to find the correct cause of the error we will need to view the code of the generated
_sapportalsjsp_SampleJSP.java file.

Locating the Java file


The _sapportalsjsp_SampleJSP.java file is not among the files in the portal application created using the
NWDS. This file is generated by the portal and is hence available on the server. To access this file you would
require either the Java Developer role or the System Administration role.
Step 1 Accessing the Tool
Log on to the portal with a valid user id and password for which either of the above mentioned roles are
available. This article uses the System Administration role.
Select System Administration > Support > Portal Runtime > Browse Deployment

Step 2 Locating the Application


From the breadcrumb displayed, Select ROOT > Click on the browse link for WEB-INF > Click on the browse
link for portal > Click on the browse link for portalapps. A table containing the list of all deployed applications
is displayed. Locate your relevant application from the list. This article uses the application called
SamplePar.

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


5

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Step 3 Fetching the correct file


Select browse corresponding to your application name > Click on the browse link for work > Click on the
browse link for pagelet. A table containing the list of the generated .java and .class files is displayed.

As per the log file entry for the error, we need to use the _sapportalsjsp_SampleJSP.java file. The log file
entry indicates that line nos. 24, 40 and 147 are the lines of code where the exception has occurred.
Step 4 Copying the Source Code
To find the above line numbers click on the view link for _sapportalsjsp_SampleJSP.java. A popup window
will appear which will display the source code of the selected file. However, the source code that is displayed
in the browser window does not contain line numbers.

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


6

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Step 5 Finding the Exception in the Source Code


To find the line number in the source code containing the error, copy all the contents of the source code
displayed in the browser. This article uses the SAP NetWeaver Developer Studio (SAP NWDS) containing a
java project with an empty java file to view the source code.
To enable visibility of line numbers in the java source code, launch the SAP NWDS. From the menu, Select
Window > Preferences > Expand the tree node Java > Select the node Editor > Tick the Show line numbers
checkbox > Click Apply and OK.
While in the Java Perspective of SAP NWDS, open the empty java file and paste the copied contents of the
source code. You will now be able to see the source code containing the line numbers. To locate the line
numbers pointed out by the log file entry use CNTRL + L and enter the line number where the exception has
occurred. It will point out the line of code which has caused the exception.

Using the highlighted line, you will now be able to identify the root cause of the error. As in the figure above,
it is clear that a Null Pointer Exception occurred due to the fact that an operation was performed on a string
variable containing a null value.

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


7

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Conclusion
This technique for finding the root cause of the Portal Runtime Error proves very handy for applications
containing complex JSPs. It can be used to track logical as well as syntax errors. It reduces the effort spent
trying to debug the jsp using print statements and also aids the developer in easily tracing the errors
encountered using standard SAP tools.

Related Content
Log Viewer Basics
Portal Applications
SDN Portal e-Learning Catalog
For more information, visit the Portal and Collaboration homepage.

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


8

Root Cause Analysis for the Portal Runtime Error in Portal Applications

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not
supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,
and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or
code sample, including any liability resulting from incompatibility between the content within this document and the materials and
services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this
document.

SAP COMMUNITY NETWORK


2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com


9

Você também pode gostar