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 <a...@apache.org> Skickat: den 30 mars 2020 19:38 Till: users@jena.apache.org <users@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 <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. >