5 Replies Latest reply on Feb 27, 2013 3:15 PM by rareddy

    teiid-odata does not take "Accept" header

    asyomichev

      I've been playing with the teiid-odata module and noticed that it chokes on "Accept" heders sent along with OData requests. It seems that presence of the header in general seems to cause the error, regardless of the value. Here is what I see:

       

      $ curl -H "Accept: application/xml" http://localhost:8080/odata/ToyVDB/$metadata

      <html><head><title>JBoss Web/7.0.13.Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.UriInfo

              org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)

              $Proxy33.getBaseUri(Unknown Source)

              org.teiid.odata.TeiidProducerProvider.getContext(TeiidProducerProvider.java:50)

              org.teiid.odata.TeiidProducerProvider.getContext(TeiidProducerProvider.java:35)

              org.odata4j.producer.resources.ExceptionMappingProvider.getODataProducer(ExceptionMappingProvider.java:85)

              org.odata4j.producer.resources.ExceptionMappingProvider.toResponse(ExceptionMappingProvider.java:53)

              org.odata4j.producer.resources.ExceptionMappingProvider.toResponse(ExceptionMappingProvider.java:1)

              org.jboss.resteasy.core.SynchronousDispatcher.executeExceptionMapper(SynchronousDispatcher.java:324)

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

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

              org.teiid.odata.ODataServletContainerDispatcher.service(ODataServletContainerDispatcher.java:97)

              org.teiid.odata.ODataServlet.service(ODataServlet.java:61)

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

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

      </pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the JBoss Web/7.0.13.Final logs.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.0.13.Final</h3></body></html>

       

      $ curl -H "Accept:" http://localhost:8080/odata/ToyVDB/$metadata

      <?xml version='1.0' encoding='utf-8'?><service xmlns="http://www.w3.org/2007/app" xml:base="http://localhost:8080/odata/ToyVDB/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app"><workspace><atom:title>Default</atom:title>... etc., the rest of a long metadata document stripped

       

      Is there anything I might have messed up in the configuration?

       

      Environment details:
      JBoss 7.1.1.Final
      Teiid 8.3.0.Beta1

      Teiid Designer 8.0.0.Final

       

      Thank you,
      --Alexey

        • 1. Re: teiid-odata does not take "Accept" header
          rareddy

          Alexey,

           

          Thanks for checking it out. Your feedback is very important, I really appreciate any help you can do in testing odata inside out.

           

          Looks like  "Accept: application/xml;charset=utf-8" works, I will check it out why with out the charset it fails, why it is not defaulting to UTF-8. There isn't much configuration. However, I made quite a few enhancements after the 8.3 Beta1, so 8.3 Beta2 would be much more feature complete.

           

          Thanks

           

          Ramesh..

          • 2. Re: teiid-odata does not take "Accept" header
            rareddy

            Alexy,

             

            Finally I had some time today to investigate this issue, I found that the OData4J framework that Teiid uses to provide the OData support only supports the UTF-8 based charsets. Leaving it from Accept header and asking just "application/xml" does not match with defined accepted headers thus it errors. However while doing so it masks the actual error. For that I logged this JIRA https://issues.jboss.org/browse/TEIID-2412

             

            So, the above suggestion to use "charset=utf-8" still works, and right way to do it.

             

            Ramesh..

            • 3. Re: teiid-odata does not take "Accept" header
              asyomichev

              Hi Ramesh,

               

              "Accept: application/xml" with charset request omitted is how odata4j client formulates its requests (I am using version 0.7). Does your answer mean that Teiid is not compatible with odata4j client, at least in its current version?

               

              Thanks,
              --Alexey

              • 4. Re: teiid-odata does not take "Accept" header
                rareddy

                In that case, it may be that RestEasy engine that Teiid uses with OData4J is being strict about enforcing the defined @Produces tag on the OData4J Entity handlers when a client request comes in.  In that case I am not sure if the server needs to relax it's enforcement, or client should include the correct  headers. Not enforcing this at server means client  can handle any charset that server gives back, I do not think that is a good assumption. I go to see if there is anyway Teiid can infer the default charset as "UTF-8".

                 

                Ramesh..

                • 5. Re: teiid-odata does not take "Accept" header
                  rareddy

                  Alexy,

                   

                  From XML specification http://www.w3.org/TR/REC-xml/#charencoding, I do see the below

                   

                  "In the absence of information provided by an external transport protocol (e.g. HTTP or MIME), it is a fatal error for an entity including an encoding declaration to be presented to the XML processor in an encoding other than that named in the declaration, or for an entity which begins with neither a Byte Order Mark nor an encoding declaration to use an encoding other than UTF-8. Note that since ASCII is a subset of UTF-8, ordinary ASCII entities do not strictly need an encoding declaration."

                  which leads me to believe that RestEasy is *not* allowing that default mode for UTF-8. I will ask the question in RestEasy forums for possible resolution.

                   

                  Ramesh..