2 Replies Latest reply on Sep 29, 2011 3:28 AM by Jozef Hartinger

    Problem with JBoss6, RESTEasy and weld

    1919 Newbie

      I have a problem with a war application, using JBoss6 and RESTEasy. I'll use CDI later in the project.


      I can't invoke REST resource, even without inject.


      There are the logs :


      @Deploy :



      INFO ConfigurationBootstrap:82 - Adding scanned resource: com.restful.ws.RestClass
      
      DEBUG CdiInjectorFactory:68 - Doing a lookup for BeanManager in java:comp/BeanManager
      
      INFO CdiInjectorFactory:82 - Found BeanManager at java:comp/BeanManager
      
      DEBUG CdiInjectorFactory:68 - Using CdiConstructorInjector for class class com.restful.ws.RestClass
      







      I am using :


      JDK6


      jboss-6.0.0.Final


      resteasy-jaxrs-2.2.1.GA


      lib :


      http://img11.hostingpics.net/pics/414255lib.png


      I use Hibernate for DAO.


      web.xml :



      <?xml version="1.0" encoding="UTF-8"?>
      
      <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
      
          <context-param>
      
              <param-name>resteasy.scan</param-name>
      
              <param-value>true</param-value>
      
          </context-param>
      
          <context-param>
      
              <param-name>resteasy.servlet.mapping.prefix</param-name>
      
              <param-value>/</param-value>
      
          </context-param>
      
          <listener>
      
              <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
      
          </listener>
      
          <servlet>
      
              <servlet-name>resteasy-servlet</servlet-name>
      
              <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
      
          </servlet>   
      
          <servlet-mapping>
      
              <servlet-name>resteasy-servlet</servlet-name>
      
              <url-pattern>/*</url-pattern>
      
          </servlet-mapping>
      
      </web-app>
      




      beans.xml :



      <?xml version="1.0" encoding="UTF-8"?>
      
      <beans xmlns="http://java.sun.com/xml/ns/javaee"
      
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
      
      </beans>
      




      Application :



      import java.util.HashSet;
      
      import java.util.Set;
      
      import javax.ws.rs.core.Application;
      
      public class MessageApplication extends Application {
      
          private Set<Object> singletons = new HashSet<Object>();
      
          public MessageApplication() {
      
              singletons.add(new RestClass());
      
          }
      
          @Override
      
          public Set<Object> getSingletons() {
      
              return singletons;
      
          }
      
      }
      




      RestClass :



      import javax.ws.rs.GET;
      
      import javax.ws.rs.Produces;
      
      import javax.ws.rs.Path;
      
      import javax.ws.rs.ext.Provider;
      
      @Path("/path")
      
      public class RestClass {
      
          @GET
      
          @Produces("text/plain")
      
          public String getMessage() {
      
              return "String"
      
          }
      
      }
      




      Thanks

        • 1. Re: Problem with JBoss6, RESTEasy and weld
          1919 Newbie
          Calling a REST resource :



          org.jboss.resteasy.spi.UnhandledException: com.google.common.collect.ComputationException: org.jboss.weld.exceptions.WeldException: by java.lang.ClassFormatError: Illegal class name \"com/restful/ws/org$jboss$weld$bean-jboss$classloader:id\=\"vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value RestClass) _]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy" in class file com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy

              org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:241)

              org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)

              org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

              org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

              javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

              org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

          com.google.common.collect.ComputationException: org.jboss.weld.exceptions.WeldException: by java.lang.ClassFormatError: Illegal class name "com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy" in class file com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy

              com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)

              com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)

              com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)

              org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:113)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:660)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:707)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:65)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:70)

              org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:43)

              org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:208)

              org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

              org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

              javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

              org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

          org.jboss.weld.exceptions.WeldException: by java.lang.ClassFormatError: Illegal class name "com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy" in class file com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy

              org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:285)

              org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:212)

              org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:97)

              org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:47)

              org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:61)

              org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:52)

              com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)

              com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)

              com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)

              org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:113)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:660)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:707)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:65)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:70)

              org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:43)

              org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:208)

              org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

              org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

              javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

              org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

          javassist.CannotCompileException: by java.lang.ClassFormatError: Illegal class name "com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy" in class file com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy

              org.jboss.weld.util.bytecode.ClassFileUtils.toClass(ClassFileUtils.java:117)

              org.jboss.weld.bean.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:392)

              org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:281)

              org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:212)

              org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:97)

              org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:47)

              org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:61)

              org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:52)

              com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)

              com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)

              com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)

              org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:113)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:660)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:707)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:65)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:70)

              org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:43)

              org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:208)

              org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

              org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

              javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

              org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

          java.lang.ClassFormatError: Illegal class name "com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy" in class file com/restful/ws/org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$jboss-6$0$0$Final$server$default$deploy$proejct$war"-ManagedBean-com$restful$ws$RestClass[@javax$enterprise$context$RequestScoped()@javax$ws$rs$Path(value=$RestClass)]{com$restful$ws$RestClass$getMessage[@javax$ws$rs$GET()@javax$ws$rs$Produces(value=[Ljava$lang$String$@13809e0)]()$}_$$_WeldClientProxy

              java.lang.ClassLoader.defineClass1(Native Method)

              java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

              java.lang.ClassLoader.defineClass(ClassLoader.java:615)

              java.lang.ClassLoader.defineClass(ClassLoader.java:465)

              sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source)

              sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              java.lang.reflect.Method.invoke(Method.java:597)

              org.jboss.weld.util.bytecode.ClassFileUtils.toClass2(ClassFileUtils.java:143)

              org.jboss.weld.util.bytecode.ClassFileUtils.toClass(ClassFileUtils.java:109)

              org.jboss.weld.bean.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:392)

              org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:281)

              org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:212)

              org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:97)

              org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:47)

              org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:61)

              org.jboss.weld.bean.proxy.ClientProxyProvider$1.apply(ClientProxyProvider.java:52)

              com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)

              com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)

              com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)

              org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:113)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:660)

              org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:707)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:65)

              org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:70)

              org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:43)

              org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:208)

              org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

              org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

              javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

              org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)


          • 2. Re: Problem with JBoss6, RESTEasy and weld
            Jozef Hartinger Master

            You have probably run into WELD-897. You can either update Weld in the app server, use JBoss AS 7 or use JDK 1.6 update 24.


            Also note that since RESTEasy is part of the JBoss AS since version 6, there is no need to bundle RESTEasy jars within your application nor to configure RESTEasy through web.xml. See docs for details.