7 Replies Latest reply on May 23, 2010 3:38 PM by Artur Friesen

    resteasy with seam 2.2 and JBoss 4.2

    Artur Friesen Newbie

      Im having problems running resteasy with SEAM 2.2.0 ans JBoss AS 4.2.

      What i did so far:
      added the jaxrs-api.jar to the webcontent-lib directory.
      added the jboss-seam-resteasy.jar and resteasy-jaxrs.jar to the EarContent-lib-directory.

      After that i had some errors during the start of the JBoss AS.
      It was something with java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

      so i added the slf4j-api.jar and slf4j-log4j12.jar also to the EarContent-lib-directory.

      After that the JBoss AS started with no problems.

      Now im faced with an 404 Error while trying to access the Webservice:

      HTTP Status 404 - Could not find resource for relative

      My Webservice class looks as following:

      package rest;
      import javax.ws.rs.*;
      public class HelloWorld {
          public String get() {
               return "Ping was Successfull";

      Im trying to reach the webservice over the URL .../seam/resource/rest/ping

      does anyone have an idea what im doing wrong??
      Im a little bit confused about where to put the JARs and the Webservice-Class.
      Maybe i have to put the Webservice-Class so the EJB container??

        • 1. Re: resteasy with seam 2.2 and JBoss 4.2
          Artur Friesen Newbie

          Finally i got it running, at least the basic example i showed in my first post. Just to note down which combination worked for me,

          i created a eclipse WAR-project via jboss-tools with the following settings:

          • JBoss AS 4.2.3

          • SEAM 2.2.0

          • PostgreSQL 8.4.3

          after creating the Project i had to add the following JARs to lib folder:

          • jboss-seam-resteasy.jar

          • jaxrs-api.jar

          • resteasy-jaxrs.jar

          • slf4j-api.jar

          • slf4j-log4j12.jar

          • 2. Re: resteasy with seam 2.2 and JBoss 4.2
            Artur Friesen Newbie

            If you use the Jboss-Toos in Eclipse to create a SEAM-EAR Project, you have to put the librarys as following:




            jaxrs-api.jar resteasy-jaxrs.jar

            • 3. Re: resteasy with seam 2.2 and JBoss 4.2
              Artur Friesen Newbie

              Im trying to inject EntityManager into the RESTeasy Class,
              but this is not working...

              is there some configuration needed to inject EntityManager??

              • 4. Re: resteasy with seam 2.2 and JBoss 4.2
                Gabor Jakab Newbie

                Not sure how far you got, but you should set your class as Seam Component with @Name to inject it.

                • 5. Re: resteasy with seam 2.2 and JBoss 4.2
                  Artur Friesen Newbie

                  Meanwhile i switched to the JBossAS 5.1, but it didnt helped me out.
                  I notated the class with @Name and tried to inject the EntityManager:

                  import javax.persistence.EntityManager;
                  import javax.ws.rs.*;
                  import org.jboss.seam.annotations.In;
                  import org.jboss.seam.annotations.Name;
                  public class HelloWorld {
                      @In(create=true) EntityManager manager;
                      public String get(@PathParam("Number")String num) {
                          return "ping succeeded !!! "+num;

                  If i look at the JBossAS Log, there is the following error after trying to navigae to the REST-URL:

                  Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: HelloWorld.manager on: rest2.HelloWorld with value: class org.jboss.seam.faces.FacesManager
                       at org.jboss.seam.util.Reflections.set(Reflections.java:86)
                       at org.jboss.seam.Component.setFieldValue(Component.java:1923)
                       ... 69 more
                  Caused by: java.lang.IllegalArgumentException: Can not set javax.persistence.EntityManager field rest2.HelloWorld.manager to org.jboss.seam.faces.FacesManager
                       at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
                       at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
                       at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
                       at java.lang.reflect.Field.set(Field.java:657)
                       at org.jboss.seam.util.Reflections.set(Reflections.java:71)
                       ... 70 more

                  • 6. Re: resteasy with seam 2.2 and JBoss 4.2
                    Artur Friesen Newbie

                    The Problem with the EntityManager injection has seemingly nothing todo with RESTeasy.
                    I also get this error if i try to onject the EntityManager into the home-class of a created entity.

                    What could be the reason for such an Error?
                    Why there is no EntityManager in the context?

                    • 7. Re: resteasy with seam 2.2 and JBoss 4.2
                      Artur Friesen Newbie

                      finally i found the reason for that behavoir. The following log pointed me to that

                      15:31:27,776 INFO Component: entityManager, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.ManagedPersistenceContext

                      SEAM doesnt inject the EntityManager if you declare the @In with another instance-name than entityManager. In my case the following injection doesnt worked because of the instance-name

                      @In EntityManager manager;

                      It has to be the following

                      @In EntityManager entityManager;