Alibaba first steps not working.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Alibaba first steps not working.

Paschke, Stefan
Hello!

I am trying to make the first steps with Alibaba, but I am having problems.

I am getting the following error message:

Exception in thread "main" java.lang.ClassCastException: object.proxies._fffffffff6fcf60f._EntityProxyffffffff9de06bd4 cannot be cast to net.stefanpaschke.resources.Employee
        at net.stefanpaschke.HelloAlibaba.main(HelloAlibaba.java:41)


Details of my source code see further down (Employee class and main method).
The problem is the line 'Employee retrieved = con.getObject(Employee.class, id);'

My developing environment comprises Eclipse (Juno) IDE for Java EE Developers, Oracle JDK 1.7.0_25-b17.

I downloaded Alibaba here.
http://sourceforge.net/projects/sesame/files/AliBabaElmo/2.0/
I used the jar file and it's dependencies as they can be found in the 'lib' and 'dist' folder.

I followed the descriptions that can be found here.
https://bitbucket.org/openrdf/alibaba/src/master/object-repository/

My questions:
 - Why did I get the exception?
 - Is there anything wrong with my employee class?
 - Am I missing something in the main method?

Any help would be appreciated.

Thanks!

Best wishes,
  Stefan Paschke

---
Here is my Employee class
--
import org.openrdf.annotations.Iri;

@Iri(Employee.NS + "Person")
public class Employee {
       
        public static final String NS = "http://stefanpaschke.net/test/foaf#";
       
        @Iri (NS + "label") private String label;

        public String getLabel() {
                return label;
        }

        public void setLabel(String label) {
                this.label = label;
        }
}


----
Here is my main method.
--
import net.stefanpaschke.resources.Employee;

import org.openrdf.model.ValueFactory;
import org.openrdf.query.QueryEvaluationException;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.config.RepositoryConfigException;
import org.openrdf.repository.object.ObjectConnection;
import org.openrdf.repository.object.ObjectRepository;
import org.openrdf.repository.object.config.ObjectRepositoryFactory;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.memory.MemoryStore;

public class HelloAlibaba {

        public static void main(String[] args) throws RepositoryException, RepositoryConfigException, QueryEvaluationException {
                // create a repository
                Repository store = new SailRepository(new MemoryStore());
                store.initialize();
               
                // wrap in an object repository
                ObjectRepositoryFactory factory = new ObjectRepositoryFactory();
                ObjectRepository repository = factory.createRepository(store);
               
                // create an employee
                Employee empl = new Employee();
                empl.setLabel("John");

                // open connection to the repository
                ObjectConnection con = repository.getConnection();

                try {
                        // add an employee to the repository
                        ValueFactory vf = con.getValueFactory();
                        String id = "http://stefanpaschke.net/data/john";
                        con.addObject(id, empl);
                       
                        // retrieve an employee (Line 41)
                        Employee retrieved = con.getObject(Employee.class, id);
                } finally {
                        // close connection to the repository
                        con.close();
                }
               
                store.shutDown();
        }
}



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Alibaba first steps not working.

James Leigh-2
On Mon, 2014-03-24 at 14:19 +0100, Paschke, Stefan wrote:

> Hello!
>
> I am trying to make the first steps with Alibaba, but I am having problems.
>
> I am getting the following error message:
>
> Exception in thread "main" java.lang.ClassCastException: object.proxies._fffffffff6fcf60f._EntityProxyffffffff9de06bd4 cannot be cast to net.stefanpaschke.resources.Employee
> at net.stefanpaschke.HelloAlibaba.main(HelloAlibaba.java:41)
>
>
> Details of my source code see further down (Employee class and main method).
> The problem is the line 'Employee retrieved = con.getObject(Employee.class, id);'

This type of exception occurs when the object is not known to be an
Employee. The first thing to check is if the RDF store has a triple that
links the IRI of the id to the IRI of the Employee class (using
rdf:type).

Regards,
James


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general
Loading...