Sunday, December 20, 2009

FAQ #4 – How to remote debug an ADF application deployed on WebLogic using JDeveloper 11g R1

Introduction

In the project that I am currently involved, the main ADF enterprise application is split into smaller logical units each represented by a separate JDeveloper application workspace. Each application can be debugged separately in JDeveloper using the integrated WebLogic application server. If we need however to debug the whole ADF application as deployed on the application server, the only way we could do so is through remote debugging.

Main Theme

The basic steps involved in remote debugging an ADF application deployed in WebLogic are summarized below:

  1. Installation and configuration of the WebLogic application server
  2. Configuration of WebLogic to support remote debugging
  3. Configuration of project in JDeveloper
  4. Actual debugging of the application
Of course steps 1 through 3 are done only once. Then we can remote debug each time we like. Below we will expand on each of these steps.

1. Installation and configuration of the WebLogic application server
Please refer to FAQ #1 – How to configue the standalone WebLogic server for deploying ADF applications from JDeveloper 11g R1 (11.1.1.2.0) for information about how to install and configure WebLogic.

2. Configuration of WebLogic to support remote debugging
In order to allow for remote debugging, there are a couple of configuration changes that need to be done to the WebLogic domain. First we need to edit the domain startup script startWebLogic.cmd and specify JVM options for starting the server in order to support remote debugging of ADF applications. The domain startup script can be located in the %MIDDLEWARE_HOME%\user_projects\domains\<domain_name>\bin directory, where %MIDDLEWARE_HOME% is the installation directory of WebLogic (and usually of JDeveloper) and <domain_name> is the name of the domain created previously.

Add the following line before the set JAVA_OPTIONS= line:

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

Change the set JAVA_OPTIONS= line to read like the one below:

set JAVA_OPTIONS=%SAVE_JAVA_OPTIONS% %ADF_JAVA_OPTIONS% %REMOTE_DEBUG_JAVA_OPTIONS%

Note that we added %ADF_JAVA_OPTIONS% in FAQ #1 – How to configue the standalone WebLogic server for deploying ADF applications from JDeveloper 11g R1 (11.1.1.2.0).

Finally we need to enable HTTP tunneling on the server. This is done after we first start WebLogic. To start WebLogic simply run the startWebLogic.cmd script. I have created a shortcut on the desktop to make it easily accessible.




Execute the startWebLogic.cmd script to start WebLogic and log onto the Admin Server Console. You can easily log onto the admin console by selecting the Admin Server Console from the Start Menu bar (Windows OS) - look under the Oracle Fusion Middleware 11.1.1.2.0 > User Projects > domain2 folder - or specifying http://localhost:7001/console in your browser.

Enter the username and password of the WebLogic administrator. You had specified the administrator credentials during the creation of the domain earlier. The default credentials are weblogic/weblogic1.



In the Home Page select Servers under the Environment section.


In the Summary of Servers click on the name of the server (AdminServer in this case).



In the Settings for AdminServer page select the Protocols tab and click on Enable Tunneling.




OK, we are almost there! A few more configuration changes in the JDeveloper project to be remotely debugged and we should be up and running with remote debugging in a sec.


3. Configuration of project in JDeveloper

First let’s create a run configuration specifically for remote debugging. Double-click on the ViewController project in your ADF application to bring up the Project Properties and select the Run/Debug/Profile page. Click New… to create a new run configuration. In the Create Run Configuration dialog enter Remote Debug for the name of the run configuration. Leave the Copy Settings From selection to Default and click OK to create the new run configuration.



Once the Remote Debug run configuration is created, select it in the Run Configurations and click Edit… to bring up the Edit Run Configuration dialog. In the Launch Settings page click on the Remote Debugging checkbox to enable remote debugging for this run configuration.



Finally select the Remote page and verify that the Protocol is set to Attach to JPDA and the port matches the port specified earlier when configuring WebLogic for remote debugging (defaults to 4000).




4. Actual debugging of the application

Now we are ready to remote debug our ADF application. Well, almost! First we need to create a connection to the WebLogic server, create deployment descriptors for the project and the application and deploy our ADF application to server. To deploy directly from JDeveloper refer to FAQ #3 - How to deploy an ADF application on a standalone WebLogic server directly from JDeveloper.

Once the application is deployed to the WebLogic server we can get down with the actual remote debugging task. To do so, right-click on the ViewController project and select Start Remote Debugger from the context menu.


Verify the attachment details shown in the Attach to JPDA Debugee and click OK to attach to the remote debugger.



That’s it, you are remote debugging! Bring up your application on your Web browser and test it. Debug as usual, setting break points, watching variables, examining the calling stack and so on.

Conclusion

Remote debugging comes handy in situations where enterprise applications are split-up across multiple JDeveloper application workspaces. Also it comes handy if you want to keep different reference versions of the application deployed on the server and you want to debug an older or different version. I have also noticed substantial performance improvement in JDeveloper during the remote debugging session.

Until the next time, keep on JDeveloping!

References











4 comments:

  1. Hi ,

    Am getting this error after "selecting Start Remote Debugger from the context menu."

    Debugger attempting to connect to remote process at LocalHost 4000.
    ......

    Any Clue y this is happening ? TY

    ReplyDelete
  2. Thomas did you start the remote debugging server too?

    ReplyDelete
  3. Hi, I am also getting the same error as Thomas...

    ReplyDelete
  4. I would make sure that weblogic is running on the host and port specified. I would also make sure that weblogic was started with debugFlag=true and that debug port was specified via the DEBUG_PORT parameter in the setDomainEnv script.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...