Configuring beans.xml file

The beans.xml file is the bean archive descriptor for CDI applications. It can be used for any CDI compliant container, such as Weld which is included in WildFly application server. First off, it’s worth understanding that the bean descriptor in CDI (META-INF/beans.xml or WEB-INF/beans.xml) is not there to define beans in XML. Rather, you can … Read more

Categories cdi

Building a CDI 2 standalone Java application

In the second article about CDI 2 we will learn how to create a standalone J2SE application featuring CDI2. Let’s get started! Using Context Dependency Injection for J2SE application is something not totally new to developers. For example,before CDI 2 you could start-up the Weld CDI container using the specific classes provided by it. This … Read more

Categories cdi

Introduction to CDI 2.0 API

CDI 2.0 is the new version of Context and Dependency Injection for the Java EE Platform and it’s now in public review status. While you can now grab the specification at: https://jcp.org/aboutJava/communityprocess/pr/jsr365/index.html in this tutorial we will have a first look on running some of its features on the last version of WildFly 10 CDI … Read more

Categories cdi

Using CDI Beans in JBoss – WildFly modules

The building blocks of the application server are modules which are, often, Java libraries which can be run out of the application server context. It is however possible to deploy CDI Beans or use AS Resources in your modules. Let’s see how. In our example project, we will use a Java class which contains CDI … Read more

Categories cdi

CDI faqs and common issues

Weld BootstrapService exception If you are starting to practice with CDI on Weld container, a common obscure exception that you might get is the following one: JBAS014775: New missing/unsatisfied dependencies: service jboss.deployment.unit.”jmsdemo.war”.WeldBootstrapService (unavailable) dependents: [service jboss.deployment.unit.”jmsdemo.war”.CdiValidatorFactoryService, service jboss.deployment.unit.”jmsdemo.war”.component.”javax.faces.webapp.FacetTag”.WeldInstantiator, service jboss.deployment.unit.”jmsdemo.war”.component.”javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV”.WeldInstantiator, service jboss.deployment.unit.”jmsdemo.war”.component.”com.sample.Test”.WeldInstantiator, JBAS014799: … and 10 more ] service jboss.deployment.unit.”jmsdemo.war”.WeldStartService (unavailable) dependents: [service jboss.deployment.unit.”jmsdemo.war”.CdiValidatorFactoryService, service jboss.deployment.unit.”jmsdemo.war”.component.”javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV”.WeldInstantiator, … Read more

Categories cdi

Accessing ServletContext and ServletRequest in CDI Beans

Today I’ve found one interesting question on StackOverFlow of one user asking to read the web.xml context params from a CDI Bean. Luckily it’s not complicated at all to accomplish this task. In order to be able to read the web.xml context-params from a CDI Bean all you need to do is injecting the ServletContext … Read more

Categories cdi

Java EE 6 CDI example application

In this tutorial we will show how to upgrade our Java EE 6 EJB based application into a CDI based application using Eclipse and Eclipse Maven plugin. Contexts and Dependency Injection(CDI) is a new addition to the Java EE specification as of Java EE 6. It provides several benefits that were missing to Java EE … Read more

Categories cdi

Interceptors and Decorators tutorial

In this tutorial we will show two advanced features of CDI programming: Interceptors and Decorators. We will introduce them by using the Kitchesink example which will be upgraded to use these features. An Interceptor is a class that is used to interpose in method invocations or lifecycle events that occur in an associated target class. … Read more

Categories cdi

CDI and JPA tutorial

One popular issue of every application is about handling multiple database resources (at minimum you should consider handling a production DB and a development DB). In this tutorial we will show how you can solve this elegantly with CDI and its powerful annotations. JPA and CDI Basically, CDI is an annotation-driven injection framework that minimizes … Read more

Categories cdi

Using CDI to manage EJB dependencies

In this tutorial we will illustrate how to use CDI to choose between different EJB implementation at deployment time, or at injection point. CDI stands for Context Dependency Injection and can be used to for injecting Context and Dependencies into your application. This concept is not at all new for Java developers. Spring developers for … Read more

Categories cdi
Exit mobile version