users@glassfish.java.net

Re: glassfish-embedded-all and java:comp/BeanManager - not bound exception

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Fri, 09 Jul 2010 14:02:50 +0530

On Wednesday 07 July 2010 12:23 AM, glassfish_at_javadesktop.org wrote:
> As for the BeanManager lookup - I mentioned that it works no problem
> in a web archive without beans.xml. Also, what does it mean "CDI is
> enabled"? I think that @Inject into EJB is always enabled. If I am wrong
> (happened many times before ;d), and it is an error, shouldn't it be
> reported during deployment? If it isn't, it will blow up at runtime,
> which is much worse.

I don't think BeanManager is available for a non-CDI enabled
web-archive. I tried a simple web-application with no beans.xml and this
is what I got when I tried to lookup BeanManager:
> [#|2010-07-09T13:09:34.229+0530|SEVERE|glassfish3.1|null|_ThreadID=26;_ThreadName=http-thread-pool-8080(1);|javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in SerialContext [Root exception is javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]]|#]
> [#|2010-07-09T13:09:34.229+0530|SEVERE|glassfish3.1|null|_ThreadID=26;_ThreadName=http-thread-pool-8080(1);| at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:456)|#]
> [#|2010-07-09T13:09:34.229+0530|SEVERE|glassfish3.1|null|_ThreadID=26;_ThreadName=http-thread-pool-8080(1);| at javax.naming.InitialContext.lookup(InitialContext.java:392)|#]
> [#|2010-07-09T13:09:34.229+0530|SEVERE|glassfish3.1|null|_ThreadID=26;_ThreadName=http-thread-pool-8080(1);| at javax.naming.InitialContext.lookup(InitialContext.java:392)|#]
> [#|2010-07-09T13:09:34.229+0530|SEVERE|glassfish3.1|null|_ThreadID=26;_ThreadName=http-thread-pool-8080(1);| at TestServlet.service(TestServlet.java:68)|#]

CDI-enabled means adding a beans.xml to the archive. I agree that it
would be nice if we report a WARNING when an archive that employs CDI,
does not include a beans.xml. Could you raise an RFE and I will try to
fix this in 3.1

Thanks
--Siva.

> - szczyp