Skip to main content

@Inject a stateless session bean

2 replies [Last post]
choicegh
Offline
Joined: 2010-02-25

I have a local stateless session bean that I am attempting to @Inject into a Weld SessionScoped Managed Bean.

When I inject with @EJB, everything works fine. When I change from @EJB to @Inject I get an UnserializableDependencyException.

When I remove @Stateless from my bean and just make it a plain @Named bean, the inject occurs without the serialization error.

I want to use @Inject so I take advantage of the @Alternative functionality of Weld for testing purposed.

I have using Glassfish v3. If this a defect or am I missing something?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Dominik Dorn

try making the property you like to inject transient.
That way, CDI does not try to serialize the ejb (which it probably
can't as its a proxy).

@Inject
transient SomeEJB ejb;

kr,
dominik

On Fri, Apr 23, 2010 at 7:18 PM, wrote:
> I have a local stateless session bean that I am attempting to @Inject into a Weld SessionScoped Managed Bean.
>
> When I inject with @EJB, everything works fine.  When I change from @EJB to @Inject I get an UnserializableDependencyException.
>
> When I remove @Stateless from my bean and just make it a plain @Named bean, the inject occurs without the serialization error.
>
> I want to use @Inject so I take advantage of the @Alternative functionality of Weld for testing purposed.
>
> I have using Glassfish v3.  If this a defect or am I missing something?
> [Message sent by forum member 'choicegh']
>
> http://forums.java.net/jive/thread.jspa?messageID=398705
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

--
Dominik Dorn
http://dominikdorn.com
http://twitter.com/domdorn

Tausche Deine Lernunterlagen auf http://www.studyguru.eu !

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

ksak
Offline
Joined: 2005-05-20

Please post the stack trace as well as the source code for the injection point and the stateless session bean.