Вопрос

I'm have download a jena-2.6.4 zip to manage a triple store. In this zip there was lib directory with libraries, and jena-tdb-0.9.4.jar was amount them.

However while trying the simplest following code

import com.hp.hpl.jena.tdb.*;
...
String tdbFile  = "/tmp/tdb";
Dataset dataset = TDBFactory.createDataset(tdbFile);

I have an error saying that TDBFactory is not found. even Explicit importation import com.hp.hpl.jena.tdb.TDBFactory doesn't work. The Class is not define.

Any idea about this ?

Edition

Here is the Error message return

Exception in thread "main" java.lang.NoClassDefFoundError:     com/hp/hpl/jena/sparql/engine/main/StageGenBasicPattern
at com.hp.hpl.jena.tdb.TDB.wireIntoExecution(TDB.java:173)
at com.hp.hpl.jena.tdb.TDB.initWorker(TDB.java:157)
at com.hp.hpl.jena.tdb.TDB.<clinit>(TDB.java:137)
at com.hp.hpl.jena.tdb.TDBFactory.<clinit>(TDBFactory.java:85)
at test.JenaRepositoryManagement.initializeTheTDBRepository(JenaRepositoryManagement.java:88)
at test.views.Main.main(Main.java:102)

Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.sparql.engine.main.StageGenBasicPattern
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 6 more
Это было полезно?

Решение

Your stacktrce doesn't say that it can't find TDBFactory. It says that it can't find

com.hp.hpl.jena.sparql.engine.main.StageGenBasicPattern.

It sounds like you need some more jars on your classpath. After you download the apache-jena bundle from Apache Jena Releases, put all the jars in the lib subdirectory on your classpath, not just the tdb jar.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top