• No results found

Debugging Portal Applications

N/A
N/A
Protected

Academic year: 2021

Share "Debugging Portal Applications"

Copied!
24
0
0

Loading.... (view fulltext now)

Full text

(1)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 1

Debugging Portal Applications

Applies to:

SAP NetWeaver Portal, and developers of portal applications

Summary

NetWeaver Developer Studio and the AS Java provide tools for helping you debug your applications. This document provides the very basics on starting to debug applications, and provides a short, simple but clear example on how the debugging tools can be used.

Author: Daniel Wroblewski Company: SAP AG Created on: 18 July 2007

Author Bio

(2)

Table of Contents

Overview ... 3

Collecting Required Information ... 4

Message Server Port ... 5

Debug Port ... 6

Enabling Debugging ... 9

Setting the AS Java ... 10

Starting Debugging ... 12 Debugging... 14 Set Breakpoints... 14 Inspect Variables... 15 Add Watches ... 16 Example ... 17

Open Portal Project... 18

Start Debugging ... 19

Run the Application ... 21

Related Content... 23

(3)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 3

Overview

The debugging tools of the AS Java and NetWeaver Developer Studio can help a lot in locating problems with your applications.

(4)

Collecting Required Information

To use debugging, you will need to know the following information: • Server Name: The host name for calling the portal in a browser • Server Port: The port number for calling the portal in a browser

(5)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 5

Message Server Port

To find the message server port:

1. Launch the AS Java home page by entering in your browser the URL http://<server>:<port>/ (the same as the main portal URL without the irj).

2. Click System Information. Information about the AS Java, such as the server name, instances and ports

(6)

Debug Port

(7)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 7

(8)

3. Navigate to cluster_data, and click Propertysheet.

A table of properties is displayed.

The debug port is listed under DebugPort.

Note:

(9)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 9

Enabling Debugging

1. Launch the Config Tool by double-clicking configtool.bat (located in the C:\usr\sap\<system ID>\<instance ID>\j2ee\configtool directory). 2. Click on the instance, and select the Servers Debug tab.

3. Make sure the debuggable and Enabled debug mode checkboxes are selected.

(10)

Setting the AS Java

1. In NetWeaver Developer Studio, select the menu item Window Æ Preferences. 2. Click SAP J2EE Engine, and enter the portal server and message port.

3. Click OK.

4. Open up the J2EE Engine view by navigating to Windows Æ Show View Æ Other, and selecting J2EE Æ

(11)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 11

5. Click to refresh the view.

(12)

Starting Debugging

Before starting to debug, make sure the current version of your project is deployed on the server. 1. Select debugging by either:

• Selecting Debug under the Debug icon.

(13)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 13

The Debug perspective is opened, and the configuration window is displayed.

2. Select Remote Java Application, click New, and set the following:

• Project: Select the project that you want to debug. Make sure its most recent version is deployed to the server on which you are debugging.

• Server: The server on which you are debugging. • Debug Port: The debug port of the server. 3. Click Debug.

(14)

Debugging

When debugging, you set breakpoints and watches in the portal component class files, and then run your portal component by navigating in the portal to an iView from your portal component. The portal component pauses when it hits a breakpoint, and the Debug view shows where you are in the component.

You can step over or into your code, and inspect variables, functions and expressions.

Set Breakpoints

1. Make sure the class file that you want to debug is open. You can open it from Enterprise Portal perspective before debugging.

2. Set a breakpoint by double-clicking at the start of the line.

(15)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 15

Inspect Variables

When the debugger has stopped at a breakpoint, you can inspect all the local variables, in the Variables window.

(16)

Add Watches

(17)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 17

Example

I have written a test portal component (HelloWorldProject.testLink) that takes a parameter with a navigation target and creates a link from it. The component tests to see if the parameter starts with the string pcd but, of course, if the parameter is null, the component will crash.

The code is as follows:

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {

String target = request.getParameter("myTarget"); if (target.startsWith("pcd")) {

response.write("Starts With PCD<BR>"); }

// Rest of code

}

