0 Replies Latest reply on Jul 3, 2012 8:06 AM by hpally

    JBoss 4.2.3 & RESTEasy 2.3.2 - Problem in BeanManager's JNDI lookup

    hpally Newbie

      Hello All,

       

      I want to use JBoss 4.2.3 with RESTEasy 2.3.2. I'm able to do it by adding all the required Jars to library. This works fine when I don't use CDI capabilities.

       

      However, if I try to use @Inject in the classes, the BeanManager lookup fails and therefore the deployment. From https://issues.jboss.org/browse/RESTEASY-558, I understand that this issue has been fixed.

       

      - I'm using JDK 1.6.X

      - I have beans.xml in my WEB-INF

      - Tried with WELD servlet. But the final error remains same

      - Added <resource-env-ref> in web.xml which did not work

       

      web.xml content:

      ============

       

      <?xml version="1.0" encoding="UTF-8"?>

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

          id="WebApp_ID" version="3.0">

          <display-name>xyz</display-name>

       

          <servlet>

          <servlet-name>Resteasy</servlet-name>

          <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher</servlet-class>

      </servlet>

          <servlet-mapping>

              <servlet-name>Resteasy</servlet-name>

              <url-pattern>/*</url-pattern>

          </servlet-mapping>

       

          <context-param>

              <param-name>resteasy.scan</param-name>

              <param-value>true</param-value>

          </context-param>

       

          <context-param>

              <param-name>resteasy.resource.method-interceptors</param-name>

              <param-value>

               org.jboss.resteasy.core.ResourceMethodSecurityInterceptor

            </param-value>

          </context-param>

       

          <listener>

              <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>

          </listener>

       

          <context-param>

              <param-name>resteasy.injector.factory</param-name>

              <param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value>

          </context-param>

       

      <!-- <resource-env-ref>

              <description>Object factory for the CDI Bean Manager</description>

              <resource-env-ref-name>java:comp/BeanManager</resource-env-ref-name>

              <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>

          </resource-env-ref> -->

       

      </web-app>

       

       

      Stacktrace:

      =========

      Caused by: java.lang.RuntimeException: Unable to lookup BeanManager.

              at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManager(CdiInjectorFactory.java:131)

              at org.jboss.resteasy.cdi.CdiInjectorFactory.<init>(CdiInjectorFactory.java:41)

              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

              at java.lang.Class.newInstance0(Class.java:355)

              at java.lang.Class.newInstance(Class.java:308)

              at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:138)

       

       

      Questions:

      ========

      - Is it possible for JBoss 4.2.3 to have CDI capabilities at all ?

      - I see that JNDI lookup is failing. Who (which module/class) is responsible for adding the JNDI entry ?

      - Is there any problem with web.xml I have ?

       

      I'm stuck with this for past one day. Any help is truly appreciated.