Hi Glenn,

The error means that something else is already using port.

Have you configured the Spring Boot Jetty server to use port 3330?

FusekiServer...build() will create a new Jetty server but maybe that's OK if nothing else is not already listening on the port.

What's hard if you want other application code along side Fuseki on the same port. Spring Boot probable wants to be in charge but you can add arbitrary servlets to Fuseki itself.

  1.  Can I configure Fuseki to run inside a Spring container which already 
uses a Jetty 9.4. Or do I need to runt to separate Jetty instances. Please 
provide code pattern?

Only in theory. the core of Fuseki is server neutral (it's a servlet Filter), it is the packaging that choose to use Jetty.

Fuseki-main is Jetty specific. It does not have a means to use an external jetty server. I don't use Spring Boot - how does an application get a the Jetty server? Maybe injecting a jetty server could be done (in a future re;lease of Fuseki).

It is also available as a WAR file which is portable across web application servers.

Can you run the war file?

  2.  Where am I suppose to place the configure file (config.ttl). The static 
web files in Spring Boot is placed under main/resources/static?

It's opened as a file so the "current directory" applies.

    Andy

On 30/03/2020 14:07, Glenn TheMan wrote:
I use jena version 3.14.0.

<dependency>
             <groupId>org.apache.jena</groupId>
             <artifactId>apache-jena-libs</artifactId>
             <type>pom</type>
             <version>3.14.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.jena</groupId>
             <artifactId>jena-fuseki-main</artifactId>
             <version>3.14.0</version>
         </dependency>
________________________________
Från: Glenn Eriksson <anykeystu...@hotmail.com>
Skickat: den 30 mars 2020 14:49
Till: users@jena.apache.org <users@jena.apache.org>
Ämne: Embed Fuseki in Spring Boot (Jetty 9.4)

Hi, in my use-case use the Spring Boot container for handling repository 
connections (Spring Data),  RESTful web services et cetera. I also want to use 
a embedded Fuseki Servers to provide a SPARQL endpoint.

When The Fuseki Servers start it throws a exception saying that the 
address/port already in use.

java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:3330
java.net.BindException: Address already in use

My Spring bean fuseki service:

@Service
public class FusekiService {
...
public void initModel() {
         model = ModelFactory.createDefaultModel();
         InputStream in1 = FileManager.get().open(ARTIST_MODEL_FILE);
         model.read(in1, BASE_URL, "TURTLE");
         LOGGER.debug("Statements read from file: {}", model.size());
     }

     @PostConstruct
     public void initService() {
         initModel();
         Dataset dataset = DatasetFactory.createTxnMem();

You could read it straight into the Dataset, making the model unnecessary.


RDFDataMgr.read(dataset.getNamedModel(BASE_URL),
                ARTIST_MODEL_FILE,
                BASE_URL,
                Lang.Turtle);

         dataset.addNamedModel(BASE_URL, model);
         server = FusekiServer.create().add("/data", 
dataset).verbose(true).build();
         server.start();
         LOGGER.debug("Fuseki service started.");
     }

Questions:

   1.  Can I configure Fuseki to run inside a Spring container which already 
uses a Jetty 9.4. Or do I need to runt to separate Jetty instances. Please 
provide code pattern?
   2.  Where am I suppose to place the configure file (config.ttl). The static 
web files in Spring Boot is placed under main/resources/static?

Best regards.

Reply via email to