Java api with Maven dependencies does NOT start the Stardog server

Hello there!

I have been using Stardog in my Java application using Netbeans IDE and Maven dependencies and everything works fine from Netbeans. I can connect to Stardog server from Netbeans and run all the queries necessary.
However, the same application running from the command prompt does not start the Stardog server and gives me back this error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/complexible/stardog/Stardog
at com.mycompany.mavenApp.MainApp.main(MainApp.java:106)
Caused by: java.lang.ClassNotFoundException: com.complexible.stardog.Stardog
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

I am using Netbeans 8.2 with Java "1.8.0_211", Maven 3.8.1 and Stardog 7.4.3
I have used Maven to compile and package the JAR file and I have included these plugins in my POM file:

  <build><plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>3.1.0</version>
      <configuration>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <classpathPrefix>lib/</classpathPrefix>
            <mainClass>com.mycompany.mavenApp.MainApp</mainClass>
          </manifest>
        </archive>
      </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.5.1</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
               <outputDirectory>
                           ${project.build.directory}/dependency-jars/
                     </outputDirectory>
            </configuration>
          </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
            <mainClass>com.mycompany.mavenApp.MainApp</mainClass>
        </configuration>
    </plugin>
  </plugins>
</build>

I have tried to run the jar file from the command prompt using this command:
java -jar target/mavenApp-1.0-SNAPSHOT.jar

I should say that all the dependencies have been copied into the project directory dependency-jars at the time of maven compiling and packaging (mvn compile package).

PS: I also have the %STARDOG_HOME% system variable and path defined.

Any help is greatly appreciated!
Thanks

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