how to debug java web application in eclips with weblogic server

26,727

Solution 1

In startWeblogic.cmdfile, add the following line before ENDLOCAL line.

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

The Weblogic Server console should display the message:

Listening for transport dt_socket at address: 8453

In eclipse follow the instructions below:

  1. Select Run > Debug Configurations... from the workbench menu bar (or Debug Configurations... from the drop-down menu on the Debug tool bar button) to show the launch configuration dialog.
  2. Select the Remote Java Application in the list of configuration types on the left.
  3. Click the New toolbar button. A new remote launch configuration is created and three tabs are shown: Connect, Source, and Common.
  4. In the Project field of the Connect tab, type or browse to select the project to use as a reference for the launch (for source lookup). A project does not need to be specified.
  5. The Connection Type field of the Connect tab allows you to choose how you will connect to the virtual machine. In most cases, you will be attaching to the vm at a specific location, in which case select Standard (Socket Attach). the rest of these instructions assume you have chosen this option. The Standard (Socket Listen) connection type creates a launch that will listen for incoming connections from a remote VM. You will need to specify a port that the launch will listen at.
  6. In the Host field of the Connect tab, type the IP address or domain name of the host where the Java program is running.If the program is running on the same machine as the workbench, type localhost.
  7. In the Port field of the Connect tab, type the port where the remote VM is accepting onnections. Generally, this port is specified when the remote VM is launched.
  8. The Allow termination of remote VM flag is a toggle that determines whether the Terminate command is enabled in the debugger. Select this option if you want to be able to terminate the VM to which you are connecting.
  9. Click Debug. The launch attempts to connect to a VM at the specified address and port, and the result is displayed in the Debug view. If the launcher is unable to connect to a VM at the specified address, an error message appears.

Docs:

Solution 2

First, make sure you enable remote debugging on your startup script for Weblogic:

-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n

(address is the port number; remember this number)

Second, you need to set up a new Remote Web Application debug configuration in Eclipse:

Run -> Debug Configurations...

then create a new Remote Web Application configuration. Make sure you specify your host and port (noted above), and add any source for the web app on the Source tab.

You should now be able to run that debug configuration to debug a web app in Eclipse on the specified Weblogic server.

Share:
26,727
Admin
Author by

Admin

Updated on February 08, 2020

Comments

  • Admin
    Admin about 4 years

    I have java application with Eclipse IDE and WebLogic 11g server. Is it possible to debug application remotely? if yes how?