Bring AI and build AI agents
into your Jakarta EE application
with LangChain4J CDI.
2025/11/25
XtremeJ Conference 2025
• Enterprise solutions architect, consultant.
• 20 years of solid Java / Enterprise Java development experience.
• Founded Devoxx4Kids South Africa (NPO) – introducing kids to
coding, robotics, AI, etc., in a fun way.
• JakartaEE / Microprofile Working Group member.
• Jakarta EE Ambassador.
• Member of the JCP
• Tech speaker
• Blogger / Content writer
• Langchain4J CDI committer.
Friday, November 21, 2025 Who am I? 2
IO.println(“I’m Buhake Sindi”);
X: @EliteGentleman
Other socials: @buhake.sindi
: buhake@gmail.com
https://linktr.ee/theEliteGentleman
Friday, November 21, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
3
Where to find me?
Friday, November 21, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
4
LangChain4J
Introducing…
• Initially inspired by LangChain (Python)
• A fully open-source Java library for Large Language Model
(LLM) integration.
• Unified API model for LLM integration.
• Comprehensive toolbox, providing common abstraction for common
features, including prompt engineering, function and tool
calling, RAG, memory management, etc.)
• Integrates with a variety of vector stores & document loaders,
for easy LLM interactions.
• Support AI Agents and Services, through the core feature of
AiServices, developers can create AI agents and define its
behaviour using Java interfaces.
• GitHub repo: https://github.com/langchain4j/
Friday, November 21, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
5
What is LangChain4J?
• High level, declarative API
• Hides the low-level components & complexities of
interacting with LLMs.
Friday, November 21, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
6
LangChain4J AiServices
Friday, November 21, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
7
Example of an AiServices
• Create an interface without
implementation.
• Register your interface,
along with LangChain4J
components using AiServices
factory.
• Familiarity: Jakarta EE APIs are familiar with
API level interfaces.
• What if?
• Make low-level APIs configurable?
• Apply enterprise-level context and scope to AI
services?
• Apply resiliency to AI services?
• Apply Observability to your ChatModel (if
supported)?
Friday, November 21, 2025 Presentation Title 8
For enterprise Java developers…
Saturday, November 22, 2025 Presentation Title 9
Introducing…
LangChain4J CDI
• A Jakarta EE with AI starter project. Initally called SmallRye-LLM.
• Donated to LangChain4J and renamed as LangChain4J CDI.
• CDI extension that enables the injection of AI services.
• Declare your AI service with @RegisterAIService annotation (CDI
stereotype).
• The container handles the proxy creation of the AiServices and
lifecycle management.
• Use the standard @Inject annotation to bring your AI services into
your REST resource or other CDI beans.
• Requirements:
• Jakarta EE 10, and higher
• JDK 17, and higher
• Tested: Helidon, Quarkus, WildFly, Payara, OpenLiberty, GlassFish
• GitHub: https://github.com/langchain4j/langchain4j-cdi
Monday, November 24, 2025 Presentation Title 10
What is LangChain4J CDI?
Saturday, November 22, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
11
• Annotation attribute
value
matches CDI bean name.
• Value of “#default”
enables the CDI
container to select
default CDI bean of
relevant
LangChain4J component.
• Empty attribute value
disables CDI bean
lookup.
@RegisterAIService
Sunday, November 23, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
12
@RegisterAIService
Sunday, November 23, 2025 Presentation Title 13
• Via Microprofile
Config.
• All low-level
LangChain4J components
are supported,
provided they have a
Builder object
provided.
• All config keys must
be prefixed with the
dev.langchain4j.plugin
.<cdi-bean-name>.
Keyword.
Configurable
Monday, November 24, 2025 Presentation Title 14
• LLMs are stateless by
default. To build a
true agent, one needs
to include memory.
• With addition of
ChatMemory component,
LangChain4J
automatically appends
previous messages to
current prompts.
Stateful conversations
Monday, November 24, 2025 Presentation Title 15
• Via Microprofile Fault
Tolerance.
• Apply any MP Fault
Tolerance interceptor
annotations (e.g.,
@Retry, @Fallback,
@Timeout, etc.), the
same way you would to
existing CDI bean.
Adding resiliency
Monday, November 24, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
16
• Via Microprofile Telemetry.
• Can register either Span,
Metrics, or both.
• Each ChatModelListener can be
assigned via MP Config.
• “lookup:@all” allows CDI to
seek all Telemetry beans and
register it to the ChatModel.
• Alternatively, specify the
full-qualified classname of
either SpanChatModelListener,
MetricsChatModelListener,
separated by a comma.
• OpenTelemetry Semantic
Convention for Generative AI
Spans.
• OpenTelemetry Semantic
Convention for Generative AI
Metrics.
Applying Observability
Monday, November 24, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
17
• Maven:
• GroupId:
dev.langchain.cdi
• Add CDI portable extension
module to your Maven POM
• Add the following
ArtifactId to enable its
features:
• MP Config: langchain4j-
cdi-config
• MP Fault Tolerance:
langchain4j-cdi-fault-
tolerance
• MP Telemetry:
langchain4j-cdi-
telemetry
Getting started with LangChain4J-CDI
Monday, November 24, 2025 Presentation Title 18
Putting it all together.
• LangChain4J-CDI:
• GitHub: https://github.com/langchain4j/langchain4j-cdi
• Example: https://github.com/langchain4j/langchain4j-
cdi/tree/main/examples
• LangChain4J:
• URL: https://docs.langchain4j.dev/
• GitHub: https://github.com/langchain4j/langchain4j
• Article: Build AI Apps and Agents in Java: Hands-on with LangChain4J
(by Lize Raes): https://javapro.io/2025/04/23/build-ai-apps-and-agents-
in-java-hands-on-with-langchain4j/
• Article: Bring AI into your Jakarta EE apps with LangChain4J-CDI
(formerly SmallRye-LLMM): JavaPRO Magazine, 04-2025, Java 25 – Special
Edition. Page, 96 (by Buhake Sindi). https://javapro.io/2025/10/28/04-
2025-java-25-special-edition/
Monday, November 24, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
19
Resources
• Spring Boot LangChain4J:
https://docs.langchain4j.dev/tutorials/spring-boot-
integration
• Quarkus LangChain4J:
https://docs.quarkiverse.io/quarkus-
langchain4j/dev/index.html
• Helidon MP LangChain4J:
https://helidon.io/docs/v4/mp/guides/langchain4j
• Micronaut LangChain4J: https://micronaut-
projects.github.io/micronaut-langchain4j/latest/guide/
Monday, November 24, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
20
Not to be confused with…
• Jakarta Agentic Artificial Intelligence:
• Still under development, under the Eclipse
Foundation.
• The project provides a set of vendor-neutral APIs
that make it easy, consistent, and reliable to
build, deploy, and run AI agents on Jakarta EE
runtimes.
• Anybody can contribute to the development of the
Jakara Agentic AI specifications.
• More info: https://jakarta.ee/specifications/agentic-
ai/
Monday, November 24, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
21
Finally…
Tuesday, November 25, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
22
Demo!
• sindi-ai-chatbox
• GitHub:
https://github.com/TheEliteGentlem
an/sindi-ai-chatbot
Tuesday, November 25, 2025
Bring AI and build AI agents into your Jakarta
EE application with LangChain4J CDI.
23
THANK YOU
Any Questions?
Buhake Sindi
x: @EliteGentleman
Other socials: @buhake.sindi
https://linktr.ee/theEliteGentleman

