Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

@EJB injection not working - Using Weblogic 10, Myfaces, EJB3

843830Jun 11 2009 — edited Nov 4 2009
Good day all

I'm trying to get a simple local reference to a Local EJB using @EJB annotation.

I've read all over the net and tried numerous small changes in an attempt to get this working.

Our Application is packaged as a deploy EAR that holds some util jars and the ejb-jar that houses our beans and interfaces.

// Local Intefrace
@Local
public interface IDataMonitoringService

//Bean implementation
@Stateless(name = "DataMonitoringServiceBean", mappedName = "ejb/DataMonitoringService")
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class DataMonitoringServiceBean3 implements IDataMonitoringService

If this is remote it works fine doing a normal lookup on the JNDI.

The servlet that is trying to inject is like this

Variable in the servlet
@EJB private IDataMonitoringService dataMonitoringService;
in doGet
List<OmDmCategory> list = dataMonitoringService.retriveAllCategories();

On hitting the last line here the dataMonitoringService object is null and injection has not occurred.

I've tried using different names, moving the annotations around on the bean and interfaces... and now I'm really just getting frustrated.

I've tried creating a ServletListener and setting "injected" local instance on the servlet context... but that doesn't inject it either.

My main goal is to be able to use the reference in a Myfaces/JSF bean to retrieve data/update etc.

If someone could help out it would be greatly appreciated.

Thanks
sirAlfred25
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 2 2009
Added on Jun 11 2009
12 comments
963 views