Wednesday, 12 October 2016

Debug Java Classes in Oracle Event Processing applications


In this post I will show how to debug java classes in Oracle Event Processing applications. We may need to use a Java class for many reasons such as to create custom adapters, Event Beans, DAO object and so on.

I will demonstrate how configure the debugger in JDeveloper using a HelloWorld sample project here, but obviously the principles could be applied to any OEP project.


Create the HelloWorld Application    

  1. In Oracle JDeveloper, select File > New > Application
  2. In the New Gallery dialog, select OEP Application and click OK.
  3. In the Create OEP Application wizard, provide HelloWorldApp for the name and click Next.
  4. Provide HelloWorld for the project name, select OEP Suite and click Next.
  5. In the Configure Java Settings dialog, click Next to accept the defaults.
  6. In the Configure OEP technology settings dialog in the OEP Application Template Name drop-down list, select HelloWorld.
  7. In the Configure OEP technology settings dialog in the OEP Server Connections drop-down list, select your server connection.
  8. Click Finish.

Start the OEP Server with debug option


To enable debug functionality, you have to start the server with the -debug option as demonstrated below:

          Windows

startwlevs.cmd -debug
 
          Linux

./startwlevs.sh -debug

The following message is displayed in the Server Console:


Configure the Debug/Run properties in JDeveloper

  1. Double click on the project to open the Project Properties dialog
  2. In the Project Properties dialog in the left window, select Run/Debug.
  3. In the right panel under Run/Debug, accept the default settings and click Edit .

  1. Select Launch Settings in the left window, and in the right window, select the Remote Debugging check box

  1. Select Tool Settings > Debugger > Remote in the left window, and in the right panel set the host and port parameters

          In this example, the host is LocalHost and the port is 8453.
  1. Click OK and click OK again to dismiss the dialogs.


Set Breakpoint in the HelloWorldBean

  1. To set breakpoints, open the HelloWorldBean.java. file in the project.
  2. Select the required line and press F5 where you want to toggle a breakpoint on.


Deploy the Project

  1. Right-click the project and select Deploy > New Deployment Profile from the context menu.
  2. In the Create Deployment Profile dialog in the Profile Type drop-down list, select OEP Project Deployment Profile.
  3. In the Create Deployment Profile dialog in the Deployment Profile Name field, provide helloworld as a unique name for the profile.

  1. Click OK.
  2. In the Deployment Properties dialog, check that the information is correct.
                  
                  Make any corrections that are needed.
  1. Click OK and Save.
  2. Right-click the project and select Deploy > helloworld
  3. Click Finish.
Now you should see the HelloWorld messages printed in the server console as shown below:


Start Debugging 

  1. Select the HelloWorld project, and Shift + F9. The Attach to JPDA Debugger dialog displays.



           You can also select the Debug button on the tool bar (red ladybug icon).
  1. In the Attach to JPDA Debugger dialog, check that the information is correct.
  2. Click OK.
The Debugging Log panel prints messages that show that the debugger is connected to the server.


And that’s it. Enjoy :)

No comments:

Post a Comment