在运行简单的Odata4j消费者时获得“意外字符'/'(代码47)”异常

时间:2014-07-17 09:13:29

标签: odata4j

我是odata4j的初学者。我正在尝试使用odata4j v0.7库运行以下程序 -

import org.core4j.Enumerable;
import org.odata4j.consumer.ODataConsumer;
import org.odata4j.consumer.ODataConsumers;
import org.odata4j.core.OEntity;
import org.odata4j.examples.AbstractExample;

public class MyOdataTest extends AbstractExample {

  public static void main(String[] args) {

    ODataConsumer consumer = ODataConsumers.create("http://services.odata.org/OData.svc");
    Enumerable<OEntity> qList = consumer.getEntities("Categories").execute();
  }

}

但是,当我在Eclipse中运行它时,我得到以下异常 -

Exception in thread "main" java.lang.RuntimeException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '/' (code 47) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
    at org.odata4j.core.Throwables.propagate(Throwables.java:11)
    at org.odata4j.stax2.staximpl.StaxXMLFactoryProvider2$StaxXMLEventReader2.nextEvent(StaxXMLFactoryProvider2.java:113)
    at org.odata4j.format.xml.EdmxFormatParser.parseMetadata(EdmxFormatParser.java:55)
    at org.odata4j.consumer.AbstractODataClient.getMetadata(AbstractODataClient.java:44)
    at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.refreshDelegate(AbstractODataConsumer.java:212)
    at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.getDelegate(AbstractODataConsumer.java:205)
    at org.odata4j.internal.EdmDataServicesDecorator.findEdmEntitySet(EdmDataServicesDecorator.java:46)
    at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.findEdmEntitySet(AbstractODataConsumer.java:221)
    at org.odata4j.consumer.AbstractODataConsumer.getFeedCustomizationMapping(AbstractODataConsumer.java:235)
    at org.odata4j.consumer.AbstractODataConsumer.getEntities(AbstractODataConsumer.java:73)
    at org.odata4j.consumer.AbstractODataConsumer.getEntities(AbstractODataConsumer.java:69)
    at com.example.MyOdataTest.main(MyOdataTest.java:16)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '/' (code 47) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2032)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1117)
    at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
    at org.odata4j.stax2.staximpl.StaxXMLFactoryProvider2$StaxXMLEventReader2.nextEvent(StaxXMLFactoryProvider2.java:111)
    ... 10 more

如果我错过了什么,请告诉我。感谢。

1 个答案:

答案 0 :(得分:0)

问题是已解决。我在jvm设置中使用错误的代理服务器端口号