com.complexible.stardog.protocols.http.server.StardogHttpServiceLoader:accept(226): An unexpected exception was handled by the server org.openrdf.query.QueryEvaluationException: Index: 32789, Size: 1

When I try to hit this code, it works sometimes and sometimes it fails. I am also running other sparql which runs fine.
Consolated error log is copied below.

Node code:

console.log(firstName+timezone);
   return query.execute(conn,'ps-bot-io', 'select ?greet { ' +
     '?s <http://specs.purpleslate.data/conversation#greet> ?greet .' +
     '} ORDER BY RAND()', {
     limit: 1,
     offset: 0
   }).then((result ) => {
....}

Error at node console log :

Error getGr`eting() { FetchError: request to http://35.154.253.26:5820/ps-bot-io/query failed, reason: Parse Error
    at ClientRequest.<anonymous> (/Users/arun/PurpleSlate/Work/ps-bot-intelligence/ps-bot-io/node_modules/node-fetch/index.js:134:11)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at Socket.socketOnData (_http_client.js:459:9)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:266:12)
    at readableAddChunk (_stream_readable.js:253:11)
    at Socket.Readable.push (_stream_readable.js:211:10)
    at TCP.onread (net.js:585:20)
  name: 'FetchError',
  message: 'request to http://35.154.253.26:5820/ps-bot-io/query failed, reason: Parse Error',
  type: 'system',
  errno: 'HPE_UNEXPECTED_CONTENT_LENGTH',
  code: 'HPE_UNEXPECTED_CONTENT_LENGTH' }
Error greeting match for Link or text: TypeError: Cannot read property 'match' of undefined
    at getGreeting.then (/Users/arun/PurpleSlate/Work/ps-bot-intelligence/ps-bot-io/routes/greeting.js:79:77)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Error log @ stardog.log:

ERROR 2017-09-22 06:47:52,905 [XNIO-1 task-5] com.complexible.stardog.protocols.http.server.StardogHttpServiceLoader:accept(226): An unexpected exception was handled by the server
org.openrdf.query.QueryEvaluationException: Index: 32789, Size: 1
	at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:81) ~[stardog-utils-rdf-5.0.2.jar:?]
	at org.openrdf.query.QueryResults.report(QueryResults.java:158) ~[sesame-query-4.0.0.jar:?]
	at org.openrdf.query.resultio.QueryResultIO.writeTuple(QueryResultIO.java:449) ~[sesame-queryresultio-api-4.0.0.jar:?]
	at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:475) ~[stardog-protocols-http-server-5.0.2.jar:?]
	at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:446) ~[stardog-protocols-http-server-5.0.2.jar:?]
	at com.complexible.stardog.protocols.http.server.SPARQLProtocol.executeQuery(SPARQLProtocol.java:133) ~[stardog-protocols-http-server-5.0.2.jar:?]
	at com.complexible.stardog.protocols.http.server.SPARQLProtocol.post(SPARQLProtocol.java:90) ~[stardog-protocols-http-server-5.0.2.jar:?]
	at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:186) ~[stardog-protocols-http-server-5.0.2.jar:?]
	at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) ~[shiro-core-1.2.3.jar:1.2.3]
	at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) ~[shiro-core-1.2.3.jar:1.2.3]
	at com.stardog.http.server.undertow.ErrorHandling.lambda$safeDispatch$1(ErrorHandling.java:70) ~[stardog-protocols-http-server-5.0.2.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_131]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: java.lang.IndexOutOfBoundsException: Index: 32789, Size: 1
	at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[?:1.8.0_131]
	at java.util.ArrayList.get(ArrayList.java:429) ~[?:1.8.0_131]
	at com.complexible.memory.memoryblock.DefaultMemoryBlockChain.get(DefaultMemoryBlockChain.java:246) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.input.impl.MemoryInput.resetIndices(MemoryInput.java:249) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.input.impl.MemoryInput.initMemoryIndices(MemoryInput.java:343) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.input.impl.MemoryInput.init(MemoryInput.java:329) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.input.impl.DefaultTapeElementInputFactory.createMemoryInput(DefaultTapeElementInputFactory.java:78) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseConventionalQuickSorter.compare(BaseConventionalQuickSorter.java:66) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseQuickSorter.compare0(BaseQuickSorter.java:79) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseQuickSorter.isGreaterThanCurrent(BaseQuickSorter.java:53) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.sortPartition(BaseSorter.java:91) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.quickSort0(BaseSorter.java:74) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.quickSort0(BaseSorter.java:75) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.quickSort0(BaseSorter.java:75) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.quickSort0(BaseSorter.java:75) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.quickSort0(BaseSorter.java:75) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.quickSort0(BaseSorter.java:75) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.sort0(BaseSorter.java:36) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.sort.sorters.quick.BaseSorter.sort(BaseSorter.java:24) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.impl.array.sorted.BaseSortedArray.sort(BaseSortedArray.java:391) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.impl.array.sorted.BaseSortedArray.sortDataInBlocks(BaseSortedArray.java:384) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.impl.array.sorted.BaseSortedArray.getTapeIterator(BaseSortedArray.java:166) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.memory.structure.impl.array.sorted.SortableArrayImpl.getTapeIterator(SortableArrayImpl.java:81) ~[stardog-memory-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.mmcollections.AbstractMMSolutionSequence.lambda$iterator$0(AbstractMMSolutionSequence.java:45) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.mmcollections.TapeToSolutionIterator.reset(CursorSolutionIterator.java:42) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.mmcollections.TapeToSolutionIterator.<init>(CursorSolutionIterator.java:36) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.mmcollections.AbstractMMSolutionSequence.iterator(AbstractMMSolutionSequence.java:45) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.mmcollections.OrderByMMSolutionSequence.iterator(OrderByMMSolutionSequence.java:35) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.mmcollections.AbstractMMSolutionSequence.iterator(AbstractMMSolutionSequence.java:28) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.OrderOp.sort(OrderOp.java:155) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.OrderOp.computeNext(OrderOp.java:137) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.OrderOp.computeNext(OrderOp.java:31) ~[stardog-5.0.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.0.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:83) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:33) ~[stardog-5.0.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.0.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:112) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:25) ~[stardog-5.0.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-5.0.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:110) ~[stardog-5.0.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:34) ~[stardog-5.0.2.jar:?]
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143) ~[guava-18.0.jar:?]
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138) ~[guava-18.0.jar:?]
	at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:77) ~[stardog-utils-rdf-5.0.2.jar:?]
	... 13 more

Hi, the HPE_UNEXPECTED_CONTENT_LENGTH error is a known bug in Stardog 5.0.2 when running stardog.js in Windows. Stardog 5.0.3 fixes this issue.

Hi Stephen, Thanks for the response.

I change the stardog to the new version 5.0.3 and still get the same error.
I did an error catch at stardog lib and i get this.

node code snippets:

return query.execute(conn,'xyz', 'select ?greet { ' +
     '?s <http://specs.abc.data/conversation#greet> ?greet .' +
     '} ORDER BY RAND() ', {
select ?greet { ?s <XXxxxxxxxxxx/conversation#greet> ?greet .} ORDER BY RAND() [object Object]
stardog dispatch:FetchError: request to http://xxxxxxx:5820/abc/query failed, reason: Parse Error
Error getGreeting() TypeError: Cannot read property 'body' of undefined
    at query.execute.then (/Users/arun/PurpleSlate/Work/ps-bot-intelligence/ps-bot-io/routes/greeting.js:119:57)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
Error greeting match for Link or text: TypeError: Cannot read property 'match' of undefined
    at getGreeting.then (/Users/arun/PurpleSlate/Work/ps-bot-intelligence/ps-bot-io/routes/greeting.js:79:77)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Just from your response. The OS is not windows, it is ubuntu.

I am unable to reproduce this with stardog 5.0.3 and stardog.js 1.0.0-rc3. Could you post your entire code? Specifically what you’re doing with the Promise returned by query.execute?

function getGreeting(firstName, timezone) {

   console.log(firstName+timezone);
   return query.execute(conn,'ps-bot-io', 'select ?greet { ' +
     '?s <http://specs.purpleslate.data/conversation#greet> ?greet .' +
     '} ORDER BY RAND() ', {

     limit: 1,
     offset: 0
   }).then((result ) => {


        greeting = parser.parse(json.stringify(result.body.results.bindings));
      for(count in greeting) {
        greeting_data = json.stringify(greeting[count]['greet']['value']);
      }

      if (convertStringToLowerCase(greeting_data).match('<name>')) {
        greetingData_Splited = greeting_data.replace('/"/g,""').split('<');

        if (firstName != null && firstName != '' &&  firstName != 'undefined') {
          greeting_data = greetingData_Splited[0]+firstName;
          return greeting_data;
        } else {
          return greetingData_Splited[0];
        }


      } else if (convertStringToLowerCase(greeting_data).match('<time>')) {
        var currentHourOnThatLocation = (greetBasedOfTime()+timezone);
          if (currentHourOnThatLocation >=0 && currentHourOnThatLocation < 4) {
            return "Welcome Night Owler...";
          }
          else if (currentHourOnThatLocation >= 4 && currentHourOnThatLocation < 12) {
              return "Good Morning...";
          } else if (currentHourOnThatLocation >= 12 && currentHourOnThatLocation < 16 ) {
              return "Good Afternoon...";
          } else if (currentHourOnThatLocation >= 16 && currentHourOnThatLocation < 24 ) {
              return "Good Evening..."
          } else {
              return "Good Day..."
          }
      } else {
          return greeting_data.replace(/"/g,"");
      }

    }).catch(error => console.log ("Error getGreeting()", error));

 }

Hi Stephen,
Any hunch on the issue. I just tried to go further and add a catch to the
stardog.js /stardog/query/main.js

const dispatchQuery = (conn, config, options = {}, params = {}) => {
  const headers = conn.headers();
  headers.set('Accept', options.accept || config.accept);
  headers.set('Content-Type', 'application/x-www-form-urlencoded');

  const queryString = qs.stringify(params);

  const uri =
    conn.uri(config.database, config.resource) +
    (queryString.length > 0 ? `?${queryString}` : '');
  console.log(config.query+headers)
  return fetch(uri, {
    method: 'POST',
    body: qs.stringify({ query: config.query }),
    headers,
  }).then(httpBody).catch( error => { console.log("stardog dispatch:"+error)});
};

The stardog dispatch is returning me. Stardog body is returning empty.

Hi,
The offset, limit function block is not working, I just passed the limit along with the sparql and code seems to work. Problem with stardog.js is not attaching the limit object with the sparql later. Please confirm what I tried is a good implemenation.

Code which is not working:

query.execute(conn,'database', 'select ?abc { ' +
     '?s <http://specs.purpleslate.data/qwerty#abc> ?abc .' +
     '} order by rand() ',{ limit:1, offset:0 }).then((result ) => {

Code which is working:

query.execute(conn,'database', 'select ?abc { ' +
     '?s <http://specs.purpleslate.data/qwerty#abc> ?abc .' +
     '} order by rand() limit 1').then((result ) => {

This is an issue that I myself have had, and I would like to change it; I’m just not sure what the best way is. query.execute takes 4 parameters, (conn, db, options, params). Your limit and offset need to go in params, not options. So your call should actually look like this:

query.execute(conn, 'database', 'select ?abc...", {}, {limit: 1, offset: 0}).then(...)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.