Debugging Jakarta CDI Applications: A Quick Intro to Payara Server's CDI Tools
Published on 13 May 2024
by Luqman SaeedPayara Server offers integrated tools that streamline your development experience when working with Jakarta CDI (Contexts and Dependency Injection) in your applications. In this post, we'll take a look at the CDI Development Mode available in Payara Server and the CDI Probe it offers.
What is CDI Development Mode?
CDI Development Mode provides key tools and features that help you simplify the process of developing, inspecting and debugging CDI-backed applications. It allows for a much smoother development workflow.
The CDI Probe
Think of the CDI Probe as an x-ray machine. It gives you in-depth visibility into the CDI beans in your applications at runtime. You can monitor their behaviour, inspect their properties and diagnose potential issues.
Enabling CDI Development Mode
There are three ways to activate CDI Development Mode for your applications:
- During Deployment: When deploying your application using either the asadmin CLI or the Admin Console, enable it using a checkbox or a property.
- Web Application Configuration: Embed a context parameter within your application's web.xml file to automatically enable CDI Development Mode.
- Global Server Setting: Set a system property (org.jboss.weld.development=true) to enable CDI Development Mode for all applications deployed to your Payara Server.
Important: If you enable CDI Development Mode using multiple methods, the options that enable it take precedence and cannot be overridden.
Accessing the CDI Probe
Once CDI Development Mode is active, you have various ways to use the CDI Probe:
- REST API: Interact with the CDI Probe programmatically through its REST interface (for data integration or automation).
- Web Application: Access the intuitive CDI Probe web application directly within your browser or via a convenient link from the Payara Server's Admin Console.
- Web Page Toolbar: If your application has web pages, CDI Development Mode adds a toolbar that provides swift access to the CDI Probe and bean invocation details.
What the CDI Probe Can Do
The CDI Probe provides a glimpse into the intricate workings of your Jakarta CDI beans, giving you detailed debugging capabilities. It allows you to:
- Break down Bean Architecture: Visualise the dependencies between your CDI beans. This helps simplify complex architectures, making them easier to maintain and modify. It's particularly useful for onboarding new developers or when working with legacy code.
- Dig into Bean Data: Inspect the current state of your beans, including properties, fields and their values. This allows for real-time debugging – you can watch variables change in response to user inputs or system events, showing the true flow of data within your application.
- Track Event Sequences: Observe CDI bean events as they fire in real-time, providing a detailed timeline of bean interactions within your application. Pinpoint the exact triggers leading to specific consequences, enabling you to debug complex event-driven systems or verify that your logic behaves as intended.
- Unravel Execution Paths: Step through the chain of bean invocations as your application executes. This offers a powerful way to identify performance issues, find unexpected method calls or simply understand the intricate flow of control.
Summary
In essence, the CDI Probe allows you to proactively debug, maintain and optimise your Jakarta EE CDI applications in a simplified and intuitive way. Take a look at the detailed documentation page and download a copy of Payara Server Community today to get started using the CDI Tools!
Related Posts
Payara Community Survey - Have Your Say
Published on 16 Dec 2024
by Dominika Tasarz
0 Comments
Virtual Payara Conference is this week! See the Agenda Highlights
Published on 09 Dec 2024
by Dominika Tasarz
0 Comments
Virtual Payara Conference - find out more and register here - is a two-day, free event that brings together industry leaders, developers, and innovators to explore the latest advancements and strategic insights in the world of Java and Jakarta ...