Debugging WebLogic Server Applications Using Eclipse and the WebLogic-Plugin
Pages: 1, 2

Sample Application

For brevity, the application we will debug is a Hello World EJB. The source for this example has been zipped up and can be accessed here. There is a little bit of setup required in order to build the deployable JAR. The following sections describe the setup procedures. Note that we assume that you have already imported the zipped up project into Eclipse.

Create the WEBLOGIC Eclipse User Library

  • Window > Preferences > Java > Build Path > User Libraries.
  • Click the New... button and give the User library name a value of WEBLOGIC.
  • With the WEBLOGIC User Library selected, click the Add JARs... button.
  • Browse to your WEBLOGIC_HOME/server/lib directory and add the weblogic.jar and the webservices.jar.
  • Close all dialogs to have Eclipse rebuild your application with the new User Library.

The reason you have to create the WEBLOGIC User Library is because our EJB requires the WebLogic JARs in the WEBLOGIC User Library to compile. It is much easier to create User Libraries because you can use them over and over in other projects.

Source modifications

  • Modify the PROJECT_HOME/src/com/jwhitlock/ to have proper values for URL, username and password on lines 19, 20 and 21, respectively.
  • Modify the PROJECT_HOME/build.xml to have the proper value for your WebLogic home on line 5.

Assuming everything is configured properly, you should be able to run Ant on the PROJECT_HOME/build.xml and have it run successfully. You can do this by opening the build.xml in Eclipse and doing the following in the Outline view:

Right-Click "distribute[default]" > Run As > 2 Ant Build

If you get any build errors, look at the Console view for errors so you can resolve and try again.

Deploying Applications

Well...we now can start WebLogic Server. We can build the application too but to have some real fun, and to see how the WebLogic-Plugin really shines, let's get to the deployment and debugging of our application.

To deploy an application to your running WebLogic Server via the WebLogic-Plugin, all you have to do is right-click the server and fill the dialog out accordingly. The basics of this dialog describe the type of deployment, whether it's archived or exploded, and the path to the deployment. That is it. Let's see this in action:

Now watch the magic. Upon successful deployment, you'll get the usual debug information from the console. You also get real-time updates to your deployments tree in the WebLogic Servers view. As soon as WebLogic acknowledges that your application deployed successfully, the WebLogic Servers view will notify you of everything that was deployed. This becomes very useful when deploying whole applications with more than just a single EJB.

Figure 3 shows how the Weblogic Servers view updates when the EJB is successfully deployed.

Figure 3
Figure 3. WebLogic Servers view updating after successful EJB deployment (click for a full-size image)

Debugging The Application

Now that we've taken care of the basics on how to use the plug-in, we are ready to debug. Here are the requirements:

Since we are using the bundled Eclipse application mentioned earlier, Number 1 is not a problem. Number 2 is the first problem we run into because earlier, we just created values for the General tab. Let's fix this first before going on to the next:

With the classpath set up, let's update the Run Mode so that we can debug our application:

We're almost finished. All that is left is to perform is everything we've learned from start to finish then run the client that invokes the EJB and debug away. Here are the final steps:

You should notice that Eclipse either notifies you of a breakpoint being hit or will automatically switch to the Debug perspective.

Figure 4 shows the Eclipse debugger stopping at the line where you set your breakpoint.

Figure 4
Figure 4. Eclipse debugger in action (click for a full-size image)


And there you have it folks. We have learned how to successfully utilize the WebLogic-Plugin to manage a WebLogic Server's deployments and to debug those deployments. While the example in this article is extremely simple, it does cover the steps that you will always follow to manage and debug your WebLogic Servers and deployments regardless of deployment type.

Thanks for your time and I hope this helps ease the process of working with WebLogic in the Eclipse environment. For future features, project roadmap or anything else related to the WebLogic-Plugin, feel free to contact me or visit the WebLogic-Plugin home page.


Jeremy Whitlock is a consultant for CollabNet where he trains corporations on Subversion. He is also project owner of Dev2Dev's most popular project, eclipse-plugin, which provides extensions to Eclipse specifically for WebLogic Server.