You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Paolo Castagna <ca...@googlemail.com> on 2012/01/24 17:12:01 UTC

NullPointerException calling setNsPrefix on a Model when using TDB

Hi,
maybe I am doing something stupid (or maybe not).

I get a NullPointerException simply doing:

Location location = new Location ("/tmp/tdb");
Model model = TDBFactory.createDataset(location).getDefaultModel();
model.setNsPrefix("foaf", "http://xmlns.com/foaf/0.1/");

Full stack trace:

Exception in thread "main" java.lang.NullPointerException
	at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.readPrefixMap(DatasetPrefixesTDB.java:175)
	at com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.getNsPrefixMap(GraphPrefixesProjection.java:62)
	at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:224)
	at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:215)
	at com.hp.hpl.jena.tdb.store.GraphTriplesTDB.createPrefixMapping(GraphTriplesTDB.java:99)
	at com.hp.hpl.jena.sparql.graph.GraphBase2.getPrefixMapping(GraphBase2.java:194)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.getPrefixMapping(ModelCom.java:908)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.withDefaultMappings(ModelCom.java:952)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:66)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:62)
	at com.hp.hpl.jena.rdf.model.ModelFactory.createModelForGraph(ModelFactory.java:166)
	at com.hp.hpl.jena.sparql.core.DatasetImpl.graph2model(DatasetImpl.java:262)
	at com.hp.hpl.jena.sparql.core.DatasetImpl.getDefaultModel(DatasetImpl.java:103)
	at dev.TDBError.main(TDBError.java:11)

In the classpath I have the following dependencies:

[INFO] |  +- org.apache.jena:jena-tdb:jar:0.9.0-incubating-SNAPSHOT:compile
[INFO] |  |  \- com.ibm.icu:icu4j:jar:3.4.4:compile
[INFO] |  +- org.apache.jena:jena-arq:jar:2.9.0-incubating:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
[INFO] |  |  \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
[INFO] |  +- org.apache.jena:jena-core:jar:2.7.0-incubating:compile
[INFO] |  |  \- org.apache.jena:jena-iri:jar:0.9.0-incubating:compile


I tried to use:

 - org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT
 - org.apache.jena:jena-arq:jar:2.9.0-incubating-SNAPSHOT

but I see the same exception.

Thanks,
Paolo

Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Paolo Castagna <ca...@googlemail.com>.
Paolo Castagna wrote:
> Location location = new Location ("/tmp/tdb");
> Model model = TDBFactory.createDataset(location).getDefaultModel();
> model.setNsPrefix("foaf", "http://xmlns.com/foaf/0.1/");

I also tried to avoid setting prefixes and move on with what I need to do.
But, I hit another strange problem:

Exception in thread "main" java.lang.NoSuchMethodError: org.openjena.atlas.lib.Bytes.toByteBuffer(Ljava/lang/CharSequence;Ljava/nio/ByteBuffer;)I
	at com.hp.hpl.jena.tdb.nodetable.NodecSSE.encode(NodecSSE.java:68)
	at com.hp.hpl.jena.tdb.lib.NodeLib.encodeStore(NodeLib.java:65)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.writeNodeToTable(NodeTableNative.java:165)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.accessIndex(NodeTableNative.java:142)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative._idForNode(NodeTableNative.java:114)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.getAllocateNodeId(NodeTableNative.java:80)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableCache._idForNode(NodeTableCache.java:123)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableCache.getAllocateNodeId(NodeTableCache.java:83)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper.getAllocateNodeId(NodeTableWrapper.java:43)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableInline.getAllocateNodeId(NodeTableInline.java:51)
	at com.hp.hpl.jena.tdb.nodetable.NodeTupleTableConcrete.addRow(NodeTupleTableConcrete.java:84)
	at com.hp.hpl.jena.tdb.store.TripleTable.add(TripleTable.java:60)
	at com.hp.hpl.jena.tdb.store.TripleTable.add(TripleTable.java:54)
	at com.hp.hpl.jena.tdb.store.GraphTriplesTDB._performAdd(GraphTriplesTDB.java:56)
	at com.hp.hpl.jena.tdb.store.GraphTDBBase.performAdd(GraphTDBBase.java:92)
	at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.add(SimpleBulkUpdateHandler.java:62)
	at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.addIterator(SimpleBulkUpdateHandler.java:73)
	at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.add(SimpleBulkUpdateHandler.java:84)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:202)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:198)

