CDI - Injecting Objects into EJB class by Using Producer Methods in Weblogic 10.3.6

822 views Asked by At

I would like to use CDI to inject objects into an EJB class using a producer method in Weblogic 10.3.6. Weblogic 10.3.6 is a Java EE 5 container and therefore does not support CDI out-of-the-box. To move to Weblogic 12c (which supports CDI out-of-the-box) is going to be a fairly big migration project that we cannot take on now.

Is it possible to retro-fit either Weld or OpenWebBeans to Weblogic 10.3.6? So far I've been trying to get OpenWebBeans to work without success. I've placed the following jar files in my classpath:

openwebbeans-ee-1.2.6.jar
openwebbeans-ee-common-1.2.6.jar
openwebbeans-ejb-1.2.6.jar
openwebbeans-el10-1.2.6.jar
openwebbeans-el22-1.2.6.jar
openwebbeans-impl-1.2.6.jar
openwebbeans-jms-1.2.6.jar
openwebbeans-osgi-1.2.6.jar
openwebbeans-resource-1.2.6.jar
openwebbeans-spi-1.2.6.jar
openwebbeans-web-1.2.6.jar

I also added a META-INF/openwebbeans/openwebbeans.properties file to my EJB project (traditional EJB jar packaged in a .ear file). I modified/added the following:

org.apache.webbeans.spi.deployer.useEjbMetaDataDiscoveryService=true org.apache.webbeans.resource.spi.ResourceService=org.apache.webbeans.ejb.resource.OpenEjbResourceInjectionService

I also hacked the following example into an EJB class to check if it works: http://www.javacodegeeks.com/2013/04/java-ee-cdi-producer-methods-tutorial.html

However, the member variables that are supposed to be injected remain null. I don't see any errors in the logs.

I'm starting to get the feeling this will only work if the EJB classes are deployed in a .war file with the OpenWebBeans listener defined. Am I correct in saying this?

1

There are 1 answers

1
win_wave On BEST ANSWER

Long time ago I've tried to make Weld to work in Weblogic 10.3.6, but it was not successful. I would think if even you will manage to make it, it will buggy. So just relax and use Guice or smth, like that in WL 10.3