connection from a restful service

1 view
Skip to first unread message

ali.k...@gmail.com

unread,
Nov 5, 2015, 12:49:56 PM11/5/15
to Stardog
Hi,

I try to connect to a stardog database. It works when I retrieve data from a main java file but it raises exception when I try to connect from a restful service. Any idea ?

Here is my sample code:

String db = "mydb";
String server = "snarl://localhost:5820";
Connection conn = ConnectionConfiguration
.to(db)
.credentials("admin", "xxx")
.server(server)
.connect();
SelectQuery query = conn.select(select distinct ?iri ?fn ?ln from dst-persons:graph where { ?iri a dst:PhdStudent; foaf:firstName ?fn; foaf:familyName ?ln });
TupleQueryResult tqr = query.execute();

Thx for your help,
Regards,
A.

Michael Grove

unread,
Nov 5, 2015, 3:02:34 PM11/5/15
to stardog
On Thu, Nov 5, 2015 at 12:49 PM, <ali.k...@gmail.com> wrote:
Hi,

I try to connect to a stardog database. It works when I retrieve data from a main java file but it raises exception when I try to connect from a restful service. Any idea ?

It would be helpful if you provided the exception you get.  It's probably a classpath issue, but it's impossible to say without knowing what the actual problem is.

Cheers,

Mike
 

Here is my sample code:

String db = "mydb";
String server = "snarl://localhost:5820";
Connection conn = ConnectionConfiguration
.to(db)
.credentials("admin", "xxx")
.server(server)
.connect();
SelectQuery query = conn.select(select distinct ?iri ?fn ?ln from dst-persons:graph where { ?iri a dst:PhdStudent; foaf:firstName ?fn; foaf:familyName ?ln });
TupleQueryResult tqr = query.execute();

Thx for your help,
Regards,
A.

--
-- --
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

ali koudri

unread,
Nov 6, 2015, 5:42:43 AM11/6/15
to Stardog
Hi Mike,

sorry, here is the message I got in the server logs.

StandardWrapperValve[fr.systemx.webapp.DstApplication]: Servlet.service() for servlet fr.systemx.webapp.DstApplication threw exception
java.net.ConnectException
    at com.complexible.common.protocols.client.rpc.DefaultRPCClient.<init>(DefaultRPCClient.java:127)
    at com.complexible.stardog.protocols.snarl.client.AbstractSNARLClient.<init>(AbstractSNARLClient.java:75)
    at com.complexible.stardog.protocols.snarl.client.SNARLClientImpl.<init>(SNARLClientImpl.java:53)
    at com.complexible.stardog.protocols.snarl.client.SNARLClientImpl$$FastClassByGuice$$b2f20e06.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
    at com.google.inject.assistedinject.FactoryProvider2.invoke(FactoryProvider2.java:770)
    at com.sun.proxy.$Proxy218.createClient(Unknown Source)
    at com.complexible.stardog.protocols.snarl.client.SNARLDriver.connect(SNARLDriver.java:111)
    at com.complexible.stardog.api.DriverManager.getConnection(DriverManager.java:74)
    at com.complexible.stardog.api.ConnectionConfiguration.connect(ConnectionConfiguration.java:126)
    at fr.systemx.webapp.data.DataProvider.getConnection(DataProvider.java:57)
    at fr.systemx.webapp.data.DataProvider.getStudents(DataProvider.java:66)
    at fr.systemx.webapp.services.PhdStudentService.getStudents(PhdStudentService.java:23)
    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:483)
    at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171)
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:195)

Hope it helps.
Regards,
A!,

Michael Grove

unread,
Nov 6, 2015, 6:57:47 AM11/6/15
to stardog
On Fri, Nov 6, 2015 at 5:37 AM, ali koudri <ali.k...@gmail.com> wrote:
Hi Mike,

sorry, here is the message I got in the server logs.

StandardWrapperValve[fr.systemx.webapp.DstApplication]: Servlet.service() for servlet fr.systemx.webapp.DstApplication threw exception
java.net.ConnectException

The ConnectException indicates that the client could not connect to the server.  Are you certain the server is reachable from your client at the given URL?

Cheers,

Mike
 

--

ali koudri

unread,
Nov 6, 2015, 10:27:51 AM11/6/15
to sta...@clarkparsia.com
As I said before, it works from standard java program. I can't see any reason it fails from a restful service!

Regards,
A.

To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

Michael Grove

unread,
Nov 6, 2015, 11:15:25 AM11/6/15
to stardog
On Fri, Nov 6, 2015 at 10:27 AM, ali koudri <ali.k...@gmail.com> wrote:
As I said before, it works from standard java program. I can't see any reason it fails from a restful service!

Getting a ConnectException would have nothing to do with what's opening the connection.  Likely, the server is not running, or not reachable from what is running your webapp.

Cheers,

Mike
Reply all
Reply to author
Forward
0 new messages