Skip to main content

Enabling CDI in ADF Applications targeting WLS 12C

If you had tried using  Contexts and Dependency Injection (CDI) in your ADF app targeting WLS 12C, you might have already noticed the issue that I'm mentioning here - CDI things are not working in the application by default. Well, here is a solution. See this blog which talks about the same: post

To keep things simple, do the  following:

  1. Download the cdi-enabler jar from the following mavne repo:
  2. Add it as dependency to your view controller project where you use CDI.
  3. Open the beans.xml file and add alternatives as shown below:

<?xml version = '1.0' encoding = 'windows-1252'?>
<beans xmlns:xsi=""

Now try running the app, I can see CDI works for me. I hope you may also see the same ;)

Update : 
The thing mentioned here is a  work around for class loading issue that may arise when an application using CDI, packaged with its own JSF implementation(Not the one provided by the underlying container). As both the CDI and JSF implementation are not loaded by class loaders of same level, CDI cannot simply work with JSF implementation provided by app. This is the case for an ADF Faces app. Work around is to make use of CDI 'alternatives'  feature to plugin  pieces that needs to work with the JSF classes loaded in the current application's context. 


sfti said…
how can we make use of CDI in ADF applications? Anything in the binding layer, contextual events, etc? Some examples would be great. Thank you.
Florin Marcus said…
As far as I know, an empty beans.xml would be enough for enabling CDI:

I wonder whats the magic behind using
Pls see the update the blog
As of now there is some 'technical' issues in uploading samples in the public facing blogs, will upload one later.

Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…