What I am doing is just adding a model to another one (backed-up by TDB):
model.add(m)

No pressure, but I'd like to understand if I am doing something wrong
or if others experience similar issues.

Thanks,
Paolo

PS:
I am going to try using the latest/stable TDB release now...





Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Paolo Castagna <ca...@googlemail.com>.
Hi Andy,
I do have Maven 3:

mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 17:31:09+0000)

But, for the Apache Snapshots|Releases repo I have https://

mvn help:effective-pom

I see:

  <repositories>
    ...
    <repository>
      <id>apache-snapshots-repo</id>
      <url>https://repository.apache.org/content/repositories/snapshots/</url>
    </repository>
    <repository>
      <id>apache-releases-repo</id>
      <url>https://repository.apache.org/content/repositories/releases/</url>
    </repository>
    ...
  </repositories>

I am double checking all the dependencies... and repositories.

Thanks,
Paolo

Andy Seaborne wrote:
> On 24/01/12 16:23, Paolo Castagna wrote:
>> Exception in thread "main" java.lang.NoSuchMethodError:
>> org.openjena.atlas.lib.Bytes.toByteBuffer(Ljava/lang/CharSequence;Ljava/nio/ByteBuffer;)I
>>
> 
> I guess you have http:// for the snapshot repo. And you use maven3.
> 
> Try https://
> 
> 
>     Andy

Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Andy Seaborne <an...@apache.org>.
On 24/01/12 16:23, Paolo Castagna wrote:
> Exception in thread "main" java.lang.NoSuchMethodError: org.openjena.atlas.lib.Bytes.toByteBuffer(Ljava/lang/CharSequence;Ljava/nio/ByteBuffer;)I

I guess you have http:// for the snapshot repo. And you use maven3.

Try https://


	Andy

Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Paolo Castagna <ca...@googlemail.com>.
Paolo Castagna wrote:
> Location location = new Location ("/tmp/tdb");
> Model model = TDBFactory.createDataset(location).getDefaultModel();
> model.setNsPrefix("foaf", "http://xmlns.com/foaf/0.1/");

I also tried to avoid setting prefixes and move on with what I need to do.
But, I hit another strange problem:

Exception in thread "main" java.lang.NoSuchMethodError: org.openjena.atlas.lib.Bytes.toByteBuffer(Ljava/lang/CharSequence;Ljava/nio/ByteBuffer;)I
	at com.hp.hpl.jena.tdb.nodetable.NodecSSE.encode(NodecSSE.java:68)
	at com.hp.hpl.jena.tdb.lib.NodeLib.encodeStore(NodeLib.java:65)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.writeNodeToTable(NodeTableNative.java:165)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.accessIndex(NodeTableNative.java:142)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative._idForNode(NodeTableNative.java:114)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.getAllocateNodeId(NodeTableNative.java:80)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableCache._idForNode(NodeTableCache.java:123)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableCache.getAllocateNodeId(NodeTableCache.java:83)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper.getAllocateNodeId(NodeTableWrapper.java:43)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableInline.getAllocateNodeId(NodeTableInline.java:51)
	at com.hp.hpl.jena.tdb.nodetable.NodeTupleTableConcrete.addRow(NodeTupleTableConcrete.java:84)
	at com.hp.hpl.jena.tdb.store.TripleTable.add(TripleTable.java:60)
	at com.hp.hpl.jena.tdb.store.TripleTable.add(TripleTable.java:54)
	at com.hp.hpl.jena.tdb.store.GraphTriplesTDB._performAdd(GraphTriplesTDB.java:56)
	at com.hp.hpl.jena.tdb.store.GraphTDBBase.performAdd(GraphTDBBase.java:92)
	at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.add(SimpleBulkUpdateHandler.java:62)
	at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.addIterator(SimpleBulkUpdateHandler.java:73)
	at com.hp.hpl.jena.graph.impl.SimpleBulkUpdateHandler.add(SimpleBulkUpdateHandler.java:84)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:202)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:198)

What I am doing is just adding a model to another one (backed-up by TDB):
model.add(m)