And the iView displays the following when no parameter is sent. The exception is caught by the Portal Runtime.

At first, I do not know why it crashes (and I did not provide any exception handling for the sake of this example). So I choose to debug.

(18)

Open Portal Project

Open the portal project that you want to debug, and open the Java editor for the class file that contains the code to debug.

The following shows the HelloWorldProject, with the testLink class that contains the code to debug. The J2EE Engine view is shown at the bottom right.

(19)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 19

Start Debugging

1. Click Run Æ Debug.

2. Select Remote Java Application, and click New.

(20)

4. Click Debug.

The Debug perspective opens.

A list of threads is displayed in upper left, and windows for displaying breakpoints and watches are displayed in the upper right.

My code is also displayed in the middle.

(21)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 21

Run the Application

1. Now I open the portal and run my iView.

As soon as I click on the link to my iView (testLink), the debugger in the NetWeaver Developer Studio comes to life, the Debug perspective opens, and the execution stops at my breakpoint.

The line is highlighted and an arrow is displayed next to the line.

(22)

3. I check the variables, and notice that target is null.

4. I step through the next statement, and the component crashes. At the very least, I learn the statement that caused the crash.

I can also check the log at this point and see that a NullPointerException caused the problem.

#1.5#000BCDDCE9DE00700000000800000E2C00043584CF3F6D20#1184744435504#com.sap.portal.portal#sap.com/irj#com.sap.portal.portal#Administr ator#35#####Thread[PRT-Async 3,5,PRT-Async]##0#0#Error#1#/System/Server#Java###Exception ID:07:40_18/07/07_0005_4070150

[EXCEPTION]

{0}#1#com.sapportals.portal.prt.component.PortalComponentException: Error in service call of Portal Component Component : pcd:portal_content/DanielContent/DanRole/testLink

Component class : testLink User : Administrator at com.sapportals.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:969) at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:343) at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136) at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189) at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:355) at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:310) at com.sapportals.portal.navigation.workAreaiView.doContent(workAreaiView.java:169) at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209) at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114) at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328) at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136) at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable$1$DoDispatchRequest.run(AsyncIncludeRunnable.java:377) at java.security.AccessController.doPrivileged(Native Method) at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable.run(AsyncIncludeRunnable.java:390) at com.sapportals.portal.prt.core.async.ThreadContextRunnable.run(ThreadContextRunnable.java:164) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:729) at java.lang.Thread.run(Thread.java:534) Caused by: java.lang.NullPointerException

at testLink.doContent(testLink.java:16)

at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209) at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)

(23)

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 23

Related Content

• Debugging J2EE Applications

(24)

Copyright

© Copyright 2007 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

Java is a registered trademark of Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.

SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials.

References

Related documents

Specify the Apache port number when the following message is displayed:.. Specify the port where you wish to start Apache: Port

concepts from the behavioral sciences that are critical for the provision of excellent patient care and for functioning in the rapidly evolving health care system. The

No Post-Scriptum às Migalhas Filosófi cas, de 1846, há uma tese profundamente instigante sobre essa relação de Kierkegaard com a herança clássica e a herança cristã e, por

Using data on prose and quantitative literacy test scores, which depend both on the quantity and the quality of education, we cannot reject the hypothesis that compulsory

fonda financira se 16 mjera za podizanje konkurentnosti poljoprivredne proizvodnje i nepoljoprivrednih djelatnosti u ruralnim područjima uz unaprjeđenje životnih i radnih uvjeta

server IP address on port 4242. Server establishes a socket connection to client, using outgoing port number 2789 7. Server can listen for new. clients on the 4242 port number..

The remainder of this section of the paper will present the results obtained from this research, which include: the number of courses in Irish HEIs which include a

curately the amount of sample shown in Table 1, ac- cording to the expected acid value of the sample, in a glass-stoppered, 250-mL flask, add 100mL of a mix- ture of diethyl ether