You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Glenn Eriksson <an...@hotmail.com> on 2020/03/30 12:49:39 UTC

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();
        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.

Sv: Sv: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)

Posted by Glenn TheMan <an...@hotmail.com>.
>> I'm afraid the computer does not agree with you :-)

True, always trust the machine. Maybe some trolls was borrowing that port on my machine  :)

About the access the Fuseki homepage at http://localhost:3330/  and the Error 404: null response. According to the documentation the UI is not included<https://jena.apache.org/documentation/fuseki2/fuseki-main.html> in the embedded  SPARQL Fuseki jar, hence the error code 404.

>> The config file has to be loaded: .parseConfigFile("....");

Question -> Where can I find the parse function. Is there a util class for FusekiServer?

//Cheers


________________________________
Från: Andy Seaborne <an...@apache.org>
Skickat: den 31 mars 2020 12:17
Till: users@jena.apache.org <us...@jena.apache.org>
Ämne: Re: Sv: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)



On 31/03/2020 09:24, Glenn TheMan wrote:
> Hi Andy
>
> The Jetty included in Spring Boot runs on 8080 by default, so there shouldn't be ant conflict.

I'm afraid the computer does not agree with you :-)

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

It may be a complete different process on the same machine (same port
space if containers).

> You can configure this with the property in application.properties for Spring:  server.port=8081
> I've fix the conflict so the both the RESTful and html/javascript are served on this port now.
>
> When trying to access the Fuseki endpoint: http://localhost:3330/ds/<http://localhost:3330/ds/query>
> I get a HTTP error code 404 and a something that look like a Turtle result wrapped in curly brackets. Is that what is called a named graph

Weird : 404 is not found and if Fuseki returns it, it means the dataset
or graph isn't found at all which means no response body.

If you GET a dataset then you get back the dataset quads, here in TriG,
with a 200.

>
> <http://clearbyte.org/> {
>      <http://clearbyte.org/paintingTechnique>
>              a       <http://www.w3.org/2000/01/rdf-schema#Property> .
>      <http://clearbyte.org/guernica>
>              a       <http://clearbyte.org/Painting> ;
>              <http://www.w3.org/2000/01/rdf-schema#label>
>                      "Guernica" ;
>              <http://clearbyte.org/paintingTechnique>
>                      <http://clearbyte.org/oil> .
>
> I've added a config.ttl and shiro.ini file which is now included in the spring JAR file in the root directory main/resources/.
>
> Question:
>
>    1.  Does the creation of Fuseki server = FusekiServer.create().add("/ds", dataset).build(); override the configuration file fuseki:name "ds". Which one take precedent?

The config file has to be loaded: .parseConfigFile("....");

>    2.  Is the curly brackets response (using /ds/get or /ds/data) what is called a named graph?

Yes.

>    3.  I guess I now have two instances of Jetty running on different ports, which is fine for the moment. Referring to your replay, since the Fuseki-main implementation is a Servlet filter it would be possible to inject it into a Spring MVC servlet since Spring boot uses the DispatcherServlet pattern?

Probably (= "yes, I don't see why not but I haven't tried").
Getting to it isn't easy - you'll have to look a the code of
FusekiServer.Builder.

How it will interact with DispatcherServlet, I don't know.

     Andy

>
> Greetings.
>
> ________________________________
> Från: Andy Seaborne <an...@apache.org>
> Skickat: den 30 mars 2020 19:38
> Till: users@jena.apache.org <us...@jena.apache.org>
> Ämne: Re: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)
>
> 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 <an...@hotmail.com>
>> Skickat: den 30 mars 2020 14:49
>> Till: users@jena.apache.org <us...@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.
>>
>

Re: Sv: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)

Posted by Andy Seaborne <an...@apache.org>.

On 31/03/2020 09:24, Glenn TheMan wrote:
> Hi Andy
> 
> The Jetty included in Spring Boot runs on 8080 by default, so there shouldn't be ant conflict.

I'm afraid the computer does not agree with you :-)

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

It may be a complete different process on the same machine (same port 
space if containers).

> You can configure this with the property in application.properties for Spring:  server.port=8081
> I've fix the conflict so the both the RESTful and html/javascript are served on this port now.
> 
> When trying to access the Fuseki endpoint: http://localhost:3330/ds/<http://localhost:3330/ds/query>
> I get a HTTP error code 404 and a something that look like a Turtle result wrapped in curly brackets. Is that what is called a named graph

Weird : 404 is not found and if Fuseki returns it, it means the dataset 
or graph isn't found at all which means no response body.