No pressure, but I'd like to understand if I am doing something wrong
or if others experience similar issues.

Thanks,
Paolo

PS:
I am going to try using the latest/stable TDB release now...





Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Andy Seaborne <an...@apache.org>.
On 24/01/12 17:40, Paolo Castagna wrote:
> Andy Seaborne wrote:
>> On 24/01/12 16:12, Paolo Castagna wrote:
>>>    - org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT
>>>    - org.apache.jena:jena-arq:jar:2.9.0-incubating-SNAPSHOT
>>
>> 2.9.1-incubating-SNAPSHOT
>
> Ack. Tried this as well.
>
> I was using 2.9.0-incubating-SNAPSHOT because that is what
> current TDB-0.9.0-incubating-SNAPSHOT is using.

Not that I see -

TDB pom.xml ==>

     <ver.arq>2.9.0-incubating</ver.arq>

TDB is going to release ... it depends on ARQ released.

But ...

 > [INFO] |  +- 
org.apache.jena:jena-arq:jar:2.9.1-incubating-SNAPSHOT:compile


2.9.1-incubating-SNAPSHOT

which is wrong.  Have you specified a later version?

Ditto:
org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT:compile

TDB:

[INFO] org.apache.jena:jena-tdb:jar:0.9.0-incubating-SNAPSHOT
[INFO] +- org.apache.jena:jena-arq:jar:2.9.0-incubating:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.5:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
[INFO] |  \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
[INFO] +- org.apache.jena:jena-arq:jar:tests:2.9.0-incubating:test
[INFO] +- org.apache.jena:jena-core:jar:2.7.0-incubating:compile
[INFO] |  \- org.apache.jena:jena-iri:jar:0.9.0-incubating:compile
[INFO] +- org.apache.jena:jena-core:jar:tests:2.7.0-incubating:test
[INFO] +- com.ibm.icu:icu4j:jar:3.4.4:compile
[INFO] +- xerces:xercesImpl:jar:2.10.0:compile
[INFO] |  \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- junit:junit:jar:4.9:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.4:compile
[INFO] \- log4j:log4j:jar:1.2.16:compile

	Andy

>
> Thanks for your help.
>
> Paolo
>
>>
>>      Andy


Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Paolo Castagna <ca...@googlemail.com>.
Andy Seaborne wrote:
> On 24/01/12 16:12, Paolo Castagna wrote:
>>   - org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT
>>   - org.apache.jena:jena-arq:jar:2.9.0-incubating-SNAPSHOT
> 
> 2.9.1-incubating-SNAPSHOT

Ack. Tried this as well.

I was using 2.9.0-incubating-SNAPSHOT because that is what
current TDB-0.9.0-incubating-SNAPSHOT is using.

Thanks for your help.

Paolo

> 
>     Andy

Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Andy Seaborne <an...@apache.org>.
On 24/01/12 16:12, Paolo Castagna wrote:
>   - org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT
>   - org.apache.jena:jena-arq:jar:2.9.0-incubating-SNAPSHOT

2.9.1-incubating-SNAPSHOT

	Andy

Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Paolo Castagna <ca...@googlemail.com>.
Hi Andy
thank you for your reply.

Andy Seaborne wrote:
> On 24/01/12 16:12, Paolo Castagna wrote:
>> Hi,
>> maybe I am doing something stupid (or maybe not).
>>
>> I get a NullPointerException simply doing:
>>
>> Location location = new Location ("/tmp/tdb");
>> Model model = TDBFactory.createDataset(location).getDefaultModel();
>> model.setNsPrefix("foaf", "http://xmlns.com/foaf/0.1/");
> 
> I have run this on a clean DB and it works for me.
> 
> TDB, latest snapshot build.
> ARQ 2.9.0-incubating
> Jena Core 2.7.0-incubating

I believe you! :-)

But, I am really running out of ideas here...

I cleaned my local Maven repository and verified the Apache Jena artifacts come from Apache Snapshot Maven repository:

