6 Replies Latest reply on Jun 4, 2009 10:48 PM by gugabcosta

    An Exception trhows when uses Resteasy with Seam

    gugabcosta

      Hi folks,



         I'm using resteasy with seam, but when a produces a application/xml, the service throws an StringIndexOutOfBoundsException.


         Can you help me?



           


      @Path("/{documentoId}")
           @Produces(MediaType.APPLICATION_XML)
           public DocumentoRest getDocumento(@PathParam("documentoId") String id) {
                Documento find = service.find(Documento.class, new Long(id));
                DocumentoRest rest = new DocumentoRest();
                rest.setId(find.getId());
                rest.setDescricao(find.getDescricao());
                return rest;
           }






      @XmlRootElement(name="documento")
      @XmlType(name="", propOrder={"descricao"})
      public class DocumentoRest implements Serializable 
      {
      
           
           private long id;
           
           private String descricao;
      
           @XmlAttribute(name="id")
           public long getId() {
                return id;
           }
      
           public void setId(long id) {
                this.id = id;
           }
      
           @XmlElement
           public String getDescricao() {
                return descricao;
           }
      
           public void setDescricao(String descricao) {
                this.descricao = descricao;
           }
           
      }





      thanks

        • 1. Re: An Exception trhows when uses Resteasy with Seam
          gugabcosta

          Hi,



             I forgot one thing in the code,





          @Path("/{documentoId}")
               @Produces(MediaType.APPLICATION_XML)
               public DocumentoRest getDocumento(@PathParam("documentoId") String id) {
                    Documento find = service.find(Documento.class, new Long(id));
                    DocumentoRest rest = new DocumentoRest();
                    rest.setId(find.getId());
                    rest.setDescricao(find.getDescricao());
                    return rest;
               }



          Any idea?

          • 2. Re: An Exception trhows when uses Resteasy with Seam
            gugabcosta

            Well... Again...






            @GET
            @Path("/{documentoId}")
                 @Produces(MediaType.APPLICATION_XML)
                 public DocumentoRest getDocumento(@PathParam("documentoId") String id) {
                      Documento find = service.find(Documento.class, new Long(id));
                      DocumentoRest rest = new DocumentoRest();
                      rest.setId(find.getId());
                      rest.setDescricao(find.getDescricao());
                      return rest;
                 }



            Now it's my code....
            Any idea?

            • 3. Re: An Exception trhows when uses Resteasy with Seam
              gugabcosta

              Hi...



                 The full stacktrace is






              java.lang.StringIndexOutOfBoundsException: String index out of range: -1
                   java.lang.String.substring(String.java:1768)
                   org.jboss.seam.exception.RedirectHandler.handle(RedirectHandler.java:39)
                   org.jboss.seam.exception.Exceptions.handle(Exceptions.java:76)
                   org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:114)
                   org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70)
                   org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                   org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                   org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                   org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                   org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                   org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                   org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                   org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                   org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

              thanks...

              • 4. Re: An Exception trhows when uses Resteasy with Seam
                christian.bauer

                What version of Seam and RESTEasy is this? There have been major changes to the RESTEasy integration code in the last 10 months with almost every release of Seam. Also, what you are trying to do works fine in the tests. Finally, what you posted is certainly not the complete stacktrace, you left the real cause. (Which I suspect to be in RESTEasy code.)


                • 5. Re: An Exception trhows when uses Resteasy with Seam
                  christian.bauer

                  Sorry, missed the RedirectHandler there in the stacktrace. So it looks like this is a Seam issue, see  https://jira.jboss.org/jira/browse/JBSEAM-4209

                  • 6. Re: An Exception trhows when uses Resteasy with Seam
                    gugabcosta

                    Hi Christian,



                       The version of Seam is 2.1.2.CR2 and the version of RESTEasy is 1.1-RC2.


                       I have already seen the https://jira.jboss.org/jira/browse/JBSEAM-4209.



                       I'm using the integration of seam and RESTEasy, the jboss-seam-resteasy.


                    thanks