[Mulgara-general] LocalJRDFSession

Omar Khan okhan at 2paths.com
Wed Nov 26 00:56:50 UTC 2008


Hello,
I'm a newbie to mulgara. I'm trying to follow the integration with JRDF
tutorial provided on the mulgara website. When I cut and past it in and run
it I get a class cast exception:

org.mulgara.server.rmi.RemoteSessionWrapperJRDFSession
Exception in thread "main" java.lang.ClassCastException:
org.mulgara.server.rmi.RemoteSessionWrapperJRDFSession
    at org.twopaths.jrdf.Sandbox.main(Sandbox.java:36)


According to the documentation, if you set the boolean parameter for
SessionFactoryFinder.newSessionFactory(serverURI, false) to false, it should
return a LocalJRDFSession however, it returns a remote session.

I've also tried to use the JRDF client rather than server and I get a no
such method exception

Exception in thread "main" java.lang.NoSuchMethodError:
org.jrdf.graph.AbstractTripleFactory: method <init>()V not found

I checked the source for the class and the method isn't there.

I'm using Mulgara 2.0.6 on am Mac running OSX. I'm developing in Eclipse.

Any guidance you could provide would be appreciated.

The code that I'm running is as follows:

package org.twopaths.jrdf;

import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;

import org.jrdf.graph.Graph;
import org.jrdf.graph.GraphException;
import org.mulgara.client.jrdf.AbstractGraphFactory;
import org.mulgara.jrdf.JRDFGraph;
import org.mulgara.jrdf.LocalJRDFSession;
import org.mulgara.query.QueryException;
import org.mulgara.server.JRDFSession;
import org.mulgara.server.NonRemoteSessionException;
import org.mulgara.server.SessionFactory;
import org.mulgara.server.driver.SessionFactoryFinder;
import org.mulgara.server.driver.SessionFactoryFinderException;

public class Sandbox {
    public static void main(String[] args) {
        try {
            // Create the host name
            String hostname =
InetAddress.getLocalHost().getCanonicalHostName();

            // Create the URI of the server
            URI serverURI = new URI("rmi", hostname, "/" + "server1", null);

            // Create a new session factory, ensure that it's local
            SessionFactory sessionFactory =
SessionFactoryFinder.newSessionFactory(serverURI, false);

            // Get a local JRDF Session (local)
            Object o = sessionFactory.newJRDFSession();
            System.out.println(o.getClass().getName());
//            JRDFSession session = (JRDFSession)
sessionFactory.newJRDFSession();
            LocalJRDFSession session = (LocalJRDFSession)
sessionFactory.newJRDFSession();

            //create a new Model
            URI modelURI = new URI("rmi", hostname, "/" + "server1",
"exampleGraph");
            URI modelType = new URI("http://mulgara.org/mulgara#Model");
            session.createModel(modelURI, modelType);

            //create a JRDF Graph for the model
            Graph graph = new JRDFGraph(session, modelURI);
//            Graph graph = AbstractGraphFactory.createGraph(serverURI,
modelURI);
        } catch (UnknownHostException uhe) {
            uhe.printStackTrace();
        } catch (URISyntaxException urise) {
            urise.printStackTrace();
        } catch (SessionFactoryFinderException sffe) {
            sffe.printStackTrace();
        } catch (NonRemoteSessionException nrse) {
            nrse.printStackTrace();
        } catch (QueryException qe) {
            qe.printStackTrace();
        } catch (GraphException ge) {
            ge.printStackTrace();
        }
    }
}





------------------------------

 <http://www.2paths.com>
 Omar Khan
Technical Architect

*e:* okhan at 2paths.com
*p:* 604-689-4123 ext 13
*w:* http://www.2paths.com
  2Path Solutions <http://www.2paths.com>
Suite 502-1540 West 2nd Avenue
Vancouver, BC
V6J 1H2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mulgara.org/pipermail/mulgara-general/attachments/20081125/1151e0ff/attachment.htm>


More information about the Mulgara-general mailing list