Hi,

Found that the problem was due to to trying to add a submodel and
OWL:imports statement during the same transaction. I had to finish and
commit the transaction where I add the submodel first, then start another
transaction that would read the Class Restrictions.

Sometimes I just need to explain the problem in order to better solve it,
sorry about that. :x

Devlin


On Wed, Aug 13, 2014 at 9:22 AM, Devlin Junker <[email protected]>
wrote:

> And here is the stack trace. Sorry about sending multiple emails.
>
> java.util.ConcurrentModificationException: Iterator: started at 6, now 7
>  at
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.policyError(DatasetControlMRSW.java:157)
>  at
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.access$000(DatasetControlMRSW.java:32)
> at
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.checkCourrentModification(DatasetControlMRSW.java:110)
>  at
> com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.hasNext(DatasetControlMRSW.java:118)
> at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
>  at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:318)
> at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:916)
>  at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>  at
> com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
> at
> com.hp.hpl.jena.graph.compose.CompositionBase$2.hasNext(CompositionBase.java:94)
>  at
> com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
> at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>  at
> com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
> at
> com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
>  at
> com.hp.hpl.jena.reasoner.rulesys.impl.TopLevelTripleMatchFrame.nextMatch(TopLevelTripleMatchFrame.java:55)
> at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPInterpreter.run(LPInterpreter.java:327)
>  at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPInterpreter.next(LPInterpreter.java:189)
> at com.hp.hpl.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:253)
>  at
> com.hp.hpl.jena.reasoner.rulesys.impl.Generator.pump(Generator.java:240)
> at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPBRuleEngine.pump(LPBRuleEngine.java:311)
>  at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPTopGoalIterator.moveForward(LPTopGoalIterator.java:107)
> at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPTopGoalIterator.hasNext(LPTopGoalIterator.java:222)
>  at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>  at
> com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
> at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>  at
> com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
> at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>  at
> com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
> at
> com.hp.hpl.jena.graph.compose.CompositionBase$2.hasNext(CompositionBase.java:94)
>  at
> com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
> at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>  at
> com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
> at
> com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
>  at
> com.hp.hpl.jena.reasoner.rulesys.impl.TopLevelTripleMatchFrame.nextMatch(TopLevelTripleMatchFrame.java:55)
> at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPInterpreter.run(LPInterpreter.java:327)
>  at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPInterpreter.next(LPInterpreter.java:189)
> at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPTopGoalIterator.moveForward(LPTopGoalIterator.java:98)
>  at
> com.hp.hpl.jena.reasoner.rulesys.impl.LPTopGoalIterator.hasNext(LPTopGoalIterator.java:222)
> at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
>  at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at
> com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
>  at
> com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at
> com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
>  at
> com.hp.hpl.jena.graph.impl.GraphBase.containsByFind(GraphBase.java:331)
> at
> com.hp.hpl.jena.graph.impl.GraphBase.graphBaseContains(GraphBase.java:309)
>  at com.hp.hpl.jena.graph.impl.GraphBase.contains(GraphBase.java:301)
> at com.hp.hpl.jena.graph.impl.GraphBase.contains(GraphBase.java:318)
>  at com.hp.hpl.jena.rdf.model.impl.ModelCom.contains(ModelCom.java:1222)
> at
> com.hp.hpl.jena.rdf.model.impl.ResourceImpl.hasProperty(ResourceImpl.java:340)
>  at
> com.hp.hpl.jena.ontology.impl.OntClassImpl.isRestriction(OntClassImpl.java:868)
> at
> com.eduworks.ontology.OntologyClass.getJSONRepresentation(OntologyClass.java:457)
>  at
> com.eduworks.ontology.OntologyInstance.createInstance(OntologyInstance.java:64)
> at com.eduworks.ontology.Ontology.createInstance(Ontology.java:396)
>  at
> com.eduworks.ontology.test.TestOntology.test_LoadExternalStructure(TestOntology.java:334)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke(Method.java:601)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>  at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>  at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
>  at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
>  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>  at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>  at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>
>
>
> On Wed, Aug 13, 2014 at 9:21 AM, Devlin Junker <[email protected]
> > wrote:
>
>> I forgot to mention that this is happening during a Write Transaction on
>> the Dataset, in case that is important.
>>
>> Devlin
>>
>>
>> On Wed, Aug 13, 2014 at 9:19 AM, Devlin Junker <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> I am having a little bit of trouble implementing the TDB store for my
>>> Jena Ontologies. I have been able to solve most of the issues that I've
>>> come across, but I have become frustrated with the view request functions
>>> that the Ontology objects define.
>>>
>>> I am trying to get a list of all of the restrictions that define a
>>> certain OntClass, but while I am looping through all of the superclasses
>>> for the class I receive a ConcurrentModificationException when calling the
>>> is[Restriction, DatatypeProperty, and SomeValuesFromRestriction] calls.
>>>
>>> Apparently it is happening when finding the triple on the graph that
>>> would define it as the certain view type. The exception is thrown on the
>>> iterator.hasNext in GraphBase.containsByFind().
>>>
>>> The application I am running is only single threaded (I think, it is in
>>> a JUnit Test Case) so I don't think any other modifications should actually
>>> be happening to the Dataset while I am checking against the View Type.
>>>
>>> I've included the important code below and highlighted the area where
>>> the exception is thrown.
>>>
>>> Thanks for any help you can offer,
>>> Devlin
>>>
>>> List<OntClass> supers = jenaClass.listSuperClasses().toList();
>>>
>>> for(int index = 0; index < supers.size(); index++){
>>> OntClass cls = supers.get(index);
>>>  if(cls.isRestriction()){
>>> Restriction r = cls.asRestriction();
>>>  String valueId = "";
>>>  OntProperty prop = r.getOnProperty();
>>>  Resource restrictionValue;
>>>
>>> if(r.isAllValuesFromRestriction()){
>>>  restrictionValue = r.asAllValuesFromRestriction().getAllValuesFrom();
>>> }else if(r.isSomeValuesFromRestriction()){
>>>  restrictionValue = r.asSomeValuesFromRestriction().getSomeValuesFrom();
>>> }else{
>>> // TODO: Implement Cardinality Restrictions
>>>  throw new RuntimeException("Unexpected Restriction Type");
>>> }
>>>   if(prop.isDatatypeProperty()){
>>> // TODO: More DataTypes
>>>  if(restrictionValue.equals(XSD.xint) ||
>>> restrictionValue.equals(XSD.integer)){
>>> valueId = "xsd:integer";
>>>  }else if(restrictionValue.equals(XSD.xstring)){
>>> valueId = "xsd:string";
>>> }else if(restrictionValue.equals(XSD.xdouble)){
>>>  valueId = "xsd:double";
>>> }else if(restrictionValue.equals(XSD.dateTime)){
>>> valueId = "xsd:dateTime";
>>>  }else{
>>> throw new RuntimeException("Unrecognized DataType:
>>> "+restrictionValue.toString());
>>>  }
>>> }else{
>>> valueId = getIdentifier(restrictionValue.getURI());
>>>  }
>>>  try{
>>> if(r.isAllValuesFromRestriction()){
>>>  JSONArray restriction =
>>> rest.optJSONArray(getIdentifier(prop.getURI()));
>>> if(restriction == null || !restriction.toString().contains(valueId)){
>>>  rest.append(getIdentifier(prop.getURI()), valueId);
>>> }
>>> }else if(r.isSomeValuesFromRestriction()){
>>>  JSONArray requirement = req.optJSONArray(getIdentifier(prop.getURI()));
>>> // TODO: HACK (For some reason during update I am getting duplicate of
>>> the some value restrictions)
>>>  if(requirement == null || !requirement.toString().contains(valueId)){
>>> req.append(getIdentifier(prop.getURI()), valueId);
>>>  }
>>> }else{
>>> // TODO: Implement Cardinality Restrictions
>>>  throw new RuntimeException("Unexpected Restriction Type");
>>> }
>>> }catch(JSONException e){
>>>  throw new RuntimeException("Error Creating JSON Object for Property "
>>> + prop);
>>> }
>>> }
>>> }
>>>
>>
>>
>

Reply via email to