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
>