1. Yes, you are right - a SFSB should not be injected into a Servlet. I
wish this were mentioned in the Servlet spec. If you care to run
verifier ($GlassFishHome/bin/verifier), it would warn you about such use.
2. In case of idle timeout, I am guessing the servlet would get an
exception as I don't think there is any code that refreshes the handle.
Thanks,
Sahoo
glassfish_at_javadesktop.org wrote:
> Hi,
>
> 1) If I understand it correctly, the class fields in a Servlet can be shared across multiple instances. When the EJB is stateful, than this bean will be shared across all instances. When I initialize the servlet with Principal user 1, then the SfullSB will be using this user. When Principal user 2 comes, the SfullSB already exists and uses the wrong user. Anyway, both users will use the same SfullSB ! [b]Please, correct me if I am wrong. [/b]
>
> public class CacheServlet extends HttpServlet {
>
> @EJB
> private StructureSessionLocal structureSession; // SSB -> Wrong, will be shared across all calls which arrive in this servlet instance
>
> ....
>
> }
>
>
> 2) Even if you use this approach (even though in 99% of all cases, this SfullSB it will not work correctly), what happens when the SfullSB has a timeout? Does the servlet refreshes the reference when a timeout occurs? In the case of Stateless Beans, there is no problem, I suppose?
>
> ---
>
> The documentation about EJB3 is very cumbersome regarding this point, hence my post. I think many people use injection because it is easy, but do not realize that placing it in a class-field can be very dangerous, even though everything may seem to run as planned. Or I am going bananas or missed the point here?
>
> Greetings
> Jan De Cooman
> [Message sent by forum member 'ossaert' (ossaert)]
>
> http://forums.java.net/jive/thread.jspa?messageID=243100
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>