13 Replies Latest reply on Nov 13, 2015 12:54 PM by rareddy

    Rest WAR web service return errror

    mirco73

      Hi,

      I've built a very simple Model View ,a Procedure, and I've deployed a rest WAR as described in http://blog.everythingjboss.org/articles/Generating-Web-Services-for-View-Models-JDV/

       

      The whole thing works perfectly until the result is somehow big (it seems when the response >30k bytes ) , in that case I get an error like the following:

       

      14:47:10,300 SEVERE [org.teiid.rest] (http-/0.0.0.0:8080-2) null Exception in execute: {0}: java.lang.Throwable: java.sql.SQLException: java.lang.IllegalArgumentException: Null charset name

          at org.teiid.rest.services.TeiidRSProviderPost.execute(TeiidRSProviderPost.java:116) [classes:]

          at org.teiid.rest.services.provaExpWS2ModelView.FattureViewProc(provaExpWS2ModelView.java:95) [classes:]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_60]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_60]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_60]

          at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_60]

          at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:168) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:541) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:523) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:125) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.0.Final-redhat-15.jar:7.5.0.Final-redhat-15]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

          at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_60]

      Caused by: java.sql.SQLException: java.lang.IllegalArgumentException: Null charset name

          at org.teiid.rest.services.TeiidRSProviderPost.handleResult(TeiidRSProviderPost.java:167) [classes:]

          at org.teiid.rest.services.TeiidRSProviderPost.execute(TeiidRSProviderPost.java:112) [classes:]

          ... 29 more

      Caused by: java.lang.IllegalArgumentException: Null charset name

          at java.nio.charset.Charset.lookup(Charset.java:457) [rt.jar:1.8.0_60]

          at java.nio.charset.Charset.forName(Charset.java:528) [rt.jar:1.8.0_60]

          at org.teiid.query.function.source.XMLSystemFunctions.serialize(XMLSystemFunctions.java:1101) [org.teiid.runtime.client_9.0.3.Final-v20150810-1438-B1157.jar:]

          at org.teiid.rest.services.TeiidRSProviderPost.handleResult(TeiidRSProviderPost.java:165) [classes:]

          ... 30 more

       

       

      If I test the procedure from the designer I get the result without any problem

       

      thanks,

      Mirco

        • 1. Re: Rest WAR web service return errror
          rareddy

          Mirco,

           

          The same people watch both Teiid forums like your question here https://developer.jboss.org/message/944871 So, as suggested please open a Designer JIRA for the issue. Meanwhile, there is another option to generate the Rest War for VDB. Please see the directions here REST Service Through VDB - Teiid 9.0 (draft) - Project Documentation Editor


          Note that the above example may have shown the Dynamic VDB, but it also works with Designer based .VDB *if* all the REST properties are correctly set and "auto-generate" property is set on the VDB. In this procedure, you do NOT need to generate the .WAR file, when you deploy a .VDB file, one is automatically generated for you.


          Ramesh..

          • 2. Re: Rest WAR web service return errror
            mirco73

            Hi Ramesh,

            I succeeded in deployng the VDB and running the Rest Web Service with no problem.

            The only problem I found was about the model name: if I create a model with capital letters, when I call the Web Service in the URL it must be lowercase otherwise the resource is not found: is it correct ?

             

            A final question: I authenticate on the Web Service the the basic authentication protocol, but is there a way to pass this user to teeid in order to use it in the Data Roles ? (for Example I'd like to apply some row filters or Column Masking). It seems the the user is presented a anonymous (I've created a Data Role in the Vdb and executed the WS):

             

            14:54:00,043 WARN  [org.teiid.PROCESSOR] (http-/0.0.0.0:8080-2) jkuLsbr1Mv2/ TEIID30020 Processing exception for request jkuLsbr1Mv2/.1 'TEIID30492 User <anonymous> is not entitled to action <EXECUTE> for 1 or more of the groups/elements/procedures.'. Originally QueryValidatorException Request.java:328. Enable more detailed logging to see the entire stacktrace.

            14:54:00,049 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (http-/0.0.0.0:8080-2) null RESTEASY000105: Failed to execute: javax.ws.rs.WebApplicationException: org.teiid.jdbc.TeiidSQLException: TEIID30492 User <anonymous> is not entitled to action <EXECUTE> for 1 or more of the groups/elements/procedures.

                at org.teiid.jboss.rest.TeiidRSProvider$1.write(TeiidRSProvider.java:75) [teiid-jboss-integration-8.11.4.jar:8.11.4]

                at org.jboss.resteasy.plugins.providers.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:32) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.plugins.providers.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:17) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.plugins.providers.jackson.JacksonJsonpInterceptor.write(JacksonJsonpInterceptor.java:112) [resteasy-jackson-provider-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:104) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:615) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:527) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:125) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.9.Final-redhat-7.jar:]

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:512) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.0.Final-redhat-15.jar:7.5.0.Final-redhat-15]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.3.Final.jar:7.5.3.Final]

                at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_60]

             

            cheers,

            Mirco

            • 3. Re: Rest WAR web service return errror
              rareddy

              Mirco,

               

              I need to check the code on the casing of the "model" name, may be for the JAX-RS engine only sees one way, we can probably see and enforce the defined casing?

               

              The basic auth does propagate the user to the Teiid, so should be able to use the "dataroles", if you are not seeing the same user, then there is an issue somewhere. Did you follow the directions on how to setup the AUTH from above link correctly? If not you can provide me  your test vdb, I will check.


              Ramesh..

              • 4. Re: Rest WAR web service return errror
                mirco73

                Hi Ramesh.

                here is my test vdb. In this there are the two previous discussed cases:

                 

                - for the model views "testWS" and "testView" I can execute the web service only if the URL is

                http://serverAddress:port/testVdb_1/testws/listaXML/0000004541 or

                http://serverAddress:port/testVdb_1/testview/listaXML/0000004541

                 

                and not

                 

                http://serverAddress:port/testVdb_1/testWS/listaXML/0000004541 or

                http://serverAddress:port/testVdb_1/testView/listaXML/0000004541

                 

                 

                - For the second case, I've created a Data role with a row filter for role "testGroup" and my aplication-roles.properties has the following row.

                 

                user=odata,rest,testGroup

                 

                If I connect through JDBC with "user" I can see only the restricted data, while if i consume the Web Service with the same user I get the "anonymous" error

                 

                cheers,

                Mirco

                • 5. Re: Rest WAR web service return errror
                  rareddy

                  Yes, both seems to be bugs. Can you log JIRAs for them. I think the data role is probably a regression somewhere. So log a JIRA for removing the lower case, and then the user pass through.

                   

                  Ramesh..

                  • 6. Re: Rest WAR web service return errror
                    rareddy

                    Mirco,

                     

                    Actually the pass-though authentication is not a coding issue at all, it is more of documentation issue.  Which is fixed now at  REST Service Through VDB - Teiid 9.0 (draft) - Project Documentation Editor

                     

                    I will summarize it here. What you need to do is add a property to the VDB. This is same place you added the "auto-generate", if there is no predefined property already in the Designer, then add like a custom property, or manually add it once the VDB is created. (you can open .VDB with zip utilities)

                     

                        <property name="{http://teiid.org/rest}passthrough-auth" value = "true"/>
                    

                     

                    By default, the security is enforced at web layer, but not at Teiid layer. As we trust in VM user. The above property make the principle flow into Teiid from web layer. Now, Teiid needs to make sure this user is using same security-domain as the web-layer, then only it will allow it. As I said before the Teiid's local connection is by default "trusting", we need to flip this *not* to.  For that, you need to edit "standalone-teiid.xml" file, and find the "teiid" subsystem, and edit the "embedded" transport configuration as below

                     

                    <transport name="embedded">
                       <authentication security-domain="teiid-security"/>
                    </transport>
                    

                     

                    Then restart the server, undeploy the old VDB and redeploy the new VDB, then the data roles will be honored.

                     

                    I still need JIRA for lower casing of model name issue

                     

                    Ramesh..

                    • 7. Re: Rest WAR web service return errror
                      rareddy

                      Little confusion again, the 8.12 documentation is here REST Service Through VDB - Teiid 8.12 - Project Documentation Editor, that shows the correct properties already. The above link is current draft documentation for 9.0, where "passthough" has been defaulted to true, without the need for the additional property.

                      • 8. Re: Rest WAR web service return errror
                        mirco73

                        Hi Ramesh,

                        I succeeded in deploying and activating the passthrough as indicated by you and in the link above.

                        I'd like to advise you of the following:

                         

                        - With JBoss Designer 9.0.0 GA, in addition to the add in the standaolone-teiid.xml and the passthrough property, I had to flag "Pass Thru Authentication" in JBoss designer during the deploying of the VDB (in the "Create VDB Data Source" window), otherwise I had the same error

                         

                        - With JBoss Designer 9.0.0 GA it is not possible di add the custom property {http://teiid.org/rest}passthrough-auth from the User Defined Properties mask

                        It seems there is a check on the input filed: "Name must contain only letters, numbers or a '-' ", so I had to insert the property directly in the VDB

                         

                        Cheers

                        Mirco

                         

                        PS:

                        for the model view issue I've opened TEIIDDES-2717

                        • 9. Re: Rest WAR web service return errror
                          rareddy

                          - With JBoss Designer 9.0.0 GA, in addition to the add in the standaolone-teiid.xml and the passthrough property, I had to flag "Pass Thru Authentication" in JBoss designer during the deploying of the VDB (in the "Create VDB Data Source" window), otherwise I had the same error

                          This is not designed for preview or inside Designer testing. When you test inside Designer using the SQL windows, the web layer is completely by passed.

                           

                          - With JBoss Designer 9.0.0 GA it is not possible di add the custom property {http://teiid.org/rest}passthrough-auth from the User Defined Properties mask

                          It seems there is a check on the input filed: "Name must contain only letters, numbers or a '-' ", so I had to insert the property directly in the VDB

                           

                          You add another Designer JIRA to allow "-" in the names of the custom properties on the VDB.

                          • 10. Re: Rest WAR web service return errror
                            jietao

                            I used the auto-generate rest war now due to the same error java.sql.SQLException: java.lang.IllegalArgumentException: Null charset name. As I tried to call http://localhost:8080/GFBIVDB_1/ I got a window asking username and password:

                             

                            A username and password are being requested by http://localhost:8080. The site says: "yourdomain.com"

                             

                            Which user name and password? I do not set any.

                            • 11. Re: Rest WAR web service return errror
                              jietao

                              I got it. This is a JBoss user and the user must be given a role "rest". However, with auto-generated REST WAR I cannot get JSON from the web service (I use XML Literal in the procedure). A question is: is this problem "java.sql.SQLException: java.lang.IllegalArgumentException: Null charset name" in processing?

                               

                              thx

                              • 12. Re: Rest WAR web service return errror
                                rareddy

                                By default these services are secured by "HTTP Basic" using the same "security-domain" as your default security domain used for JDBC transport. So, use the same name and password as your JDBC client.

                                • 13. Re: Rest WAR web service return errror
                                  rareddy

                                  with auto-generated REST WAR I cannot get JSON from the web service (I use XML Literal in the procedure).

                                  Why not? If you are trying to produce JSON from this procedure, use the JSON Functions to generate the content in JSON form, and set the "ACCEPTS" metadata property on procedure to "JSON", and when you issue your REST call from client make sure you set the "Content Type" to "application/json". So, basically instead of using SQL/XML functions, you will use JSON Functions in your transformation to build the return payload.

                                   

                                  If you want to deliver both XML and JSON payloads, create two procedures with different transformations, but with same "PATH" and different "ACCEPTS" metadata properties. Then your client can choose which to payload to read from using the "content type" header.

                                   

                                  Designer based REST war, tries converts the XML payload into JSON, but there you do not have an option as to how final JSON should look like, with what I described above you have complete control over the payload of the web-service.

                                   

                                  Ramesh..