ElPatriota / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

Consumer unable to parse EdmType if it's a collection of complex types #100

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create an OData service that will have a collection of complex types as 
property
2. execute getMetadata() via consumer class

What is the expected output? What do you see instead?
Exception has been thrown. Here is a stack trace.
Exception in thread "main" java.lang.RuntimeException: Edm-type not found: 
Collection(tns.MultiStringRow)
    at org.odata4j.edm.EdmType$DeferredBuilder.buildImpl(EdmType.java:141)
    at org.odata4j.edm.EdmType$Builder._build(EdmType.java:107)
    at org.odata4j.edm.EdmType$DeferredBuilder.build(EdmType.java:134)
    at org.odata4j.edm.EdmProperty$Builder.build(EdmProperty.java:207)
    at org.odata4j.edm.EdmStructuralType.<init>(EdmStructuralType.java:40)
    at org.odata4j.edm.EdmComplexType.<init>(EdmComplexType.java:27)
    at org.odata4j.edm.EdmComplexType.<init>(EdmComplexType.java:22)
    at org.odata4j.edm.EdmComplexType$Builder.buildImpl(EdmComplexType.java:54)
    at org.odata4j.edm.EdmType$Builder._build(EdmType.java:107)
    at org.odata4j.edm.EdmComplexType$Builder.build(EdmComplexType.java:49)
    at org.odata4j.edm.EdmSchema$Builder.build(EdmSchema.java:120)
    at org.odata4j.edm.EdmDataServices$Builder.build(EdmDataServices.java:230)
    at org.odata4j.format.xml.EdmxFormatParser.parseMetadata(EdmxFormatParser.java:80)
    at org.odata4j.consumer.ODataClient.getMetadata(ODataClient.java:70)
    at org.odata4j.consumer.ODataConsumer$CachedEdmDataServices.refreshDelegate(ODataConsumer.java:592)
    at org.odata4j.consumer.ODataConsumer$CachedEdmDataServices.getDelegate(ODataConsumer.java:586)
    at org.odata4j.internal.EdmDataServicesDecorator.findEdmEntitySet(EdmDataServicesDecorator.java:46)
    at org.odata4j.consumer.ODataConsumer$CachedEdmDataServices.findEdmEntitySet(ODataConsumer.java:598)
    at com.sap.odp.integration.test.odata.ODataMaterialTest.upgradeRootEntityTest(ODataMaterialTest.java:40)
    at com.sap.odp.integration.test.odata.ODataMaterialTest.run(ODataMaterialTest.java:31)
    at com.sap.odp.integration.test.odata.ODataMaterialTest.main(ODataMaterialTest.java:26)

metadata xml is attached

What version of the product are you using? On what operating system?
0.5 Win7

Please provide any additional information below.

Original issue reported on code.google.com by kisel.ev...@gmail.com on 19 Dec 2011 at 10:30

Attachments:

GoogleCodeExporter commented 8 years ago
Tony, mind taking a look at this?

Original comment by john.spurlock on 15 Jan 2012 at 10:57

GoogleCodeExporter commented 8 years ago
sure...(several  minutes later):  the attached metadata is not valid CSDL. Line 
5 is incorrect syntax for specifying a collection:

It shows: <Property Name="Row" Nullable="false" 
Type="Collection(tns.MultiStringRow)" />

The correct way is:
<Property Name="Row" Nullable="false" Type="tns.MultiStringRow" 
CollectionKind="None|Bag|List" />

Is this metadata from a real service?  How is the producer implemented?  Is 
this one of those "we need to be lenient in our implementation" type scenarios?

Original comment by tony.ro...@gmail.com on 17 Jan 2012 at 6:12

GoogleCodeExporter commented 8 years ago
I am also facing a similar issue. My service exposes as CSDL 2.0. I have a 
nested complex structure in one of my EntityTypes which is multivalued.

<Property CollectionKind="List" Name="ValueDetails" Type="myns.ValueDetails"/>

<ComplexType Name="ValueDetails">
     <Property Name="Value" Type="Edm.String"/>
     <Property Name="Timestamp" Type="Edm.DateTime"/>
</ComplexType>

This internal collection of complex type looks like:
<d:ValueDetails>
     <d:element>
         <d:Value>10</d:Value>
         <d:Timestamp>2012-09-07T15:25:04.535+05:30</d:Timestamp>
     </d:element>
</d:ValueDetails>

But when I do getEntities on this EntityType, I get the following Exception:
Exception in thread "main" java.lang.RuntimeException: 
java.lang.RuntimeException: com.ctc.wstx.exc.WstxParsingException: Expected a 
text token, got START_ELEMENT.
 at [row,col {unknown-source}]: [16,11]
    at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:50)
    at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:482)
    at org.core4j.Enumerable$FuncIterator.hasNext(Enumerable.java:482)
    at com.ca.garan10.odata.ODataClient.main(ODataClient.java:32)
Caused by: java.lang.RuntimeException: com.ctc.wstx.exc.WstxParsingException: 
Expected a text token, got START_ELEMENT.
 at [row,col {unknown-source}]: [16,11]
    at org.odata4j.core.Throwables.propagate(Throwables.java:8)
    at org.odata4j.stax2.staximpl.StaxXMLFactoryProvider2$StaxXMLEventReader2.getElementText(StaxXMLFactoryProvider2.java:90)
    at org.odata4j.format.xml.AtomFeedFormatParser.parseProperties(AtomFeedFormatParser.java:205)
    at org.odata4j.format.xml.AtomFeedFormatParser.parseDSAtomEntry(AtomFeedFormatParser.java:249)
    at org.odata4j.format.xml.AtomFeedFormatParser.parseEntry(AtomFeedFormatParser.java:360)
    at org.odata4j.format.xml.AtomFeedFormatParser.parseFeed(AtomFeedFormatParser.java:155)
    at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:143)
    at org.odata4j.format.xml.AtomFeedFormatParser.parse(AtomFeedFormatParser.java:1)
    at org.odata4j.jersey.consumer.ConsumerQueryEntitiesRequest$EntryIterator.advance(ConsumerQueryEntitiesRequest.java:81)
    at org.core4j.ReadOnlyIterator.hasNext(ReadOnlyIterator.java:48)
    ... 3 more
Caused by: com.ctc.wstx.exc.WstxParsingException: Expected a text token, got 
START_ELEMENT.
 at [row,col {unknown-source}]: [16,11]
    at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:605)
    at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:461)
    at com.ctc.wstx.sr.BasicStreamReader.getElementText(BasicStreamReader.java:677)
    at com.ctc.wstx.evt.WstxEventReader.getElementText(WstxEventReader.java:118)
    at org.odata4j.stax2.staximpl.StaxXMLFactoryProvider2$StaxXMLEventReader2.getElementText(StaxXMLFactoryProvider2.java:88)
    ... 11 more

Original comment by gvnan...@gmail.com on 7 Sep 2012 at 10:07