6 Replies Latest reply on Jan 31, 2018 2:14 PM by Divyesh Vallabh

    ODATA War Proxy Configuration

    Divyesh Vallabh Newbie

      I followed the instructions for modifying the ODATA War file to setup the proxy base URL, but when I try to access the metadata or perform a search on a table I get an exception error:

       

       

      <error xmlns="http://docs.oasis-open.org/odata/ns/metadata">

      <code>null</code>

      <message>The URI is malformed.</message>

      </error>

       

       

      The address I used was in the format: http://xxx.net. THe url to access the VBD was http://xxx.net/odata4/babynames/file/$metadata. I'm not sure if there is anything else that needs to be configured.

       

       

      I looked at the log files and this is what was printed out in the stacktrace.

       

       

      2018-01-26 11:50:22,396 WARN  [org.teiid.ODATA] (default task-2)  TEIID16052 Unable to process odata request due to: The URI is malformed.: Unexpected start of resource-path segment.

      at org.apache.olingo.server.core.uri.parser.ResourcePathParser.leadingResourcePathSegment(ResourcePathParser.java:236)

      at org.apache.olingo.server.core.uri.parser.ResourcePathParser.parsePathSegment(ResourcePathParser.java:88)

      at org.apache.olingo.server.core.uri.parser.Parser.parseUri(Parser.java:234)

      at org.apache.olingo.server.core.ServiceDispatcher.execute(ServiceDispatcher.java:93)

      at org.apache.olingo.server.core.OData4HttpHandler.process(OData4HttpHandler.java:67)

      at org.teiid.olingo.web.ODataServlet.service(ODataServlet.java:39)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)

      at org.teiid.olingo.web.ODataFilter.internalDoFilter(ODataFilter.java:224)

      at org.teiid.olingo.web.ODataFilter.doFilter(ODataFilter.java:96)

      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

      at org.teiid.olingo.web.gzip.GzipFilter.doFilter(GzipFilter.java:57)

      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

      at org.teiid.olingo.web.CorsFilter.doFilter(CorsFilter.java:80)

      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

      at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)

      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

      at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

      at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)

      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

      at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)

      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

      at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)

      at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

      at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

      at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)

      at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)

      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)

      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)

      at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

      at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

      at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)

      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)

      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)

      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)

      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

      at java.lang.Thread.run(Thread.java:748)

       

       

      2018-01-26 11:50:22,437 INFO  [io.undertow.request.dump] (default task-2) 

      ----------------------------REQUEST---------------------------

                     URI=/odata4/babynames/file/$metadata

      characterEncoding=null

           contentLength=-1

             contentType=null

                  header=Accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8

                  header=Accept-Language=en-US,en;q=0.9

                  header=Accept-Encoding=gzip, deflate

                  header=Max-Forwards=10

                  header=User-Agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36

                  header=Connection=Keep-Alive

                  header=Authorization=Basic dXNlcjp1c2Vy

                  header=X-ARR-LOG-ID=8b4688f2-ca76-410b-941d-fe0b6a5c46ab

                  header=X-Forwarded-For=10.86.3.158:62686

                  header=X-Original-URL=/odata4/babynames/file/$metadata

                  header=Upgrade-Insecure-Requests=1

                  header=Host=localhost:8080

                  locale=[en_US, en]

                  method=GET

                protocol=HTTP/1.1

             queryString=

              remoteAddr=127.0.0.1/127.0.0.1:62598

              remoteHost=127.0.0.1

                  scheme=http

                    host=localhost:8080

              serverPort=8080

      --------------------------RESPONSE--------------------------

           contentLength=152

             contentType=application/xml

                  header=Content-Encoding=gzip

                  header=Expires=0

                  header=Cache-Control=no-cache, no-store, must-revalidate

                  header=X-Powered-By=Undertow/1

                  header=Server=WildFly/11

                  header=Pragma=no-cache

                  header=Date=Fri, 26 Jan 2018 16:50:22 GMT

                  header=Connection=keep-alive

                  header=Content-Type=application/xml

                  header=Content-Length=152

                  header=OData-Version=4.0

                  status=400

        • 1. Re: ODATA War Proxy Configuration
          Ramesh Reddy Master

          Can you attach your war file? What is the URL you issued when you saw this exception?

          • 2. Re: ODATA War Proxy Configuration
            Divyesh Vallabh Newbie

            I tried the following modifications in teiid 9.3.6 and also the latest 10.1 snapshot

             

             

            Modified the web.xml in the teiid-olingo-odata4.war located in the <jbosshome>\modules\system\layers\dv\org\jboss\teiid\main\deployments folder

             

             

                  <init-param>

                        <param-name>proxy-base-uri</param-name>

                        <param-value>${teiid-odata-proxy-base-uri}</param-value>

                  </init-param>

                

            Added the following lines to the standalone-teiid.xml file

             

             

            <system-properties>

                    <property name="teiid-odata-proxy-base-uri" value="http://dvltple6.net"/>  <!-- name of my laptop -->

                </system-properties>

             

            I also tried using the URL directly in the web.xml file and get the same error.

             

             

            To access the babynames vdb I used the following url http://dvltple6.net/odata4/babynames/file/$metadata

            • 3. Re: ODATA War Proxy Configuration
              Ramesh Reddy Master

              1) The system property in standalone-teiid.xml, I am not sure it works with the property in web.xml (never tested)

              2) The attached war file, I see that the property is not changed at all in web.xml

               

              Also note the proxy URL does not modify where you are accessing the OData V4 service. In OData response message, if the results span more than a single page, the URL for next fetch is provided. In cloud environments, this URL and what system sees as base URL differ as they may be under a container obsufication, this property is defined to correct and provide a public facing URL.

               

              For general proxy consult WildFly documentation.

              • 4. Re: ODATA War Proxy Configuration
                Divyesh Vallabh Newbie

                1) The system property in standalone-teiid.xml, I am not sure it works with the property in web.xml (never tested)

                I ended up downloading and recompiling the code and added some log messages to org.teiid.olingo.web.ODataFilter class and verified system property does work

                2) The attached war file, I see that the property is not changed at all in web.xml

                Also note the proxy URL does not modify where you are accessing the OData V4 service. In OData response message, if the results span more than a single page, the URL for next fetch is provided. In cloud environments, this URL and what system sees as base URL differ as they may be under a container obsufication, this property is defined to correct and provide a public facing URL.

                 

                Yes, I made this change so the embedded next fetch/edit links in the response are correctly generated. I downloaded the file that was attached to this message and I do see the change.

                 

                 

                Not sure if this is the issue, but I'm currently on a Windows 7 machine with the following JDK:

                 

                java version "1.8.0_152"

                Java(TM) SE Runtime Environment (build 1.8.0_152-b16)

                Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

                 

                I created a test java class (see attachement) to test out the "extractURI"  in the ProxyHttpServletRequest.java class and it doesn't seem to generate the new proxy url correctly when the path and ref are encoded.

                 

                In the teiid/ProxyHttpServletRequest.java at master · teiid/teiid · GitHub , I removed the UrlEncoder.encode(..) code on lines 63 and 69 and copied the newly compiled jar file into jboss and proxy change started to work. The next fetch links were correctly being generated with my system property value and no longer received the malformed url error.

                • 5. Re: ODATA War Proxy Configuration
                  Ramesh Reddy Master

                  Can you create a JIRA and provide pull for the fix?