# Using Maven is a mess

**URL:** <https://community.stardog.com/t/using-maven-is-a-mess/1608>\
**Category:** Support\
**Created:** [April 19, 2019, 11:37pm UTC](https://community.stardog.com/t/using-maven-is-a-mess/1608 "2019-04-19T23:37:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavideRossi](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DavideRossi](https://community.stardog.com/u/DavideRossi)\
**Post date:** [April 19, 2019, 11:37pm UTC](https://community.stardog.com/t/using-maven-is-a-mess/1608/1 "2019-04-19T23:37:38Z")

</div>

I'm trying to build a simple SNARL API example.  
I'm following the " Java Programming" and "Using Maven" sections in the docs.  
First of all, the updated examples (see for example here:

> <https://github.com/stardog-union/stardog-examples/blob/e1f308d18f7ebdc6b4659b0f0c105462e27a9eee/examples/api/main/src/com/complexible/stardog/examples/api/ConnectionAPIExample.java#L58>

differ from the docs in that they say that I have to initialize the Stardog instance first, something that is missing in the docs so I have two versions of the code: one with the instance initialization (call that E1) and one without (call that E2).  
Well, now by looking at "Using Maven" it's not clear what deps I need. This is not a server program, it's not an http-client program either, it's an embedded instance accessed via SNARL.  
OK, I tried all the permutations of the 5 "client type dependencies" in the docs and E1 inevitably fails with a  
`"No driver was found which supports the connection string: 'embed://system/'` whereas E2 fails with a `"java.lang.NoClassDefFoundError: org/quartz/SchedulerException"`.  
But hey, look, under "Using Maven" there is a pointer: " You can see an example of their usage in our examples [repository on Github](https://github.com/complexible/stardog-examples/blob/628cf3dab2/examples/api/build.gradle#L3-L14)", cool!  
Not so fast, this is still a Gradle example and is way outdated.  
So I switched to the develop version of the Gradle buildfile and I tried to reconstruct the same structure with Maven. The results looks like the following:

```auto
		<dependency>
			<groupId>com.complexible.stardog</groupId>
			<artifactId>server</artifactId>
			<version>${stardog.version}</version>
			<type>pom</type>
		</dependency>
		<dependency>
			<groupId>com.complexible.stardog</groupId>
			<artifactId>client-http</artifactId>
			<version>${stardog.version}</version>
			<type>pom</type>
		</dependency>
		<dependency>
			<groupId>com.stardog.stark.query</groupId>
			<artifactId>stardog-stark-query-api</artifactId>
			<version>${stardog.version}</version>
		</dependency>
		<dependency>
			<groupId>com.stardog.stark.io</groupId>
			<artifactId>stardog-stark-io-api</artifactId>
			<version>${stardog.version}</version>
		</dependency>
		<dependency>
			<groupId>com.stardog.stark.query.io</groupId>
			<artifactId>stardog-stark-query-io</artifactId>
			<version>${stardog.version}</version>
		</dependency>
		<dependency>
			<groupId>com.complexible.stardog</groupId>
			<artifactId>client-embedded</artifactId>
			<version>${stardog.version}</version>
		</dependency>
		<dependency>
			<groupId>com.complexible.stardog.prov</groupId>
			<artifactId>stardog-prov</artifactId>
			<version>${stardog.version}</version>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>com.complexible.stardog.skos</groupId>
			<artifactId>stardog-skos</artifactId>
			<version>${stardog.version}</version>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>com.complexible.stardog.rdf4j</groupId>
			<artifactId>stardog-rdf4j</artifactId>
			<version>${stardog.version}</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.rdf4j</groupId>
			<artifactId>rdf4j-runtime</artifactId>
			<version>2.2.4</version>
		</dependency>
		<dependency>
			<groupId>com.complexible.stardog.jena</groupId>
			<artifactId>stardog-jena</artifactId>
			<version>${stardog.version}</version>
		</dependency>
		<dependency>
			<groupId>com.complexible.stardog.gremlin</groupId>
			<artifactId>stardog-gremlin</artifactId>
			<version>${stardog.version}</version>
		</dependency>

```

ok, lots of stuff that I do not need but I can try to trim them out later... build... run... same results as above.  
OK, let's assume that `Stardog.builder().create()` is really needed and get rid of the `java.lang.NoClassDefFoundError: org/quartz/SchedulerException` by explicitly adding quartz to the deps...  
Good we are making progress, not it complains about Caffeine: `java.lang.NoClassDefFoundError: com/github/benmanes/caffeine/cache/Caffeine`.  
And if I add Caffeine to the deps I get `Error in custom provider, java.lang.RuntimeException: Could not load system index: system`.  
OK, going nowhere.  
Now the questions are:

1. is `Stardog.builder().create()` needed? If so please update the docs, if it is not please update the examples.
2. can you please provide me a minimal set of Maven deps to run a simple SNARL API program with an embedded server (and maybe update/improve the Maven docs since you are at that)?

Thanks!

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 22, 2019, 2:30pm UTC](https://community.stardog.com/t/using-maven-is-a-mess/1608/2 "2019-04-22T14:30:56Z")

</div>

Hello and welcome!

> [@DavideRossi](#):
>
> is `Stardog.builder().create()` needed? If so please update the docs, if it is not please update the examples.

The docs are indeed not _explicit_ about this, however the `Stardog.builder().create()` call is needed if you intend to start up the embedded server, as it seems you want to do. I should note that this is the new and improved way to do this as of Stardog 6, which could explain the slight disconnect. The docs section does seem to go off the assumption that you are connecting to the embedded server, so perhaps it should be more explicit about this, however if you were running a local instance of the Stardog server you would _NOT_ need this call, as you could just point the `AdminConnectionConfiguration` to that instance instead.

> [@DavideRossi](#):
>
> Well, now by looking at "Using Maven" it's not clear what deps I need. This is not a server program, it's not an http-client program either, it's an embedded instance accessed via SNARL.

Because you want to run the embedded server, you actually do need the server dependency. You're technically correct about it not being an HTTP client but rather an embedded one, and we do actually have a `client-embedded` artifact, but `client-http` brings that (as well as everything else) in along with it.

> [@DavideRossi](#):
>
> can you please provide me a minimal set of Maven deps to run a simple SNARL API program with an embedded server

I was able to get the exact `main` method from the stardog-examples repository to which you linked by bringing in just `server` and `client-http` as follows:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.stardog</groupId>
    <artifactId>java-sandbox-maven</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <stardog.version>6.1.3</stardog.version>
    </properties>

    <repositories>
        <repository>
            <id>stardog-public</id>
            <url>http://maven.stardog.com</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.complexible.stardog</groupId>
            <artifactId>server</artifactId>
            <version>${stardog.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.complexible.stardog</groupId>
            <artifactId>client-http</artifactId>
            <version>${stardog.version}</version>
            <type>pom</type>
        </dependency>
    </dependencies>

</project>

```

---

<div class="post-metadata">

**Author:** ![DavideRossi](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DavideRossi](https://community.stardog.com/u/DavideRossi)\
**Post date:** [April 22, 2019, 7:48pm UTC](https://community.stardog.com/t/using-maven-is-a-mess/1608/3 "2019-04-22T19:48:30Z")

</div>

Thanks Steph, it turned out that I had a broken quartz jar in my .m2 and since I was running the application from within Eclipse I got no error notifications.  
When I tried a `maven install` I saw the problem.  
A build system whose usual fix is "clean the local repo" is a mess indeed...  
However: now I can build the app and run in from the produced jar but I'm still having troubles with running it from Eclipse: the error I get is this:

```auto
There was an error initializing Stardog; one or more dependencies could not be satisfied. Please verify your classpath is correct.
The initialization errors were: 
 *	Error in custom provider, java.lang.RuntimeException: Could not load system index: system
		com.complexible.stardog.virtual.DefaultVirtualGraphRegistry
		com.complexible.stardog.virtual.VirtualGraphService.<init>()
...

```

it is probably a problem with the Maven Eclipse plugin but maybe I can try to fix it by manually adding some missing deps if you could just point me in the right direction...

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 24, 2019, 12:32pm UTC](https://community.stardog.com/t/using-maven-is-a-mess/1608/4 "2019-04-24T12:32:51Z")

</div>

> [@DavideRossi](#):
>
> Could not load system index: system

It's been a while since anyone here has used Eclipse or the Maven Eclipse plugin, however this sounds like it could be a matter of $STARDOG\_HOME being set incorrectly. Either that or since it's complaining about `VirtualGraph` things perhaps you have a virtual graph defined and Eclipse can't find the JDBC driver?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [May 8, 2019, 12:32pm UTC](https://community.stardog.com/t/using-maven-is-a-mess/1608/5 "2019-05-08T12:32:51Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
