1 2 Previous Next 15 Replies Latest reply on Jul 30, 2012 11:09 AM by shawkins

    Error building Source for context item.

    mlopezal

      I've created a procedure what consume a service which return the next output:

      {

      "result": {

      "guid": "#9202a8c04000641f800000000002db30",

      "/travel/travel_destination/tourist_attractions": [

      {

      "/common/topic/official_website": "http://www.notredamedeparis.fr",

      "guid": "#9202a8c04000641f800000000007678f",

      "name": "Notre Dame de Paris"

      },

      {

      "/common/topic/official_website": null,

      "guid": "#9202a8c04000641f8000000000014101",

      "name": "Eiffel Tower"

      },

      {

      "/common/topic/official_website": null,

      "guid": "#9202a8c04000641f80000000001d3985",

      "name": "\u00cele de la Cit\u00e9"

      },

      {

      "/common/topic/official_website": null,

      "guid": "#9202a8c04000641f8000000000274f09",

      "name": "Folies Berg\u00e8res"

      }, ...

       

      to avoid errors of characters I use "convert"  and to_chars functions in this way:

       

      CREATE VIRTUAL PROCEDURE

      BEGIN

                DECLARE string VARIABLES.IN_city = LocationREST.getTouristAttraction.guid;

                DECLARE string VARIABLES.INPUT_ENDPOINT;

                VARIABLES.INPUT_ENDPOINT = (('?query={"guid":"%23' || VARIABLES.IN_city) || '","/travel/travel_destination/tourist_attractions":[{"guid":null,"name":null,"/common/topic/official_website" : null}]}');

                VARIABLES.INPUT_ENDPOINT = REPLACE(VARIABLES.INPUT_ENDPOINT, ' ', '%20');

                CREATE LOCAL TEMPORARY TABLE TEMP (name string, website string, guid string);

                LOOP ON (SELECT CONVERT(TO_CHARS(t.guidtemp, 'BASE64'), string) AS guidtemp, CONVERT(TO_CHARS(t.nametemp, 'BASE64'), string) AS nametemp, CONVERT(TO_CHARS(t.websitetemp, 'BASE64'), string) AS websitetemp FROM (EXEC FreebaseMQLRead.invokeHttp(action => 'GET', endpoint => VARIABLES.INPUT_ENDPOINT)) AS x, XMLTABLE('/FreebaseIDResult/result/_u002F_travel_u002F_travel_destination_u002F_tourist_attractions/*' PASSING JSONTOXML('FreebaseIDResult', x.result) COLUMNS guidtemp blob PATH 'guid', nametemp blob PATH 'name', websitetemp blob PATH '_u002F_common_u002F_topic_u002F_official_website') AS t) AS txncursor

                BEGIN

                          INSERT INTO TEMP (TEMP.guid, TEMP.name, TEMP.website) VALUES (txncursor.guidtemp, txncursor.nametemp, txncursor.websitetemp);

                END

                SELECT XMLELEMENT(NAME TouristAttractions, XMLAGG(XMLELEMENT(NAME TouristAttraction, XMLFOREST(temp.guid AS GUID, temp.name AS NAME, temp.website AS WEBSITE)))) AS xmlResult FROM temp;

      END

       

      But I obtain the next error:

      Remote org.teiid.core.TeiidProcessingException: Error building Source for context item.

       

      Any help please?

        • 1. Re: Error building Source for context item.
          shawkins

          The exception should have the cause with the underlying problem and the server should have also logged at least the root message, or the entire stacktrace if in debug. 

          • 2. Re: Error building Source for context item.
            mlopezal

            That's the log, but I don't understand why it can make the conversion

             

            Caused by: nu.xom.ParsingException: Invalid conversion from type class java.lang.String with value '#9202a8c04000641f800000000007639b' to type class org.teiid.core.types.BlobType

                      at nu.xom.Builder.build(Builder.java:1183)

                      at nu.xom.Builder.build(Builder.java:599)

                      at org.teiid.query.xquery.saxon.XQueryEvaluator.evaluateXQuery(XQueryEvaluator.java:121)

                      ... 7 more

            Caused by: Invalid conversion from type class java.lang.String with value '#9202a8c04000641f800000000007639b' to type class org.teiid.core.types.BlobTypeInvalid conversion from type class java.lang.String with value '#9202a8c04000641f800000000007639b' to type class org.teiid.core.types.BlobType

                      at org.teiid.query.processor.relational.XMLTableNode.processRow(XMLTableNode.java:349)

                      at org.teiid.query.xquery.saxon.XQueryEvaluator$2.transform(XQueryEvaluator.java:112)

                      at nux.xom.xquery.StreamingPathFilter$StreamingPathFilterNodeFactory.transformMatch(StreamingPathFilter.java:461)

                      at nux.xom.xquery.StreamingPathFilter$StreamingPathFilterNodeFactory.finishMakingElement(StreamingPathFilter.java:445)

                      at nu.xom.XOMHandler.endElement(XOMHandler.java:238)

                      at net.sf.saxon.event.ContentHandlerProxy.endElement(ContentHandlerProxy.java:391)

                      at org.teiid.query.xquery.saxon.ContentHandlerProxyReceiver.endElement(StreamingUtils.java:247)

                      at net.sf.saxon.event.ProxyReceiver.endElement(ProxyReceiver.java:178)

                      at org.teiid.query.xquery.saxon.PathMapFilter.endElement(PathMapFilter.java:184)

                      at net.sf.saxon.event.ReceivingContentHandler.endElement(ReceivingContentHandler.java:447)

                      at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)

                      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)

                      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                      at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)

                      at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:397)

                      at net.sf.saxon.event.Sender.send(Sender.java:182)

                      at net.sf.saxon.Configuration.buildDocument(Configuration.java:3317)

                      at net.sf.saxon.Configuration.buildDocument(Configuration.java:3262)

                      at org.teiid.query.xquery.saxon.SaxonReader.parse(StreamingUtils.java:169)

                      at nu.xom.Builder.build(Builder.java:1160)

                      ... 9 more

            Caused by: [TransformationException]Invalid conversion from type class java.lang.String with value '#9202a8c04000641f800000000007639b' to type class org.teiid.core.types.BlobType

                      at org.teiid.core.types.DataTypeManager.transformValue(DataTypeManager.java:851)

                      at org.teiid.core.types.DataTypeManager.transformValue(DataTypeManager.java:838)

                      at org.teiid.query.function.FunctionDescriptor.importValue(FunctionDescriptor.java:225)

                      at org.teiid.query.processor.relational.XMLTableNode.processRow(XMLTableNode.java:306)

                      at org.teiid.query.processor.relational.XMLTableNode.processRow(XMLTableNode.java:343)

            • 3. Re: Error building Source for context item.
              rareddy

              TO_CHARS is complaining that it can not convert string to blob. This function is used to convert blob to clob, so that it can be converted to string. You already have in string form.

               

              Ramesh..

              • 4. Re: Error building Source for context item.
                mlopezal

                So, how can I avoid the character error that I obtained when no conversion is done?:

                 

                Error de lectura XML: mal formado

                Ubicación: http://localhost:8888/EnriquecimientoBusquedaData/LocationREST/getTouristAttraction/9202a8c04000641f80000000000094d6

                Número de línea 1, columna 793:<TouristAttractions><TouristAttraction><GUID>#9202a8c04000641f8000000004772c88</GUID><NAME>Deutscher Dom</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f800000000768a444</GUID><NAME>Reichstag dome</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f8000000000031256</GUID><NAME>Potsdamer Platz</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f8000000000279f1f</GUID><NAME>Berliner Dom</NAME><WEBSITE>http://www.berliner-dom.de/</WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000002bbff0</GUID><NAME>Kaiser Wilhelm Memorial Church</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000009de7ce</GUID><NAME>Franz sischer Dom</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000007c0fe5</GUID><NAME>Deutsches Historisches Museum</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000007ddf91</GUID><NAME>Gem�ldegalerie, Berlin</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f8000000000189176</GUID><NAME>Pergamon Museum</NAME><WEBSITE>http://www.smb.museum/smb/standorte/index.php?lang=en&amp;p=2&amp;objID=27&amp;n=1&amp;r=4</WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f800000000015c46a</GUID><NAME>Checkpoint Charlie</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000001245a8</GUID><NAME>Brandenburg Gate</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f8000000000007c4b</GUID><NAME>Alexanderplatz</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000003860ec</GUID><NAME>Olympic Stadium</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f8000000000877229</GUID><NAME>Charlottenburg Palace</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f8000000007e48e42</GUID><NAME>Deutsche Guggenheim, Berlin</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f800000001c5c2bbc</GUID><NAME>K�the Kollwitz Museum</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000004b9474</GUID><NAME>Humboldt Museum</NAME><WEBSITE>http://www.naturkundemuseum-berlin.de/index_english.html</WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000002e67d7</GUID><NAME>Neue Nationalgalerie</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000203b1009</GUID><NAME>Collegienhaus</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f80000000002c112a</GUID><NAME>Jewish Museum Berlin</NAME><WEBSITE></WEBSITE></TouristAttraction><TouristAttraction><GUID>#9202a8c04000641f8000000000009da5</GUID><NAME>Berlin Wall</NAME><WEBSITE></WEBSITE></TouristAttraction></TouristAttractions>

                ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^

                • 5. Re: Error building Source for context item.
                  shawkins

                  So there are a couple of things going on here.  You are receiving the wrong error message, that wrapping shouldn't be happening.  That was corrected in trunk prior to beta1, but I see that there's a regression as well which is swallowing the error if xpath streaming is used.  That was just addressed on trunk.

                   

                  A blob type columm: websitetemp blob PATH '_u002F_common_u002F_topic_u002F_official_website'

                   

                  Will currently not work unless the element is marked with an xsi:type of xs:hexBinary or xs:base64Binary, then Saxon will give us a byte[] that we'll treat as a blob.  There is room for a an improvement there, since we can map blob to the xs:base64Binary type, but I don't think that it applies to your case.  What do you expect in the NAME element?  Is it getting converted to something inappropriate by the jsonToXml function or is it due to the extraction?

                   

                  Steve

                  • 6. Re: Error building Source for context item.
                    mlopezal

                    The problem is that in the source webservice I obtain JSON data as "name": "Basilica of the Sacr\u00e9 C\u0153ur". but I don't know how to manage it to avoid the error. I supposed is in the extraction of information.

                    Regards,

                    Mónica

                    • 7. Re: Error building Source for context item.
                      shawkins

                      To experiment with this scenario:

                       

                      {code:sql}select xmlelement(name \"name\", name) from xmltable('/Place' passing jsontoxml('Place', '{\"name\": \"\\u00cele de la Cit\\u00e9\"}') columns name string) as x{code}

                       

                      Gives me the result:

                       

                      {code:xml}<name>Île de la Cité</name>{code}

                       

                      How do you want the value to appear in the final doc?  And how are you serializing the document? 

                       

                      Also if you'r results are not large and you're simply transforming the document, you would use the XSLTRANSFORM function to apply a style sheet.

                       

                      Steve

                      • 8. Re: Error building Source for context item.
                        mlopezal

                        The problem is when I publish this result in a REST Service generated by "Generate RestEasyWay" functionality.

                        When I execute the procedure of this service in the designer there're no errors at first sight (It returns a field with the XML object but no the content, org.teiid.core.types.SQLXMLImpl@2a82b5c3, I don't know how to display it, in the trace it doesn't appear), but in the browser return the Error de lectura XML: mal formado.

                        Could you help me?

                        Thanks a lot !

                        • 9. Re: Error building Source for context item.
                          mlopezal

                          Look, I change the result type of procedure (the one of the REST Service) to string to see the content result and I obtained a "good" string.

                          The problem is when I change the result type to XMLliteral and publish the procedure as REST Service

                          Any idea?

                          Thanks,

                          Mónica

                          • 10. Re: Error building Source for context item.
                            shawkins

                            Designer is piggy backing off of DTP, which like SQuirreL, doesn't have good support fo SQLXML values.  To see the document you'll want to use XMLSERIALIZE function to produce a string/clob.  This should be similar to what you did by changing the return type to string.

                             

                            As a string did everything work correctly through RestEasy?  If so then there is an issue with either RestEasy or our generated functionality.

                            • 11. Re: Error building Source for context item.
                              mlopezal

                              Yes I've change the type from XMLLiteral to string using Xmlserialize and the result is correct but no with XMLLiteral to use it in the RESTeasy webservice.

                              Could you help me?

                              • 12. Re: Error building Source for context item.
                                shawkins

                                Just to make sure we're at the same place. You're generating the RESTEasy war through the Designer correct? 

                                 

                                If that's the case then your procedure is being consumed by the clasee TeiidRSProvider.  It's doing to get the result is calling getString on the SQLXML object, which is basically the same as the XMLSERIALIZE call.  So presumably you have no issue up to that point.  The problem could then be with the serialization of that result.  We don't have an encoding declaration in the xml, so whatever the browser is assuming would need to be what the doc was serialized as.  I'm trying to track down where that would be in the generated REST logic, but I'm not familiar enough to saw for sure at this point.

                                 

                                Steve

                                • 13. Re: Error building Source for context item.
                                  shawkins

                                  I suspect there is an issue here.  We need to do have some control over the final serialization and probably the addition of an xml declaration of the encoding.  Can you open a designer jira on the support of unicode characters through the REST support and reference this topic?

                                   

                                  Steve

                                  • 14. Re: Error building Source for context item.
                                    mlopezal

                                    Great and bad news, I solved adding

                                    <?xml version="1.0" encoding="iso-8859-1" ?>

                                    in the beginning of the result variable of the procedure, of XMLliteral type. But the problem now is other, I don't know how to concat a string and a clob in order to create the XMLliteral.

                                    1 2 Previous Next