users@glassfish.java.net

Re: OSGi - _at_EJB injection of an internal _at_Singleton

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Mon, 20 Jun 2011 22:39:20 +0530

Hi Robert,

I am sure you know @EJB can only be used in Java EE managed classes like
Servlets, EJBs, etc., so don't expect it to work if you accidentally
used it in regular classes. I am surprised that it is not even working
for you from a Servlet. May I know how you packaged your bundle? Where
are the EJB and Servlet classes. I am assuming it is a WAB, because it
has both EJB and Servlet. If you have packaged it as a WAB (by
definition a WAB must have Web-ContextPath header), then I don't see the
need to have Export-EJB header at all unless you want the EJBs to be
really exported as service. When the WAB gets deployed, the EJBs will
automatically get deployed. If you send me the log messages that appear
after you deploy this bundle, I can look into it to see what's going on.

Thanks,
Sahoo
On Monday 20 June 2011 09:46 PM, Robert Weeks wrote:
> Hello -
>
> We are trying to have a Singleton inside of a bundle - and have a class/servlet inside that bundle reference that singleton via @EJB - but are not getting the results we are wanting/needing.
>
> If we define a @Singleton within the bundle:
>
> package com.mycompany.classes;
>
> @Singleton
> public class MySingleton {
> ....
>
>
> and within that same bundle - have another class to reference that singleton
>
> @EJB
> private MySingleton mySingleton;
>
>
> Always comes up null.
>
> We have tried to export - but not sure if we are missing something.
>
> In manifest:
>
> Export-EJB: All;
> Export-EJB: om.mycompany.classes.MySingleton;
>
> etc.
>
> Are we missing something here?
>
> Thanks for any information.
>
>
> Robert Weeks
> Lead Developer - Framework and UI
> EXTENSION, INC.
> Email: rweeks_at_ext-inc.com
> Office: 260-797-0200 x4228
> General: 877-207-3753
> www.OpenTheRedBox.com
>
> Download the FREE EXTENSION Mobile App for iPhone and iPod Touch
> http://www.opentheredbox.com/iPhone_appDemo.php
>