How to debug Java enterprise applications with EJB breakpoints

Debugging an enterprise application can feel quite different from stepping through a small Java console program. Requests may pass through servlets, dependency injection, session beans, persistence layers and message queues before a visible result appears. NetBeans IDE helps make that path observable by connecting source code to the running application server. Learn more about How Much Do High Rollers Win.

EJB breakpoints are especially useful when a defect involves business logic, transaction boundaries or state shared between requests. Rather than relying only on log statements, you can pause a method, inspect injected services and examine the values that led to an unexpected outcome.

The workflow is suitable for teams building Java EE or Jakarta EE systems across Australia, whether the application runs locally in Sydney, on a Melbourne development workstation or on infrastructure serving customers in Brisbane and Perth. The labels may vary slightly between NetBeans releases and application servers, but the debugging principles remain consistent.

Debugging approach Best use Main limitation
Line breakpoint in an EJB Inspecting method flow and variables Stops only when the selected code executes
Conditional breakpoint Finding a fault affecting one customer or order Conditions can slow execution
Exception breakpoint Locating the source of thrown exceptions May pause on handled exceptions
Logging and log levels Observing asynchronous or production behaviour Does not provide live variable inspection
Remote debugging Investigating an application on another server Requires secure debugger configuration

Prepare the NetBeans project and server

Before placing a breakpoint, confirm that the project builds successfully and that NetBeans has the correct source files. A typical enterprise project may contain an EJB module, a web module and an EAR packaging project. Clean and build the application so the generated classes and deployment descriptors match the source currently open in the IDE.

Start the configured application server from the Services window, or deploy the project to a running server. GlassFish, Payara, WildFly and similar platforms expose Java debugging through a socket or server integration. Check the server output for a successful deployment message before testing a browser request, REST call or message producer.

If a local team is working on an NBN connection while the server sits in a different region, allow for network latency during remote debugging. A short pause in the debugger can become much longer when the application is hosted outside Australia, so begin with a focused breakpoint rather than stopping every method.

Place breakpoints in session beans

Open the implementation class for a stateless, stateful or singleton session bean. Click the left margin beside a line inside a business method, such as an order validation, payment calculation or customer lookup. A red breakpoint marker indicates that NetBeans will suspend the relevant thread when execution reaches that line.

Choose a line that will execute after the method has entered its useful logic. A breakpoint on a declaration, annotation or unreachable branch will not help. For a suspected input problem, place the marker after parameters have been received and inspect values such as account identifiers, collection sizes and security roles.

Start the debugger with the project’s Debug command rather than ordinary Run. NetBeans should attach its debugger to the server process, then open the Debugging, Variables, Call Stack and Watches windows. Trigger the application operation from a browser, REST client or test.

Inspect calls, transactions and injected services

When execution stops, use Step Over to move through the current bean without entering every called method. Step Into is useful when the defect may be inside a repository, converter or another EJB. Step Out returns to the calling method after the current operation has completed.

The Call Stack reveals how the request reached the bean. It may show a servlet, interceptor, proxy and business method rather than a direct call. Inspect the Variables window for transaction flags, entity values and injected references. A proxy object may not display all useful state until you step into the target implementation.

For a detailed view of interactions between components, generate a UML sequence diagram from the Java code before debugging. It can clarify whether a failure occurs in the web tier, an EJB callback, a persistence operation or an asynchronous hand-off.

Use conditional and exception breakpoints

A conditional breakpoint is valuable when the same method processes hundreds of records but only one causes trouble. Right-click the breakpoint, open its properties and add an expression such as order.getId() == 4821 or a suitable status check. Use valid Java syntax and avoid expressions that mutate application state.

Exception breakpoints are useful for NullPointerException, persistence exceptions and security failures that are wrapped before reaching the user interface. Configure them through the Breakpoints window, then decide whether NetBeans should stop when an exception is thrown, caught or both.

Keep conditions simple in a busy application. Calling a service, loading a lazy relationship or changing a bean through a debugger expression can affect transaction behaviour. A small logging statement may be safer when the application is processing live-like data.

Debug message-driven beans and asynchronous work

Message-driven beans require a different testing rhythm because the business method runs after a message arrives on a queue or topic. Set the breakpoint inside onMessage, start debugging and publish a test message using the application’s normal producer. The debugger will pause only when the destination delivers a message to that bean instance.

Inspect message headers, correlation identifiers and deserialised payloads. If the breakpoint never activates, verify the destination name, connection factory, listener configuration and deployment status. Also check that the message was not consumed by another running server instance.

Asynchronous processing can make log correlation harder. Add a request or message identifier to relevant log lines, and consider colourised terminal output when scanning different log levels during a long debugging session. Australian teams often use “arvo” deployments or shared test environments, so clear identifiers help separate one test run from another.

Handle remote debugging safely

For an application running outside the local machine, enable the Java Debug Wire Protocol on the target JVM with a secured, restricted listener. Configure NetBeans with the server address, port and matching source files. Never expose an unrestricted debug port to the public internet; use a VPN, SSH tunnel or private network path.

Compile the deployed application with debugging information and ensure the local source matches the deployed build. If line numbers appear wrong or breakpoints show as hollow, the class may have been rebuilt, obfuscated or loaded from a different module. Redeploy the exact artefact and restart the server when necessary.

Use remote breakpoints sparingly in production. Suspending an EJB can hold database connections, locks or transaction resources, affecting other customers. For a public-facing Australian service, capture a safe reproduction in staging first. A local business application may depend on Google Business Profile traffic, so a sudden pause in its booking or enquiry workflow can have an immediate commercial effect.

Verify the fix with focused tests

After identifying the faulty branch, remove broad breakpoints and create a focused test for the behaviour. EJB tests should cover valid input, failed validation, transaction rollback and security restrictions where those concerns affect the method. For message-driven beans, test duplicate delivery and malformed payloads as well as the normal message path.

Rebuild and redeploy before repeating the original operation. Confirm that the debugger now passes through the corrected code and that the server logs contain no hidden warnings. Review database changes and queued messages so a successful screen response has not concealed a partial failure.

A disciplined NetBeans debugging session combines source-level breakpoints, call-stack inspection, server logs and repeatable test data. That approach makes complex enterprise execution easier to follow without turning every request into a slow, opaque investigation.