7

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

Mind Peace
  • 905
  • 8
  • 29
user2881224
  • 71
  • 1
  • 1
  • 3

2 Answers2

11

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:

Bandham Manikanta
  • 1,858
  • 21
  • 21
Federico Sierra
  • 5,118
  • 2
  • 23
  • 36
  • "-Xnoagent Disables support for the old JDB debugger." (- internet) So in newer versions of Java this is unneeded. – Andrew Aug 07 '17 at 13:16
  • "If you see a WebLogic started under Servers, you are looking at an embedded server and not at the one you started via the command line. Make sure to stop any embedded server before starting via the command line as they will not be able to run on the same port together anyway." - https://stackoverflow.com/a/19806670/1599699 – Andrew Aug 07 '17 at 13:35
  • Lastly... make sure you set MW_HOME as well, if you're seeing "Error: Could not find or load main class weblogic.Server". – Andrew Aug 07 '17 at 14:12
3

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.

aryn.galadar
  • 716
  • 4
  • 13