13 Replies Latest reply on Jul 26, 2013 8:01 AM by rareddy

    calling servlet ( web service) through Teiid desinger gives error

    amitagrawal

      Hi,

       

      I have a simple servlet which retuns xml respsone as mentioned in the consumerest_ws_datasource.pdf example. I am calling this servlet from VDB using REST service connection profile. However, I get the below error while exeucting the final query on the table. I have also attached the VDB.

       

      servlet :

       

      this is the query executed from Squirrel : select * from MyCustomers

       

      below is the error long. appricate any help to resolve this issue.

       

      18:05:53,585 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "WebConvdb.vdb"
      18:05:53,616 INFO  [org.teiid.RUNTIME] (MSC service thread 1-4) TEIID50029 VDB WebConvdb.1 model "mywebsource" metadata is currently being loaded. Start Time: 7/18/13 6:05 PM
      18:05:53,616 INFO  [org.teiid.RUNTIME] (MSC service thread 1-4) TEIID50029 VDB WebConvdb.1 model "mywebview" metadata is currently being loaded. Start Time: 7/18/13 6:05 PM
      18:05:53,663 INFO  [org.jboss.as.server] (HttpManagementService-threads - 1) JBAS018559: Deployed "WebConvdb.vdb"
      18:05:53,678 INFO  [org.teiid.RUNTIME] (teiid-async-threads - 1) TEIID50030 VDB WebConvdb.1 model "mywebsource" metadata loaded. End Time: 7/18/13 6:05 PM
      18:05:53,678 INFO  [org.teiid.RUNTIME] (teiid-async-threads - 2) TEIID50030 VDB WebConvdb.1 model "mywebview" metadata loaded. End Time: 7/18/13 6:05 PM
      18:05:53,897 INFO  [org.teiid.RUNTIME] (teiid-async-threads - 2) TEIID40003 VDB WebConvdb.1 is set to ACTIVE
      18:06:43,772 DEBUG [org.teiid.COMMAND_LOG] (Worker1_QueryProcessorQueue13)  START DATA SRC COMMAND: startTime=2013-07-18 18:06:43.772 requestID=Zlg3MjVw1uyv.6 sourceCommandID=4 txID=null modelName=mywebsource translatorName=ws sessionID=Zlg3MjVw1uyv principal= sql=EXEC mywebsource.invoke('HTTP', 'GET', 'http://ssc80049:8080/WebServiceSource/SampleServlet')
      18:06:43,975 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (Worker1_QueryProcessorQueue13) Creating Service {http://teiid.org}teiid from class org.apache.cxf.jaxws.support.DummyImpl
      18:06:44,303 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (Worker1_QueryProcessorQueue13) Interceptor for {http://teiid.org}teiid#{http://cxf.apache.org/jaxws/dispatch}Invoke has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Could not write to XMLStreamWriter.
      at org.apache.cxf.interceptor.StaxOutEndingInterceptor.handleMessage(StaxOutEndingInterceptor.java:75)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
      at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
      at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:354)
      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:385)
      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:243)
      at org.teiid.translator.ws.WSProcedureExecution.execute(WSProcedureExecution.java:135)
      at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:257) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:457) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:177) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:174) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_45]
      at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_45]
      at org.teiid.dqp.internal.process.DQPCore$FutureWork.run(DQPCore.java:118) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:250) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:123) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:298) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_45]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_45]
      at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_45]
      Caused by: javax.xml.stream.XMLStreamException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document).
      at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1518)
      at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1547)
      at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1373)
      at com.ctc.wstx.sw.BaseStreamWriter.writeEndDocument(BaseStreamWriter.java:532)
      at org.apache.cxf.interceptor.StaxOutEndingInterceptor.handleMessage(StaxOutEndingInterceptor.java:56)
      ... 22 more

      18:06:44,319 DEBUG [org.teiid.COMMAND_LOG] (Worker1_QueryProcessorQueue13)  ERROR SRC COMMAND: endTime=2013-07-18 18:06:44.319 requestID=Zlg3MjVw1uyv.6 sourceCommandID=4 txID=null modelName=mywebsource translatorName=ws sessionID=Zlg3MjVw1uyv principal= finalRowCount=null
      18:06:44,334 WARN  [org.teiid.CONNECTOR] (Worker1_QueryProcessorQueue13) Connector worker process failed for atomic-request=Zlg3MjVw1uyv.6.4.0: org.teiid.translator.TranslatorException
      at org.teiid.translator.ws.WSProcedureExecution.execute(WSProcedureExecution.java:139)
      at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:257) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:457) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:177) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:174) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_45]
      at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_45]
      at org.teiid.dqp.internal.process.DQPCore$FutureWork.run(DQPCore.java:118) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:250) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:123) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:298) [teiid-engine-8.2.0.Final.jar:8.2.0.Final]
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_45]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_45]
      at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_45]
      Caused by: javax.xml.ws.http.HTTPException
      at org.apache.cxf.jaxws.DispatchImpl.mapException(DispatchImpl.java:273)
      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:392)
      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:243)
      at org.teiid.translator.ws.WSProcedureExecution.execute(WSProcedureExecution.java:135)
      ... 13 more
      Caused by: org.apache.cxf.interceptor.Fault: Could not write to XMLStreamWriter.
      at org.apache.cxf.interceptor.StaxOutEndingInterceptor.handleMessage(StaxOutEndingInterceptor.java:75)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
      at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
      at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:354)
      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:385)
      ... 15 more
      Caused by: javax.xml.stream.XMLStreamException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document).
      at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1518)
      at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1547)
      at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1373)
      at com.ctc.wstx.sw.BaseStreamWriter.writeEndDocument(BaseStreamWriter.java:532)
      at org.apache.cxf.interceptor.StaxOutEndingInterceptor.handleMessage(StaxOutEndingInterceptor.java:56)
      ... 22 more

      18:06:44,350 WARN  [org.teiid.PROCESSOR] (Worker0_QueryProcessorQueue14) TEIID30020 Processing exception 'TEIID30504 mywebsource: null' for request Zlg3MjVw1uyv.6.  Exception type org.teiid.core.TeiidProcessingException thrown from com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1518). Enable more detailed logging to see the entire stacktrace.

        • 1. Re: calling servlet ( web service) through Teiid desinger gives error
          rareddy

          Is error occurs only calling through VDB or do you get results when executed through say a web browser?

          • 2. Re: calling servlet ( web service) through Teiid desinger gives error
            amitagrawal

            This error occurs when I execute query through VDB. I get the below xml response when executing the ULR thurough Web browser. is that what you were asking?

             

            <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

            - <customers>
            - <customer>
            <customernumber>103</customernumber>
            <customername>Atelier graphique</customername>
            <contactlastname>Schmitt</contactlastname>
            <contactfirstname>Blaine</contactfirstname>
            <phone>40.32.2555</phone>
            <addressline1>54, rue Royale</addressline1>
            <addressline2 />
            <city>Nantes</city>
            <state />
            <postalcode>44000</postalcode>
            <country>France</country>
            <salesrepemployeenumber>1370</salesrepemployeenumber>
            <creditlimit>21000.0</creditlimit>
            </customer>
            </customers>
            • 3. Re: calling servlet ( web service) through Teiid desinger gives error
              rareddy

              Ok, now how are you calling it in the VDB? in a transformation? can you post the SQL you wrote? I would need Designer project to open your VDB and see the query.

              • 4. Re: calling servlet ( web service) through Teiid desinger gives error
                amitagrawal

                I wrote below query in transformation editor. once the VDB is created, I deployed it on seriver and finally executed select * from MyCustomers from Squirrel. I am also attaching my workspace.

                 

                 

                SELECT

                MyCustomers.ID, MyCustomers.Name, MyCustomers.ContactFirstName, MyCustomers.ContactLastName, MyCustomers.Phone, MyCustomers.Address, MyCustomers.Address2, MyCustomers.City, MyCustomers.State, MyCustomers.PostalCode, MyCustomers.Country, MyCustomers.CreditLimit

                 

                FROM

                (

                EXEC mywebsource.invoke(binding => 'HTTP', action => 'GET', endpoint => 'http://localhost:8080/WebServiceSource/SampleServlet')) AS ws, XMLTABLE('/customers/customer' PASSING ws.result COLUMNS ID integer PATH './customernumber', Name string PATH './customername', ContactFirstName string PATH './contactfirstname', ContactLastName string PATH './contactlastname', Phone string PATH './phone', Address string PATH './addressline1', Address2 string PATH './addressline2', City string PATH './city', State string PATH './state', PostalCode string PATH './postalcode', Country string PATH './country', CreditLimit bigdecimal PATH './creditlimit') AS

                MyCustomers

                 

                 

                 

                • 5. Re: calling servlet ( web service) through Teiid desinger gives error
                  rareddy

                  Now, when you issue the query through the SquirreL you will see the above exception right? Also, what vesion of Teiid are you using, try using Teiid 8.4.final and Teiid Designer 8.2 Alpha.

                  • 6. Re: calling servlet ( web service) through Teiid desinger gives error
                    amitagrawal

                    yes, I get the above excpetion while executing the query (select * from MyCustomers) from Squirrel.

                     

                    I am using below version of teiid.

                     

                    Teiid : teiid-8.2.0.Final

                    Teiid Designer : 8.0.0.Final

                    jboss-as-7.1.1.Final

                     

                    do you think this issue is  because of the older version of Teiid? can you also let me know if installing the versions you suggested would solve the issue?

                    • 7. Re: calling servlet ( web service) through Teiid desinger gives error
                      amitagrawal

                      Hi Ramesh,

                       

                      I tried the query after installing Teiid 8.4.final ,Teiid Designer 8.2 Alpha and Jboss jboss-eap-6.1.0.Alpha but now getting below error.

                       

                       

                       

                      17:19:15,397 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (Worker3_QueryProcessorQueue17) XIvNxdk7Q8WL Creating Service {http://teiid.org}teiid from class org.apache.cxf.jaxws.support.DummyImpl
                      17:19:15,397 WARN  [org.teiid.CONNECTOR] (Worker3_QueryProcessorQueue17) XIvNxdk7Q8WL Connector worker process failed for atomic-request=XIvNxdk7Q8WL.7.5.1: org.teiid.translator.TranslatorException
                      at org.teiid.translator.ws.WSProcedureExecution.execute(WSProcedureExecution.java:139)
                      at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:254) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:446) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:159) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:156) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_45]
                      at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_45]
                      at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:58) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:269) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:214) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]
                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_45]
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_45]
                      at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_45]
                      Caused by: javax.xml.ws.http.HTTPException
                      at org.apache.cxf.jaxws.DispatchImpl.mapException(DispatchImpl.java:273)
                      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:392)
                      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:243)
                      at org.teiid.translator.ws.WSProcedureExecution.execute(WSProcedureExecution.java:135)
                      ... 13 more
                      Caused by: org.apache.cxf.interceptor.Fault: No conduit initiator was found for the namespace http://www.w3.org/2004/08/wsdl/http.
                      at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:127)
                      at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63)
                      at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:850)
                      at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:525)
                      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
                      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
                      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
                      at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:354)
                      at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:385)
                      ... 15 more
                      Caused by: org.apache.cxf.BusException: No conduit initiator was found for the namespace http://www.w3.org/2004/08/wsdl/http.
                      at org.apache.cxf.bus.managers.ConduitInitiatorManagerImpl.getConduitInitiator(ConduitInitiatorManagerImpl.java:138)
                      at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:96)
                      ... 23 more

                      17:19:15,397 WARN  [org.teiid.PROCESSOR] (Worker2_QueryProcessorQueue18) XIvNxdk7Q8WL TEIID30020 Processing exception for request XIvNxdk7Q8WL.7 'TEIID30504 MyRESTDataSource: null'. Originally TeiidProcessingException 'No conduit initiator was found for the namespace http://www.w3.org/2004/08/wsdl/http.' ConduitInitiatorManagerImpl.java:138. Enable more detailed logging to see the entire stacktrace.

                      • 8. Re: calling servlet ( web service) through Teiid desinger gives error
                        rareddy

                        You got me thinking, but as I was trying it out, I realized that for REST type calls you need to use "invokeHttp" not "invoke". "invoke" is for the SOAP based calls. That may be reason your 8.2 did not work either.

                        • 9. Re: calling servlet ( web service) through Teiid desinger gives error
                          amitagrawal

                          HI Ramesh,

                           

                          Thanks for the reply. I was able to get it worked by using invokeHttp. can you point me to any docuemnt about passing http headers to the web service? I can send the reqeust using reqeust parameter but could find any document on sending headers ( specifically I want to send sm_user ( siteminder user header) to web service?)

                           

                          Thanks,

                          Amit

                          • 10. Re: calling servlet ( web service) through Teiid desinger gives error
                            rareddy

                            Amit,

                             

                            There is no built in way to do that from Teiid SQL language.

                             

                            Teiid 8.4 uses CXF underneath for all the HTTP communication. So you configure CXF for additional stuff. See https://docs.jboss.org/author/display/TEIID/Web+Service+Data+Sources especially 'Configuring SSL Support". Now, I searched for adding the custom headers in the CXF only found http://stackoverflow.com/questions/10479396/apache-cxf-set-http-header which you have to write a interceptor for. I am not sure if there any pre-built interceptor already available for htto-conduit to set the custom headers. Here is another CXF link where they mention different kind of authentications http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html that may be useful.

                             

                            If you do write the interceptor, you need to include the jar file in "jboss-eap-6.1/modules/system/layers/base/org/jboss/teiid/resource-adapter/webservice/main" directory and modify the "module.xml" to include it. If you do find another solution please let us know about it for other users.

                             

                            Ramesh..

                            • 11. Re: calling servlet ( web service) through Teiid desinger gives error
                              shawkins

                              It seems like for the invokeHttp case we could easily offer the ability to specify headers as the execution logic already supports custom header properties for odata usage.  We would just have to decide on an appropriate calling structure as we don't have something resembling a map (such as a varag string parameter that we process in pairs). 

                               

                              Steve

                              • 12. Re: calling servlet ( web service) through Teiid desinger gives error
                                amitagrawal

                                Hi Ramesh,

                                 

                                As I mentioned, I was able to get the servlet worked in 7.1.1 and teiid 8.2.  we are now wokring on creating a custom interceptor to pass the HTTP headers. can you let me know the corrosponding path in 7.1.1 where we have to copy the jar file and location of modules.xml file? Also, what will be the entry in the modules.xml so our own custom interceptor code gets invoked?

                                • 13. Re: calling servlet ( web service) through Teiid desinger gives error
                                  rareddy

                                  Amit,

                                   

                                  In Teiid 8.2, the resource-adapters were deployed as RAR files, in 8.4 version they are being deployed as modules. So, it is easy to do in Teiid 8.4. In Teiid 8.2, you can create a new module, or copy it in "modules/org/jboss/teiid/translator/ws/main" directory, and the entry in the module.xml in there about your jar. Then you would need to edit the MANIFEST.MF file in the "standalone/deployments/teiid-connector-ws.rar" and add "org.jboss.teiid.translator.ws" on the Dependencies line at the end. Note if you created a new module, this name would reflect that! Then restart the server.

                                   

                                  Ramesh..