10 Replies Latest reply on Jul 16, 2012 10:31 PM by Caio Candido

    Problem with RESTeasy

    Lars Braunholz Newbie


      i'm trying to integrate RESTeasy with SEAM 2.1.0.CR1 into my application. I started with a very simple test and ran into problems.

      This is my ressource class:

      public class DokumentenRessourceBean implements DokumentenRessource {
           public String getTest( @PathParam("id") int id )
                return "Servus " + id;
           @Destroy @Remove
           public void destroy() {}

      The interface has no REST annotations. I deployed jboss-seam-resteasy.jar, resteasy-jaxrs.jar and jaxrs-api.jar with the libraries of my application.
      I got the following error when the jboss server starts.

      22:18:21,543 ERROR [[/bxtranet]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.resteasy.dispatcher
              at org.jboss.seam.Component.newInstance(Component.java:2049)
              at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
              at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
              at org.jboss.seam.contexts.ServletLifecycle.endIn.....
       at org.jboss.Main$1.run(Main.java:508)
              at java.lang.Thread.run(Thread.java:613)
      Caused by: java.lang.RuntimeException: Class is not a root resource.  It, or one of its interfaces must be annotated with @Path: com.bxtranet.basic.session.DokumentenRessourceBean implements:  com.bxtranet.basic.session.DokumentenRessource
              at org.resteasy.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:104)
              at org.resteasy.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:83)
              at org.jboss.seam.resteasy.ResteasyDispatcher.onStartup(ResteasyDispatcher.java:54)

      I also tried to annotate the interface or use a POJO as resource class but i got the same error. Now i'm running out of ideas. Did i miss something ?

        • 1. Re: Problem with RESTeasy
          Christian Bauer Master

          EJBs have not been tested, the RESTEasy integration is beta and so they might not work. However, basic POJOs have been tested and should work.

          • 2. Re: Problem with RESTeasy
            Lars Braunholz Newbie

            ok, i changed the class to this:

            public class DokumentenRessource{
                 public String getTest( @PathParam("id") int id )
                      return "Servus " + id;

            but the problem still exists.

            • 3. Re: Problem with RESTeasy
              Johnny Ren Newbie
              Why not use Page Actions?

                  <page view-id="/hello/*" action="#{helloWorld.sayHello}"/>
              • 4. Re: Problem with RESTeasy
                Mar Cin Newbie
                I have the same problem with serving a binary document (from blob) as in Your DokumentenRessource.
                Have You resolved it?

                My alternative solution is:
                public class ZzzBean implements Zzz {

                        private Manager manager;
                        @In(create = true)
                        private DocumentStore documentStore;
                        private FacesContext facesContext;
                        @Begin(flushMode = FlushModeType.MANUAL)
                        public void zzzDokument(int idDokumentu) {
                                byte[] plik = dokument.getPlik();
                                DocumentData dane = new DocumentData("filename",
                                                new DocumentData.DocumentType("pdf",
                                                                "application/pdf"), plik);
                                String docId = documentStore.newId();
                                documentStore.saveData(docId, dane);
                                String documentUrl =
                                try {
                                                        manager.encodeConversationId(documentUrl, manager.getCurrentConversationViewId()));
                                catch (IOException ioe) {
                                        throw new RedirectException(ioe);

                but I think seam/resource would be smarter

                • 5. Re: Problem with RESTeasy
                  Matthias van der Vlies Newbie

                  I'm having the same problem. I used both an EJB and a POJO, both with the same result. Could it somehow be related to: https://jira.jboss.org/jira/browse/RESTEASY-47 ?

                  • 6. Re: Problem with RESTeasy
                    Matthias van der Vlies Newbie

                    Ok, I fixed it (with some help of a colleague), after some debugging we discovered that there were two javax.ws.rs.Path's in the classpath. Make sure you have the following layout:





                    And in no other combination or duplicates. This should solve your problem. It solved mine :)

                    • 7. Re: Problem with RESTeasy
                      Niels Henrik Hagen Newbie

                      Could you please add the MANIFEST.MF files here. I'm having a problem with the clathpath for classes in the jaxrs-api.jar

                      • 8. Re: Problem with RESTeasy
                        kongo09 Newbie

                        I had exactly the same problem with Seam 2.2 and your .jar layout solved it for me. Thanks!!!

                        • 9. Re: Problem with RESTeasy
                          keurvet keurvet Newbie

                          Yes, me too, thanks a lot !!!!!

                          • 10. Re: Problem with RESTeasy
                            Caio Candido Newbie

                            Does anyone know of any definitive solution to the use of RESTEasy in each WAR file in the same server?