Bring AI and build AI agents into your Jakarta EE Apps with LangChain4J-CDI

  • 1.
    Bring AI andbuild AI agents into your Jakarta EE application with LangChain4J CDI. 2025/11/25 XtremeJ Conference 2025
  • 2.
    • Enterprise solutionsarchitect, consultant. • 20 years of solid Java / Enterprise Java development experience. • Founded Devoxx4Kids South Africa (NPO) – introducing kids to coding, robotics, AI, etc., in a fun way. • JakartaEE / Microprofile Working Group member. • Jakarta EE Ambassador. • Member of the JCP • Tech speaker • Blogger / Content writer • Langchain4J CDI committer. Friday, November 21, 2025 Who am I? 2 IO.println(“I’m Buhake Sindi”);
  • 3.
    X: @EliteGentleman Other socials:@buhake.sindi : [email protected] https://linktr.ee/theEliteGentleman Friday, November 21, 2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 3 Where to find me?
  • 4.
    Friday, November 21,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 4 LangChain4J Introducing…
  • 5.
    • Initially inspiredby LangChain (Python) • A fully open-source Java library for Large Language Model (LLM) integration. • Unified API model for LLM integration. • Comprehensive toolbox, providing common abstraction for common features, including prompt engineering, function and tool calling, RAG, memory management, etc.) • Integrates with a variety of vector stores & document loaders, for easy LLM interactions. • Support AI Agents and Services, through the core feature of AiServices, developers can create AI agents and define its behaviour using Java interfaces. • GitHub repo: https://github.com/langchain4j/ Friday, November 21, 2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 5 What is LangChain4J?
  • 6.
    • High level,declarative API • Hides the low-level components & complexities of interacting with LLMs. Friday, November 21, 2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 6 LangChain4J AiServices
  • 7.
    Friday, November 21,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 7 Example of an AiServices • Create an interface without implementation. • Register your interface, along with LangChain4J components using AiServices factory.
  • 8.
    • Familiarity: JakartaEE APIs are familiar with API level interfaces. • What if? • Make low-level APIs configurable? • Apply enterprise-level context and scope to AI services? • Apply resiliency to AI services? • Apply Observability to your ChatModel (if supported)? Friday, November 21, 2025 Presentation Title 8 For enterprise Java developers…
  • 9.
    Saturday, November 22,2025 Presentation Title 9 Introducing… LangChain4J CDI
  • 10.
    • A JakartaEE with AI starter project. Initally called SmallRye-LLM. • Donated to LangChain4J and renamed as LangChain4J CDI. • CDI extension that enables the injection of AI services. • Declare your AI service with @RegisterAIService annotation (CDI stereotype). • The container handles the proxy creation of the AiServices and lifecycle management. • Use the standard @Inject annotation to bring your AI services into your REST resource or other CDI beans. • Requirements: • Jakarta EE 10, and higher • JDK 17, and higher • Tested: Helidon, Quarkus, WildFly, Payara, OpenLiberty, GlassFish • GitHub: https://github.com/langchain4j/langchain4j-cdi Monday, November 24, 2025 Presentation Title 10 What is LangChain4J CDI?
  • 11.
    Saturday, November 22,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 11 • Annotation attribute value matches CDI bean name. • Value of “#default” enables the CDI container to select default CDI bean of relevant LangChain4J component. • Empty attribute value disables CDI bean lookup. @RegisterAIService
  • 12.
    Sunday, November 23,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 12 @RegisterAIService
  • 13.
    Sunday, November 23,2025 Presentation Title 13 • Via Microprofile Config. • All low-level LangChain4J components are supported, provided they have a Builder object provided. • All config keys must be prefixed with the dev.langchain4j.plugin .<cdi-bean-name>. Keyword. Configurable
  • 14.
    Monday, November 24,2025 Presentation Title 14 • LLMs are stateless by default. To build a true agent, one needs to include memory. • With addition of ChatMemory component, LangChain4J automatically appends previous messages to current prompts. Stateful conversations
  • 15.
    Monday, November 24,2025 Presentation Title 15 • Via Microprofile Fault Tolerance. • Apply any MP Fault Tolerance interceptor annotations (e.g., @Retry, @Fallback, @Timeout, etc.), the same way you would to existing CDI bean. Adding resiliency
  • 16.
    Monday, November 24,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 16 • Via Microprofile Telemetry. • Can register either Span, Metrics, or both. • Each ChatModelListener can be assigned via MP Config. • “lookup:@all” allows CDI to seek all Telemetry beans and register it to the ChatModel. • Alternatively, specify the full-qualified classname of either SpanChatModelListener, MetricsChatModelListener, separated by a comma. • OpenTelemetry Semantic Convention for Generative AI Spans. • OpenTelemetry Semantic Convention for Generative AI Metrics. Applying Observability
  • 17.
    Monday, November 24,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 17 • Maven: • GroupId: dev.langchain.cdi • Add CDI portable extension module to your Maven POM • Add the following ArtifactId to enable its features: • MP Config: langchain4j- cdi-config • MP Fault Tolerance: langchain4j-cdi-fault- tolerance • MP Telemetry: langchain4j-cdi- telemetry Getting started with LangChain4J-CDI
  • 18.
    Monday, November 24,2025 Presentation Title 18 Putting it all together.
  • 19.
    • LangChain4J-CDI: • GitHub:https://github.com/langchain4j/langchain4j-cdi • Example: https://github.com/langchain4j/langchain4j- cdi/tree/main/examples • LangChain4J: • URL: https://docs.langchain4j.dev/ • GitHub: https://github.com/langchain4j/langchain4j • Article: Build AI Apps and Agents in Java: Hands-on with LangChain4J (by Lize Raes): https://javapro.io/2025/04/23/build-ai-apps-and-agents- in-java-hands-on-with-langchain4j/ • Article: Bring AI into your Jakarta EE apps with LangChain4J-CDI (formerly SmallRye-LLMM): JavaPRO Magazine, 04-2025, Java 25 – Special Edition. Page, 96 (by Buhake Sindi). https://javapro.io/2025/10/28/04- 2025-java-25-special-edition/ Monday, November 24, 2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 19 Resources
  • 20.
    • Spring BootLangChain4J: https://docs.langchain4j.dev/tutorials/spring-boot- integration • Quarkus LangChain4J: https://docs.quarkiverse.io/quarkus- langchain4j/dev/index.html • Helidon MP LangChain4J: https://helidon.io/docs/v4/mp/guides/langchain4j • Micronaut LangChain4J: https://micronaut- projects.github.io/micronaut-langchain4j/latest/guide/ Monday, November 24, 2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 20 Not to be confused with…
  • 21.
    • Jakarta AgenticArtificial Intelligence: • Still under development, under the Eclipse Foundation. • The project provides a set of vendor-neutral APIs that make it easy, consistent, and reliable to build, deploy, and run AI agents on Jakarta EE runtimes. • Anybody can contribute to the development of the Jakara Agentic AI specifications. • More info: https://jakarta.ee/specifications/agentic- ai/ Monday, November 24, 2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 21 Finally…
  • 22.
    Tuesday, November 25,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 22 Demo! • sindi-ai-chatbox • GitHub: https://github.com/TheEliteGentlem an/sindi-ai-chatbot
  • 23.
    Tuesday, November 25,2025 Bring AI and build AI agents into your Jakarta EE application with LangChain4J CDI. 23 THANK YOU Any Questions? Buhake Sindi x: @EliteGentleman Other socials: @buhake.sindi https://linktr.ee/theEliteGentleman