loadIndex method throws IndexReadException

Saraswathy
2010-09-20
2013-05-15
  • Saraswathy

    Saraswathy - 2010-09-20

    Hi

    I’m  just trying out vtd xml to split my xml for my web application.  I’m using  jdk 1.5  So I created a vtd-xml.jar using build.bat and I’m using that in my application.
    My simple sample xml is
    <a>
      <b>hello world!</b>
    </a>
    My code snippet is
    URL inputSourceUrl = new URL("http://localhost:8080/mySampleApp/sample.xml");
            int i;
            VTDGen vg = new VTDGen();
            AutoPilot ap = new AutoPilot();
            ap.selectXPath("/a/b");
            VTDNav vn = vg.loadIndex(inputSourceUrl.openStream());
                ap.bind(vn);
                while ((i = ap.evalXPath()) != -1)
                {
                 System.out.println(" res= "+vn.toString(i));
                }
    I get the following stacktrace

    20:26:52,377 ERROR  com.ximpleware.IndexReadException: Invalid version number for readIndex()
    20:26:52,377 ERROR      at com.ximpleware.IndexHandler.readIndex(IndexHandler.java:430)
    20:26:52,377 ERROR      at com.ximpleware.VTDGen.loadIndex(VTDGen.java:1770)
    20:26:52,377 ERROR      at com.arp.action.SplitAction.execute(Unknown Source)
    20:26:52,377 ERROR      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
    20:26:52,377 ERROR      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
    20:26:52,377 ERROR      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    20:26:52,377 ERROR      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    20:26:52,377 ERROR      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    20:26:52,377 ERROR      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    20:26:52,377 ERROR      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    20:26:52,377 ERROR      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    20:26:52,377 ERROR      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    20:26:52,377 ERROR      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    20:26:52,377 ERROR      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    20:26:52,377 ERROR      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    20:26:52,377 ERROR      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    20:26:52,377 ERROR      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    20:26:52,377 ERROR      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    20:26:52,377 ERROR      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    20:26:52,377 ERROR      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    20:26:52,377 ERROR      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    20:26:52,377 ERROR      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    20:26:52,377 ERROR      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
    20:26:52,377 ERROR      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    20:26:52,377 ERROR      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    20:26:52,377 ERROR      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    20:26:52,377 ERROR      at java.lang.Thread.run(Thread.java:595)

    I’m able to successfully see the sample xml in the browser using the url http://localhost:8080/mySampleApp/sample.xml
    I tried the physical file location as a parameter to the loadIndex method and get the same exception.

    Can you please help?

     
  • jimmy zhang

    jimmy zhang - 2010-09-20

    did you get the latest version of vtd-xml?

     
  • Saraswathy

    Saraswathy - 2010-09-20

    yes I did download version 2.9 yesterday. I'm guessing if the input to loadIndex must be a vxl file and not an xml file

    I'm able to use parseHTTPUrl  method instead to get VTDNav

    URL is my option than loading from a physical file  as my xml will be dynamic.

     
  • jimmy zhang

    jimmy zhang - 2010-09-20

    it doesn't seem you are loading vxl files, so you probably just use parseHTTPUrl… that should work… am I right?

     
  • Saraswathy

    Saraswathy - 2010-09-20

    Yes. You are correct. Thank you.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks