Unable to get a connection using stardog java api

3 views
Skip to first unread message

samch...@gmail.com

unread,
Mar 21, 2014, 1:18:05 PM3/21/14
to sta...@clarkparsia.com, samee...@which.co.uk, Sameer Garg
Hi,

We are in process of evaluating Stardog. 

Our technical stack is JVM(java 7) based and we use maven in our CI pipeline to build our applications into different environments. 

However, we are having major issues in identifying the dependencies required to obtain a connection to Stardog. 

After lot of hit and miss we have narrowed down the required dependencies in our pom.xml (attached in zip project). We have uploaded all of them in our local repository as well. 

(BTW We struggle to upload snapshot artifacts as we have to remove 'snapshot' from the artifact name to upload them in Nexus.)

After doing all this we have created a simple junit test to obtain the connection but it is failing due to the attached error.

Please suggest how we should proceed from here. If you have a maven repository to which we can connect or a sample java project to which we can refer then please provide us the details. I have attached the project in zip format in this email. This would require the dependencies, java 7 and maven.

Regards,
Sameer Garg
Software Eng. @ Which?
stardog-connector-maven.zip

Al Baker

unread,
Mar 21, 2014, 2:48:32 PM3/21/14
to sta...@clarkparsia.com, samee...@which.co.uk, Sameer Garg
Hi Sameer,

I'm not sure how you created your POM, but you have a mix of downstream dependencies, incorrect server dependencies, and missing others.

Here is a correct list in Gradle notation of groupId:artifactId:version

        compile ('com.complexible.stardog.protocols.snarl:client:2.1.2')
        compile ('com.complexible.stardog:common-rdf:2.1.2')
        compile ('com.complexible.stardog:openrdf-utils:2.1.2')
        compile ('com.complexible.stardog:shared:2.1.2')
        compile ('org.openrdf.sesame:sesame:2.7.7')
        compile ('com.complexible.stardog:api:2.1.2')

Note that Maven support for running Stardog as an embedded server is not supported as of 2.1.2, and does require the full server set of libraries.   So in your Junit class, you're calls to the 'Stardog' class in your startEmbeddedServer method will not find the classes.  For running embedded server, we often simplify our build files with Gradle and use the fileTree mechanism to pull in all of the jars in the Stardog distribution.  I would recommend you start with client/server in your development environment first before moving to embedded server.  Unless you're app really needs embedded server, you can automate a test Stardog instance in your CI toolchain and still use the client/server mode – I.e. A prebuilt step that starts a Stardog instance, then builds your app, then a post-build action that stops the Stardog instance.

What I did for the Stardog-Spring setup is have client/server jars, but then pull in the full jar list as a test dependency, so an embedded server can be used for testing.  This is much easier with Gradle where a 'fileTree' call is all that is needed.  Otherwise, you'll have to enumerate the full list and populate them in your pom.  An example can be seen in the stardog-spring build.gradle file (see line 61 for the testCompile line for embedded server):


To make sure you have the right jars, download the latest Starodg, navigate to the bin folder where you'll find a mavenInstall (Unix)  and mavenInstall.bat (Windows) file.  Run the appropriate script for your platform.  Once you do, you'll notice you ~/.m2/repository folder will now have a "com/complexible/…" hierarchy in it.  There should be no snapshots in any of the POMs provided.

This is covered at the end of the Programming Java section of the Stardog docs (scroll to bottom):


-- 
Al Baker



--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
Reply all
Reply to author
Forward
0 new messages