Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to debug java web application in eclips with weblogic server

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

like image 800
user2881224 Avatar asked Sep 29 '14 16:09

user2881224


People also ask

How do I debug a WebLogic Server?

WebLogic Server debugging is based on the Java Platform Debugger Architecture (JPDA). Note: We are using the domain wl_server, to deploy and debug the provided application. To start WebLogic Server in debug mode, you will need to modify the startWebLogic. cmd script in the <WLS-root>\wlserver_10.

How do I enable debug in WebLogic managed server?

Select the Debug tab. Expand the scope labeled default or weblogic. Select the check box for the debug scopes or attributes you want to enable. Click Enable to enable (or Disable to disable) the debug scopes or attributes you have selected.

How do I run a debug server in eclipse?

To debug your application, select a Java file with a main method. Right-click on it and select Debug As Java Application. If you started an application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.


2 Answers

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:

  • Using Remote Debugging - BEA WebLogic Server
  • Weblogic remote debugging using eclipse
  • Debug Java applications remotely with Eclipse
  • Using the remote Java application launch configuration
like image 142
Federico Sierra Avatar answered Oct 28 '22 08:10

Federico Sierra


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.

like image 3
aryn.galadar Avatar answered Oct 28 '22 08:10

aryn.galadar