Developing for WebLogic Server 8.1 with Oracle JDeveloper 10g
Pages: 1, 2, 3, 4, 5

Remote Debugging a WebLogic Application

The JDeveloper IDE has the provision to remote debug applications deployed in WebLogic Server with a remote debugger. In this section, the example J2EE application deployed to WebLogic Server will be debugged in JDeveloper. For the JDeveloper debugger to debug an application deployed in WebLogic Server, start the server in debug mode. WebLogic Server debugging is based on the Java Platform Debugger Architecture (JPDA). For the J2EE application deployed in the previous section, the server was not started in debug mode. Uninstall the J2EE application that was deployed in the previous section from WebLogic Server. The server will be restarted in the debug mode. To start WebLogic Server in debug mode, modify the startWLS script in the <weblogic81>\server\bin directory. <weblogic81> is the directory in which WebLogic Server 8.1 is installed. In the startWLS script, specify the JAVA_OPTIONS with:

set JAVA_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=4000,suspend=n

The -XDebug parameter enables debugging. The -Xnoagent parameter disables the default debug agent. The -Xrunjdwp parameter loads the JPDA reference implementation of JDWP. The JDWP protocol is the protocol used to debug with a remote debugger. Start WebLogic Server in debug mode. The remote debugger in the JDeveloper IDE is not available by default. Set the remote debugging feature in JDeveloper by selecting the Profiles>Development>Debugger>Remote node in the Project Properties frame. Select the Remote Debugging checkbox, and then select the Attach to JPDA radio button.

Figure 23
Figure 23. Setting remote debugging

To debug a JSP with the remote debugger, add the debug param to the weblogic.xml deployment descriptor. Set the debug param value to true in the weblogic.xml deployment descriptor in the View project:


Figure 24
Figure 24. Specifying the debug parameter in weblogic.xml

Next, add breakpoints to the JSP. Select View>Debugger>Breakpoints.

Figure 25
Figure 25. Setting breakpoints

The Breakpoints frame will be displayed. The breakpoints enabled by default are listed in the Breakpoints frame. To add a new breakpoint, right-click in the Breakpoints frame, and select New Breakpoint. The New Breakpoint frame will be displayed. As an example, select the Exception class NullPointerException.

Figure 26
Figure 26. Breakpoint class

The NullPointerException breakpoint will be added to the Breakpoints frame. To demonstrate the remote debugging, add an error to the JSP. Replace

 InitialContext ctx=new InitialContext();


InitialContext ctx=null;

Setting InitialContext to null would generate a NullPointerException in the JSP application. As in the previous section, generate the deployment profile for the Web application and a deployment profile for the J2EE application. Deploy the J2EE application to WebLogic Server as in the previous section. Access the WebLogic Server Administration Console with the URL: http://localhost:7001/console. Next, start the remote debugger. Right-click on the View project, and select Remote Debugger.

Figure 61
Figure 27. Starting the remote debugger

In the Debugger frame, specify localhost as the Host, and 4000 as the Port. Port 4000 was specified in the -Xrunjdwp parameter used to start WebLogic Server in debug mode.

Figure 28
Figure 28. Debugger Host and Port

The remote debugger will start and will be connected to WebLogic Server.

Figure 29
Figure 29. Debugger output

In the WebLogic Server administration console, invoke the weblogic.jsp JSP that has an error ( InitialContext is set to null) with the URL:


The debugger finds the exception. If the debugger is not able to find the source JSP file, an Unable to Find Source File frame may get displayed. Select Let me find the file myself with the open file dialog radio button. Select the weblogic.jsp in the View/public_html directory. The code that has generated the NullPointerException will be highlighted in the JSP.

Figure 56
Figure 30. JSP code with error

Debug the JSP application with the different debug options in the JDeveloper IDE. In this section, a J2EE application deployed in WebLogic Server from the JDeveloper IDE was debugged with the JDeveloper remote debugger.


This tutorial has shown how a WebLogic Server application may be developed in the JDeveloper IDE and deployed to a WebLogic Server instance from JDeveloper. The remote debugger adds the provision to debug deployed applications. The J2EE application wizards and the application server connection wizard facilitate the development and deployment of applications. I hope this gives you enough grounding to start using JDeveloper and WebLogic Server together.


Deepak Vohra is a NuBean consultant and web developer. He is a Sun Certified Java 1.4 Programmer and Sun Certified Web Component Developer for J2EE.