If you GET a dataset then you get back the dataset quads, here in TriG, 
with a 200.

> 
> <http://clearbyte.org/> {
>      <http://clearbyte.org/paintingTechnique>
>              a       <http://www.w3.org/2000/01/rdf-schema#Property> .
>      <http://clearbyte.org/guernica>
>              a       <http://clearbyte.org/Painting> ;
>              <http://www.w3.org/2000/01/rdf-schema#label>
>                      "Guernica" ;
>              <http://clearbyte.org/paintingTechnique>
>                      <http://clearbyte.org/oil> .
> 
> I've added a config.ttl and shiro.ini file which is now included in the spring JAR file in the root directory main/resources/.
> 
> Question:
> 
>    1.  Does the creation of Fuseki server = FusekiServer.create().add("/ds", dataset).build(); override the configuration file fuseki:name "ds". Which one take precedent?

The config file has to be loaded: .parseConfigFile("....");

>    2.  Is the curly brackets response (using /ds/get or /ds/data) what is called a named graph?

Yes.

>    3.  I guess I now have two instances of Jetty running on different ports, which is fine for the moment. Referring to your replay, since the Fuseki-main implementation is a Servlet filter it would be possible to inject it into a Spring MVC servlet since Spring boot uses the DispatcherServlet pattern?

Probably (= "yes, I don't see why not but I haven't tried").
Getting to it isn't easy - you'll have to look a the code of 
FusekiServer.Builder.

How it will interact with DispatcherServlet, I don't know.

     Andy

> 
> Greetings.
> 
> ________________________________
> Från: Andy Seaborne <an...@apache.org>
> Skickat: den 30 mars 2020 19:38
> Till: users@jena.apache.org <us...@jena.apache.org>
> Ämne: Re: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)
> 
> 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 <an...@hotmail.com>
>> Skickat: den 30 mars 2020 14:49
>> Till: users@jena.apache.org <us...@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.
>>
> 

Sv: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)

Posted by Glenn TheMan <an...@hotmail.com>.
Hi Andy

The Jetty included in Spring Boot runs on 8080 by default, so there shouldn't be ant conflict.
You can configure this with the property in application.properties for Spring:  server.port=8081
I've fix the conflict so the both the RESTful and html/javascript are served on this port now.

When trying to access the Fuseki endpoint: http://localhost:3330/ds/<http://localhost:3330/ds/query>
I get a HTTP error code 404 and a something that look like a Turtle result wrapped in curly brackets. Is that what is called a named graph

<http://clearbyte.org/> {
    <http://clearbyte.org/paintingTechnique>
            a       <http://www.w3.org/2000/01/rdf-schema#Property> .
    <http://clearbyte.org/guernica>
            a       <http://clearbyte.org/Painting> ;
            <http://www.w3.org/2000/01/rdf-schema#label>
                    "Guernica" ;
            <http://clearbyte.org/paintingTechnique>
                    <http://clearbyte.org/oil> .

I've added a config.ttl and shiro.ini file which is now included in the spring JAR file in the root directory main/resources/.

Question:

  1.  Does the creation of Fuseki server = FusekiServer.create().add("/ds", dataset).build(); override the configuration file fuseki:name "ds". Which one take precedent?
  2.  Is the curly brackets response (using /ds/get or /ds/data) what is called a named graph?
  3.  I guess I now have two instances of Jetty running on different ports, which is fine for the moment. Referring to your replay, since the Fuseki-main implementation is a Servlet filter it would be possible to inject it into a Spring MVC servlet since Spring boot uses the DispatcherServlet pattern?

Greetings.

________________________________
Från: Andy Seaborne <an...@apache.org>
Skickat: den 30 mars 2020 19:38
Till: users@jena.apache.org <us...@jena.apache.org>
Ämne: Re: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)

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 <an...@hotmail.com>
> Skickat: den 30 mars 2020 14:49
> Till: users@jena.apache.org <us...@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.
>

Re: Sv: Embed Fuseki in Spring Boot (Jetty 9.4)

Posted by Andy Seaborne <an...@apache.org>.
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 <an...@hotmail.com>
> Skickat: den 30 mars 2020 14:49
> Till: users@jena.apache.org <us...@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.
> 

Sv: Embed Fuseki in Spring Boot (Jetty 9.4)

Posted by Glenn TheMan <an...@hotmail.com>.
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 <an...@hotmail.com>
Skickat: den 30 mars 2020 14:49
Till: users@jena.apache.org <us...@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();
        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.