52780

How do you create a Fuseki SPARQL server using the Apache Jena Java API?

I am trying to create a Fuseki SPARQL server on my machine. The documentation on the Jena website describes how to create such a server from the command-line, here: http://jena.apache.org/documentation/serving_data/. I am looking for a way of creating and initializing such a server just using the Jena Java API. I have looked over the Jena API but have not made any progress in working out how to proceed. Has anyone done this before?

Answer1:

Yes this is possible but it is not how Fuseki was designed to operate so do so at your own risk.

You will need to pull in Fuseki as a dependency, via maven this would be the following:

<dependency>
  <groupId>org.apache.jena</groupId>
  <artifactId>jena-fuseki</artifactId>
  <version>0.2.7</version>
</dependency>


Then you can use the SPARQLServer class to create a server and call start() to actually run the server and stop() when you are done. (This is located in the org.apache.jena.fuseki.server package)

It is <strong>important to note</strong> that if you do this the server is embedded in the JVM from which you start it, when that JVM shuts down the server shuts down. This may be your intention but it may not.

Btw you question is unclear as to exactly why you want to do this? There may be alternative ways to achieve your goal without embedding Fuseki if you explain your goals further

Answer2:

If you use

<dependency> <groupId>org.apache.jena</groupId> <artifactId>apache-jena-libs</artifactId> <type>pom</type> <version>2.11.2-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.jena</groupId> <artifactId>jena-fuseki</artifactId> <version>1.0.2-SNAPSHOT</version> </dependency>

You can start an embedded Server.

Dataset dataset = TDBFactory.createDataset(MagicStrings.TDBLocation); dataset.begin(ReadWrite.WRITE); Model tdb = dataset.getDefaultModel(); EmbeddedFusekiServer server = EmbeddedFusekiServer. create(3030,getDataset().asDatasetGraph(), "comp");

Recommend

  • Rearrange an array to be optimal in comparison to another array
  • Should concrete implementation provide any public API not present in the interface it implements?
  • lein uberjar doesn't pack the jar file under resource into the final jar
  • Composer error [UnexpectedValueException]
  • How to enumerate Azure subscriptions and tenants programmatically?
  • JENKINS: ERROR when I try to use an older JDK for a specific maven project
  • Java Date object constructor for getting string is deprecated
  • GWT Toolkit: preprocessing files on client side
  • IllegalArgumentException caught when parsing URL with JSON String
  • Regarding client side code generation from WSDL
  • How can I include the Ivy dependency and none of its dependencies?
  • Convert symmetric matrix between packed and full storage?
  • CSS: How to fix overlapping divs
  • How to force Composer to download a local package?
  • dismiss Progress Dialog in another Activity … Android
  • CSS Grid, position absolute an element in a css grid item: IMPOSSIBLE
  • How many Vertica Databases can run on a Host in the same time?
  • maven jboss-as:start A required class was missing … org/sonaty…/ArtifactResolutionException
  • How to synchronize two scrollview in Android?
  • C Program Compiled with Cygwin and Called from Python Hangs
  • What is the use of a session store?
  • Is it possible to define rest argument in OCaml?
  • joining two bezier curves
  • jQuery: add elements until a particular height is reached
  • Enabling DTD support in Sql Server
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Control modification in presentation layer
  • jQuery show() function is not executed in Safari if submit handler returns true
  • Spray.io: When (not) to use non-blocking route handling?
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • How do I rollback to a specific git commit
  • Matrix multiplication with MKL
  • File upload with ng-file-upload throwing error
  • Hits per day in Google Big Query
  • File not found error Google Drive API
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Converting MP3 duration time
  • java string with new operator and a literal