rm -rf /home/castagna/.m2/repository/org/apache/jena/
mvn dependency:tree | grep Downloaded

Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-tdb/0.9.0-incubating-SNAPSHOT/maven-metadata.xml (372 B at 0.2 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-tdb/0.9.0-incubating-SNAPSHOT/jena-tdb-0.9.0-incubating-20120124.160659-109.pom (8 KB at 11.3 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/releases/org/apache/jena/jena-top/0-incubating/jena-top-0-incubating.pom (11 KB at 8.4 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-arq/2.9.1-incubating-SNAPSHOT/maven-metadata.xml (2 KB at 3.7 KB/sec)
Downloaded: http://repository.apache.org/snapshots/org/apache/jena/jena-arq/2.9.1-incubating-SNAPSHOT/maven-metadata.xml (2 KB at 0.4 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-arq/2.9.1-incubating-SNAPSHOT/jena-arq-2.9.1-incubating-20120124.123311-27.pom (9 KB at 12.7 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-core/2.7.1-incubating-SNAPSHOT/maven-metadata.xml (2 KB at 2.8 KB/sec)
Downloaded: http://repository.apache.org/snapshots/org/apache/jena/jena-core/2.7.1-incubating-SNAPSHOT/maven-metadata.xml (2 KB at 3.7 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-core/2.7.1-incubating-SNAPSHOT/jena-core-2.7.1-incubating-20120113.004508-10.pom (9 KB at 5.3 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-iri/0.9.1-incubating-SNAPSHOT/maven-metadata.xml (2 KB at 2.7 KB/sec)
Downloaded: http://repository.apache.org/snapshots/org/apache/jena/jena-iri/0.9.1-incubating-SNAPSHOT/maven-metadata.xml (2 KB at 0.2 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-iri/0.9.1-incubating-SNAPSHOT/jena-iri-0.9.1-incubating-20120119.211453-8.pom (5 KB at 3.8 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-iri/0.9.1-incubating-SNAPSHOT/jena-iri-0.9.1-incubating-20120119.211453-8.jar (152 KB at 22.3 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-tdb/0.9.0-incubating-SNAPSHOT/jena-tdb-0.9.0-incubating-20120124.160659-109.jar (570 KB at 83.8 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-arq/2.9.1-incubating-SNAPSHOT/jena-arq-2.9.1-incubating-20120124.123311-27.jar (2223 KB at 138.1 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/jena/jena-core/2.7.1-incubating-SNAPSHOT/jena-core-2.7.1-incubating-20120113.004508-10.jar (1687 KB at 104.7 KB/sec)


Double checked the dependencies:

mvn dependency:tree

[INFO] |  +- org.apache.jena:jena-tdb:jar:0.9.0-incubating-SNAPSHOT:compile
[INFO] |  |  \- com.ibm.icu:icu4j:jar:3.4.4:compile
[INFO] |  +- org.apache.jena:jena-arq:jar:2.9.1-incubating-SNAPSHOT:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
[INFO] |  |  \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
[INFO] |  +- org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT:compile
[INFO] |  |  \- org.apache.jena:jena-iri:jar:0.9.1-incubating-SNAPSHOT:compile


Eclipse files (and restart Eclipse, clean-up and rebuild the project... just to be sure):

mvn eclipse:eclipse

cat .classpath | grep jena
  <classpathentry kind="var" path="M2_REPO/org/apache/jena/jena-arq/2.9.1-incubating-SNAPSHOT/jena-arq-2.9.1-incubating-SNAPSHOT.jar"
sourcepath="M2_REPO/org/apache/jena/jena-arq/2.9.1-incubating-SNAPSHOT/jena-arq-2.9.1-incubating-SNAPSHOT-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/apache/jena/jena-core/2.7.1-incubating-SNAPSHOT/jena-core-2.7.1-incubating-SNAPSHOT.jar"
sourcepath="M2_REPO/org/apache/jena/jena-core/2.7.1-incubating-SNAPSHOT/jena-core-2.7.1-incubating-SNAPSHOT-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/apache/jena/jena-iri/0.9.1-incubating-SNAPSHOT/jena-iri-0.9.1-incubating-SNAPSHOT.jar"
sourcepath="M2_REPO/org/apache/jena/jena-iri/0.9.1-incubating-SNAPSHOT/jena-iri-0.9.1-incubating-SNAPSHOT-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/apache/jena/jena-tdb/0.9.0-incubating-SNAPSHOT/jena-tdb-0.9.0-incubating-SNAPSHOT.jar"
sourcepath="M2_REPO/org/apache/jena/jena-tdb/0.9.0-incubating-SNAPSHOT/jena-tdb-0.9.0-incubating-SNAPSHOT-sources.jar"/>


I see the dependencies in Eclipse as well.

My JVM is:

java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)


TDB Database is clean, I run from Eclipse:

	Location location = new Location ("target/tdb");
	Model model = TDBFactory.createDataset(location).getDefaultModel();
	model.setNsPrefix("foaf", "http://xmlns.com/foaf/0.1/");


Or, this from the command line (just to remove Eclipse from the list of possible stupid things I am doing):

mvn exec:java -Dexec.mainClass="dev.TDBError"


Exception I see in both situation is this:

Exception in thread "main" java.lang.NoSuchMethodError: org.openjena.atlas.lib.Bytes.toByteBuffer(Ljava/lang/CharSequence;Ljava/nio/ByteBuffer;)I
	at com.hp.hpl.jena.tdb.nodetable.NodecSSE.encode(NodecSSE.java:68)
	at com.hp.hpl.jena.tdb.lib.NodeLib.encodeStore(NodeLib.java:65)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.writeNodeToTable(NodeTableNative.java:165)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.accessIndex(NodeTableNative.java:142)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative._idForNode(NodeTableNative.java:114)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.getAllocateNodeId(NodeTableNative.java:80)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper.getAllocateNodeId(NodeTableWrapper.java:43)
	at com.hp.hpl.jena.tdb.nodetable.NodeTableInline.getAllocateNodeId(NodeTableInline.java:51)
	at com.hp.hpl.jena.tdb.nodetable.NodeTupleTableConcrete.addRow(NodeTupleTableConcrete.java:84)
	at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.insertPrefix(DatasetPrefixesTDB.java:123)
	at com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.set(GraphPrefixesProjection.java:84)
	at com.hp.hpl.jena.shared.impl.PrefixMappingImpl.setNsPrefix(PrefixMappingImpl.java:72)
	at com.hp.hpl.jena.rdf.model.impl.ModelCom.setNsPrefix(ModelCom.java:924)
	at dev.TDBError.main(TDBError.java:12)


In Eclipse, I can click on (NodecSSE.java:68) and it opens the source code at line 68.
I see:         int x = Bytes.toByteBuffer(str, bb) ;
... and I can F3 on the toByteBuffer method and I see the Bytes.class|java sources!


I'll sleep over it... maybe tomorrow is a better day.
Never had such problems.

Thanks,
Paolo




> 
> Prefixes don't work very well in TDB ... but ther shouldn't be any crashes.
> 
> It might be a symptom of fixed issues from before Xmas.  They affect the
> database.
> 
>     Andy
> 
>>
>> Full stack trace:
>>
>> Exception in thread "main" java.lang.NullPointerException
>>     at
>> com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.readPrefixMap(DatasetPrefixesTDB.java:175)
>>
>>     at
>> com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.getNsPrefixMap(GraphPrefixesProjection.java:62)
>>
>>     at
>> com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:224)
>>
>>     at
>> com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:215)
>>
>>     at
>> com.hp.hpl.jena.tdb.store.GraphTriplesTDB.createPrefixMapping(GraphTriplesTDB.java:99)
>>
>>     at
>> com.hp.hpl.jena.sparql.graph.GraphBase2.getPrefixMapping(GraphBase2.java:194)
>>
>>     at
>> com.hp.hpl.jena.rdf.model.impl.ModelCom.getPrefixMapping(ModelCom.java:908)
>>
>>     at
>> com.hp.hpl.jena.rdf.model.impl.ModelCom.withDefaultMappings(ModelCom.java:952)
>>
>>     at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:66)
>>     at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:62)
>>     at
>> com.hp.hpl.jena.rdf.model.ModelFactory.createModelForGraph(ModelFactory.java:166)
>>
>>     at
>> com.hp.hpl.jena.sparql.core.DatasetImpl.graph2model(DatasetImpl.java:262)
>>     at
>> com.hp.hpl.jena.sparql.core.DatasetImpl.getDefaultModel(DatasetImpl.java:103)
>>
>>     at dev.TDBError.main(TDBError.java:11)
>>
>> In the classpath I have the following dependencies:
>>
>> [INFO] |  +-
>> org.apache.jena:jena-tdb:jar:0.9.0-incubating-SNAPSHOT:compile
>> [INFO] |  |  \- com.ibm.icu:icu4j:jar:3.4.4:compile
>> [INFO] |  +- org.apache.jena:jena-arq:jar:2.9.0-incubating:compile
>> [INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
>> [INFO] |  |  \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
>> [INFO] |  +- org.apache.jena:jena-core:jar:2.7.0-incubating:compile
>> [INFO] |  |  \- org.apache.jena:jena-iri:jar:0.9.0-incubating:compile
>>
>>
>> I tried to use:
>>
>>   - org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT
>>   - org.apache.jena:jena-arq:jar:2.9.0-incubating-SNAPSHOT
>>
>> but I see the same exception.
>>
>> Thanks,
>> Paolo
> 

Re: NullPointerException calling setNsPrefix on a Model when using TDB

Posted by Andy Seaborne <an...@apache.org>.
On 24/01/12 16:12, Paolo Castagna wrote:
> Hi,
> maybe I am doing something stupid (or maybe not).
>
> I get a NullPointerException simply doing:
>
> Location location = new Location ("/tmp/tdb");
> Model model = TDBFactory.createDataset(location).getDefaultModel();
> model.setNsPrefix("foaf", "http://xmlns.com/foaf/0.1/");

I have run this on a clean DB and it works for me.

TDB, latest snapshot build.
ARQ 2.9.0-incubating
Jena Core 2.7.0-incubating

Prefixes don't work very well in TDB ... but ther shouldn't be any crashes.

It might be a symptom of fixed issues from before Xmas.  They affect the 
database.

	Andy

>
> Full stack trace:
>
> Exception in thread "main" java.lang.NullPointerException
> 	at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.readPrefixMap(DatasetPrefixesTDB.java:175)
> 	at com.hp.hpl.jena.sparql.graph.GraphPrefixesProjection.getNsPrefixMap(GraphPrefixesProjection.java:62)
> 	at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:224)
> 	at com.hp.hpl.jena.tdb.store.DatasetPrefixesTDB.getPrefixMapping(DatasetPrefixesTDB.java:215)
> 	at com.hp.hpl.jena.tdb.store.GraphTriplesTDB.createPrefixMapping(GraphTriplesTDB.java:99)
> 	at com.hp.hpl.jena.sparql.graph.GraphBase2.getPrefixMapping(GraphBase2.java:194)
> 	at com.hp.hpl.jena.rdf.model.impl.ModelCom.getPrefixMapping(ModelCom.java:908)
> 	at com.hp.hpl.jena.rdf.model.impl.ModelCom.withDefaultMappings(ModelCom.java:952)
> 	at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:66)
> 	at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:62)
> 	at com.hp.hpl.jena.rdf.model.ModelFactory.createModelForGraph(ModelFactory.java:166)
> 	at com.hp.hpl.jena.sparql.core.DatasetImpl.graph2model(DatasetImpl.java:262)
> 	at com.hp.hpl.jena.sparql.core.DatasetImpl.getDefaultModel(DatasetImpl.java:103)
> 	at dev.TDBError.main(TDBError.java:11)
>
> In the classpath I have the following dependencies:
>
> [INFO] |  +- org.apache.jena:jena-tdb:jar:0.9.0-incubating-SNAPSHOT:compile
> [INFO] |  |  \- com.ibm.icu:icu4j:jar:3.4.4:compile
> [INFO] |  +- org.apache.jena:jena-arq:jar:2.9.0-incubating:compile
> [INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
> [INFO] |  |  \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
> [INFO] |  +- org.apache.jena:jena-core:jar:2.7.0-incubating:compile
> [INFO] |  |  \- org.apache.jena:jena-iri:jar:0.9.0-incubating:compile
>
>
> I tried to use:
>
>   - org.apache.jena:jena-core:jar:2.7.1-incubating-SNAPSHOT
>   - org.apache.jena:jena-arq:jar:2.9.0-incubating-SNAPSHOT
>
> but I see the same exception.
>
> Thanks,
> Paolo