No Starrocks-CentOS-7 in java.library.path

I tried to access Stardog from RDF4J.
In my mab=in i have the following line of code Stardog aStardog = Stardog.builder().create();
So, when I execute my maven project through mvn exec:java I get the following exception

[StardogTestDriver.main()] INFO  c.c.common.LinuxDistribution - Determined Linux distribution from file '/etc/os-release': CentOS 7.0 (7)
15:41:36.313 [StardogTestDriver.main()] ERROR com.stardog.starrocks.StarrocksUtils - Unable to load native library(Starrocks-CentOS-7):
java.library.path = </opt/software/slurm/lib:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib>
LD_LIBRARY_PATH = {/opt/software/slurm/lib}
java.lang.UnsatisfiedLinkError: no Starrocks-CentOS-7 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_121]
        at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_121]
        at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_121]
        at com.stardog.starrocks.StarrocksUtils.loadLibrary(StarrocksUtils.java:94) ~[stardog-7.3.0.jar:na]
        at com.complexible.stardog.Stardog.<init>(Stardog.java:168) [stardog-7.3.0.jar:na]
        at com.complexible.stardog.Stardog.<init>(Stardog.java:66) [stardog-7.3.0.jar:na]
        at com.complexible.stardog.Stardog$StardogBuilder.create(Stardog.java:655) [stardog-7.3.0.jar:na]
        at StardogTestDriver.main(StardogTestDriver.java:33) [classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297) [exec-maven-plugin-1.2.1.jar:na]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
15:41:36.315 [StardogTestDriver.main()] ERROR com.stardog.starrocks.StarrocksUtils - Unable to load native library(native library name =Starrocks-CentOS-7)
java.lang.UnsatisfiedLinkError: no Starrocks-CentOS-7 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_121]
        at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_121]
        at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_121]
        at com.stardog.starrocks.StarrocksUtils.loadLibrary(StarrocksUtils.java:94) ~[stardog-7.3.0.jar:na]
        at com.complexible.stardog.Stardog.<init>(Stardog.java:168) [stardog-7.3.0.jar:na]
        at com.complexible.stardog.Stardog.<init>(Stardog.java:66) [stardog-7.3.0.jar:na]
        at com.complexible.stardog.Stardog$StardogBuilder.create(Stardog.java:655) [stardog-7.3.0.jar:na]
        at StardogTestDriver.main(StardogTestDriver.java:33) [classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297) [exec-maven-plugin-1.2.1.jar:na]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
[WARNING]
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsatisfiedLinkError: no Starrocks-CentOS-7 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at com.stardog.starrocks.StarrocksUtils.loadLibrary(StarrocksUtils.java:94)
        at com.complexible.stardog.Stardog.<init>(Stardog.java:168)
        at com.complexible.stardog.Stardog.<init>(Stardog.java:66)
        at com.complexible.stardog.Stardog$StardogBuilder.create(Stardog.java:655)
        at StardogTestDriver.main(StardogTestDriver.java:33)
        ... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.040 s
[INFO] Finished at: 2020-05-13T15:41:36-07:00
[INFO] Final Memory: 33M/1278M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project rdf4j-getting-started: An exception occured while executing the Java class. null: InvocationTargetException: no Starrocks-CentOS-7 in java.library.path -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

So, someone has an idea how to solve this issue please

I am going to assume you desire a new instance of Stardog within your Java code because that's what you're doing here. Stardog requires non-Java native code (DLLs) to run. You need to set the java.library.path variable to the lib/ directory of the distribution.

Jess

Thank you. You mean to the lib folder inside where i installed stardog. I mean the following lib folder which include

  1. libStarrocks-CentOS-7.so
  2. libStarrocks.dylib
  3. ...
  4. VCRUNTIME140.dll

If yes, please how I can set that

You can either set it at the command line when starting your Java process, eg. -Djava.library.path=/path/to/stardog/lib or in Java code System.setProperty("java.library.path", "/path/to/stardog/lib");.

Unfortunately, it not working. The same exception is still thown

Can you try passing the argument on the command line? It's possible that you are setting the system property too late in the process; after it has been used and cached.

I tried

java -Djava.library.path=/path/to/stardog/lib

But I still get the exception and the

java.library.path = </opt/software/slurm/lib:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib>

but if I add

System.setProperty("java.library.path", "/path/to/stardog/lib") the java path is

java.library.path = </project/6008168/tamouze/stardog-7.3.0/lib>

Are you running through Maven? How are you setting the system property on the command line?

yes. with

mvn compile

its ok, but in execution

mvn exec:java

the exception is raised.

You can either add it on the command line

mvn exec:java -Djava.library.path=$STARDOG/lib

or in the pom.xml file

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <configuration>
        <mainClass>com.myPackage.myClass</mainClass>
        <commandlineArgs>-Djava.library.path=${env.STARDOG}/lib</commandlineArgs>
      </configuration>
    </plugin>
  </plugins>
</build>

You'll need to use either $STARDOG or $STARDOG_HOME depending on how exactly you've installed Stardog but just make it where you fine the lib directory.

Im sorry i cannot uderstand what you mean. I installed stardog as

https://www.stardog.com/docs/#_starting_stardog

So i have a folder named

stardog-7.3.0
which icluding bin, client, etc

and folder called

STARDOG_HOME

including data, system, stardog-license-key.bin, etc

So how i should configure the

commandlineArgs

I’m a little confused when you say you have a folder called STARDOG_HOME that might indicate a problem with your installation. Do you have a folder that is actually named STARDOG_HOME or do you have some folder who’s path is set to the environment variable STARDOG_HOME?

You should most likely change the environment variable in my previous examples from STARDOG to STARDOG_HOME.

I have folder called STARDOG_HOME where I used to save the created database etc. Indeed I set this variable as follow

export STARDOG_HOME= "/project/6008168/tamouze/STARDOG_HOME"

and my installation is under the folder stardog7.3.0, which I added to the PATH as

export PATH=$PATH:/project/6008168/tamouze/stardog-7.3.0/bin

Now to run Stardog, I did

stardog-admin server start --home /project/6008168/tamouze/STARDOG_HOME

and the startdog starts where i was asked to enter my email and that i have 60 days trial and now the

stardog-license-key.bin appears in

/project/6008168/tamouze/STARDOG_HOME

So, this is how i installed stardog where I can create throughthe command line a datbase and to query this database. The problem is only where I try to access this database through the code RDF4J

Your setup looks good. Try the options I previously mentioned but using the STARDOG_HOME variable instead as shown below. You can try the first one just to see if it works and then the second one so you don'e have to enter such a long command.

mvn exec:java -Djava.library.path=$STARDOG_HOMES/lib

or in the pom.xml file

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <configuration>
        <mainClass>com.myPackage.myClass</mainClass>
        <commandlineArgs>-Djava.library.path=${env.STARDOG_HOME}/lib</commandlineArgs>
      </configuration>
    </plugin>
  </plugins>
</build>

Still not working.
1- With

mvn exec:java -Djava.library.path=$STARDOG_HOME/lib

the library path is set as follow

java.library.path = lib

In any way, in STARDOG_HOMES i dont have the lib.
2- With

mvn exec:java -Djava.library.path=/project/6008168/tamouze/stardog-7.3.0/lib

the path is set to

java.library.path = </project/6008168/tamouze/stardog-7.3.0/lib>

Even that the same error still raised

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project rdf4j-getting-started: An exception occured while executing the Java class. null: InvocationTargetException: no Starrocks-CentOS-7 in java.library.path -> [Help 1]

STARDOG_HOMES was a typo. If I understand your previous post java.library.path should be set to /project/6008168/tamouze/STARDOG_HOME/lib

That directory name is very confusing as it’s the same as the environment variable.

So, please you suggestion to solve that. /STARDOG_HOME/ lib does not exist. What I have in STARDOG_HOME is a folder called data, another one called myDB which i created from the command line, etc, but NO lib inside
Or if possible to explicitly specify how i can install without any problem.

By the way, the following documentation is not clear at least for me;

You should not set STARDOG_HOME to be the same as the directory where you put the Stardog binary. Our convention is to put Stardog in /opt/stardog/{$version} and set STARDOG_HOME to /var/stardog

can you please explain please
I so appreciate your help

I can see how it can be a little confusing. In the simplest setup you can simply unzip the Stardog distribution and set the STARDOG_HOME environment variable to the directory containing Stardog. (ie. stardog-x.x.x). With this setup your database files will be contained in the same directory as the stardog distribution. This makes for an easier setup but can cause some problems when upgrading because the files are mixed together. To overcome this you can separate the Stardog distribution from the database files (the files that contain your data) into two directories. The directory containing your database files is set to the env variable STARDOG_HOME. (ie STARDOG_HOME=/var/stardog) and you'd set the env variable STARDOG to the Stardog distribution (ie STARDOG=/opt/stardog/{$version})

If you set it up this way there should be a lib folder in your $STARDOG directory /opt/stardog/7.3.0/lib. This is the directory you'd set in java.library.path

Thank you so much but it doesnt work. I do exactly the same but the error still. I can see that startdog is starting but with maven the same exception still raised

Can you try the second option of updating the config in your pom.xml file? I suspect that the exec plugin may fork off a separate JVM and doesn't pass through the option.