emftriple example fails

45 views
Skip to first unread message

Moritz Hoffmann

unread,
May 25, 2011, 5:42:15 AM5/25/11
to emf4sw-emftriple-discuss
Hi there,
I had a look at emftriple, and it seems to do what I need for a
project. However, I have troubles to get it running. When running the
sample, I get the following exception:

Exception in thread "main" java.lang.NullPointerException
at org.eclipse.emf.ecore.util.EcoreUtil.create(EcoreUtil.java:3247)
at com.emftriple.sail.SailResourceImpl.load(SailResourceImpl.java:94)
at
com.emftriple.resource.ETripleResourceImpl.load(ETripleResourceImpl.java:
101)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:
255)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:
270)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:
397)
at com.emftriple.examples.basic.Main.main(Main.java:60)

This is on Debian/Testing, both Sun and IBM JVM, source code from git
as of today.

Maybe you can give me a hint on what I'm doing wrong!

Thank you,
Moritz

Guillaume Hillairet

unread,
May 25, 2011, 7:56:16 AM5/25/11
to emf4sw-emftriple-discuss
Hi Moritz,

This generally happens when it try to load an rdf resource that has no
rdf:type attached. This can be because nothing is written in the rdf
store (bad file location?), or
when it try to load an object with a wrong uri.
I have to test the example again, and see what is going on.
Nevertheless, this has to be fixed, because it should not raise this
exception, but rather return null.

What you can do now, is try to see if data are actually saved in the
location set in the load options. If nothing is saved then try to
change this location and relaunch the example.
Also, lower the number of parents actually created to 100 or less.
There is still some performance issues with very large number of
objects.

BRs,
Guillaume

Moritz Hoffmann

unread,
May 26, 2011, 3:30:30 AM5/26/11
to emftripl...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Guillaume,
thanks for the explanation!

On 05/25/2011 01:56 PM, Guillaume Hillairet wrote:
> Hi Moritz,
>
> This generally happens when it try to load an rdf resource that has no
> rdf:type attached. This can be because nothing is written in the rdf
> store (bad file location?), or
> when it try to load an object with a wrong uri.
> I have to test the example again, and see what is going on.
> Nevertheless, this has to be fixed, because it should not raise this
> exception, but rather return null.

I figured out what the problem was: The objects in the graph are not
accessible via the URI fragment (graph#object), but they need to be
encoded like graph/object. The solution was to change the following
string in the sample application:

URI.createURI("emftriple://neo_test?graph=http://test&uri=http://eclipselabs.org/emftriple/model#parent_0"),

To:

URI.createURI("emftriple://neo_test?graph=http://test&uri=http://eclipselabs.org/emftriple/model/parent_0"),

> Also, lower the number of parents actually created to 100 or less.
> There is still some performance issues with very large number of
> objects.

I noticed that the example with 1000^2 objects causes the JVM to crash,
so I already reduced the number of objects... Is the problem that all
objects are stored in one graph and thus are loaded into memory at once?

Kind regards,
Moritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iF4EAREIAAYFAk3eAZEACgkQ264ap80Va8fv6gEAjHzhlsDo1DUo0N5fkAiIJfNQ
cn6b6cMBabqztQDF+0gA/2DHoqbC4MK/cSUMpfoUK5TeuRsm2wO7bmgysAZ6JJ+R
=rGOp
-----END PGP SIGNATURE-----

Guillaume Hillairet

unread,
May 26, 2011, 6:00:11 AM5/26/11
to emf4sw-emftriple-discuss
Hi Moritz,

Comments below.

> I figured out what the problem was: The objects in the graph are not
> accessible via the URI fragment (graph#object), but they need to be
> encoded like graph/object. The solution was to change the following
> string in the sample application:

I also found this issue. The problem was that EObject were assigned a
bad proxy URI. So they could not be resolved properly.
The proxy URI is now made of the resource URI and a fragment
containing the RDF URI like : URI#uri=rdf_uri. EObject are now
properly resolved when the resourceSet call getEObject(fragement).
This issue has been fixed in the trunk.

> I noticed that the example with 1000^2 objects causes the JVM to crash,
> so I already reduced the number of objects... Is the problem that all
> objects are stored in one graph and thus are loaded into memory at once?

I have the same problem. If you look at the example, the objects are
first created, then the save method is called. Thus all objects
are stored at once. On small size object graph that is fine but not on
big ones.
A solution would to call save more frequently (in the loop, after
creation of child in this example). But for now, the content of the
resource is not
flush after calling save. This is something to look at, so I'll open
an issue for that.

BRs,
Guillaume
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/

Moritz Hoffmann

unread,
May 26, 2011, 8:08:18 AM5/26/11
to emftripl...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hello Guillame,

first of all, thanks for this piece of software, it's very helpful! I am
now able to run the example, and I start to understand how you
structured the projects.

The next step for me is now to support Jena+files, and I saw that you
have started an implementation, which is not finished. I added a
FileResourceImpl and FileResourceFactory. They are rather minimal at the
moment, it's possible to load data from turtle files.

The next problem I ran into is the handling of references. The file I
want to read uses anonymous references all over the place, but emftriple
seems to expect references to URIs. For Jena, this can be solved by
changing the URL for proxies to

"_:"+resource.getAnonId.toString(),

that way the SPARQL queries work. Emftriple creates the objects, but
only as proxies, which are somehow never initialized. I have to do some
more research on this ;-)

Actually, I think it's not the best way of handling blank nodes. These
objects could be transformed to EMF object directly. I tried to do that
by calling loadEObject again with the nested object's URI, which works
very well.

The other issue I have are URI references in the triples. Let's say I have:

subject ns:references <http://some.url.com/object>

How do I get the URI into my EMF model? I don't know what's behind the
URI, so I would like to have it as a URI, not a modeled object. Is it
possible to solve this?

Thanks again!
Moritz

On 05/26/2011 12:00 PM, Guillaume Hillairet wrote:
> Hi Moritz,
>

-----BEGIN PGP SIGNATURE-----


Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iF4EAREIAAYFAk3eQrEACgkQ264ap80Va8f+MQEAtG+0DOlJHC9uXj5/5s4c/GZQ
zUNkx/LAtvBK9TtpRjYA/3z9DeXwusTTdzKiJjbvy9SdxQNXAc6tYPeCUwGh0CEB
=9gAz
-----END PGP SIGNATURE-----

Guillaume Hillairet

unread,
May 30, 2011, 6:08:14 AM5/30/11
to emf4sw-emftriple-discuss
comments below.

> first of all, thanks for this piece of software, it's very helpful! I am
> now able to run the example, and I start to understand how you
> structured the projects.

thanks, I'm glad it's useful.

> The next step for me is now to support Jena+files, and I saw that you
> have started an implementation, which is not finished. I added a
> FileResourceImpl and FileResourceFactory. They are rather minimal at the
> moment, it's possible to load data from turtle files.

Actually, support for RDF files was in previous versions. I can bring
it back quite easily.

> The next problem I ran into is the handling of references. The file I
> want to read uses anonymous references all over the place, but emftriple
> seems to expect references to URIs. For Jena, this can be solved by
> changing the URL for proxies to
>
> "_:"+resource.getAnonId.toString(),
>
> that way the SPARQL queries work. Emftriple creates the objects, but
> only as proxies, which are somehow never initialized. I have to do some
> more research on this ;-)

Yes, every object in a reference is first created as a proxy. The
proxy URI is the resource URI plus the RDF node URI as fragment. If
the
URI node is a blank node, then the created proxy URI will not be a
valid one. So the proxy could not be loaded. The loading of an EMF
proxy is
done by a SPARQL query that tries to find the RDF resource
corresponding to the proxy URI. The query won't work on blank nodes.

> Actually, I think it's not the best way of handling blank nodes. These
> objects could be transformed to EMF object directly. I tried to do that
> by calling loadEObject again with the nested object's URI, which works
> very well.

Could you give a sample of the blank nodes you try to load, because
according to what I said before, this should not work.

> The other issue I have are URI references in the triples. Let's say I have:
>
> subject ns:references <http://some.url.com/object>
>
> How do I get the URI into my EMF model? I don't know what's behind the
> URI, so I would like to have it as a URI, not a modeled object. Is it
> possible to solve this?

That's not possible right now, because this RDF property has for range
a URI, and thus could be only map to an EReference.
To change that we could add some annotations on the EMF model, in
order to say that this property have to be map to an EAttribute
instead. So the
URIs could be stored in a list of string for example.


BRs,
Guillaume
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/

Moritz Hoffmann

unread,
May 30, 2011, 8:22:12 AM5/30/11
to emftripl...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,
comments below.

On 05/30/2011 12:08 PM, Guillaume Hillairet wrote:
>> The next step for me is now to support Jena+files, and I saw that you
>> have started an implementation, which is not finished. I added a
>> FileResourceImpl and FileResourceFactory. They are rather minimal at the
>> moment, it's possible to load data from turtle files.
>
> Actually, support for RDF files was in previous versions. I can bring
> it back quite easily.

That would be great!

>> The next problem I ran into is the handling of references. The file I
>> want to read uses anonymous references all over the place, but emftriple
>> seems to expect references to URIs. For Jena, this can be solved by
>> changing the URL for proxies to
>>
>> "_:"+resource.getAnonId.toString(),
>>
>> that way the SPARQL queries work. Emftriple creates the objects, but
>> only as proxies, which are somehow never initialized. I have to do some
>> more research on this ;-)
>
> Yes, every object in a reference is first created as a proxy. The
> proxy URI is the resource URI plus the RDF node URI as fragment. If
> the
> URI node is a blank node, then the created proxy URI will not be a
> valid one. So the proxy could not be loaded. The loading of an EMF
> proxy is
> done by a SPARQL query that tries to find the RDF resource
> corresponding to the proxy URI. The query won't work on blank nodes.

I managed to get it working. I now use an URI of "_:"+anonid, and this
one can be used in SPARQL queries to fetch proxy objects.

>
>> Actually, I think it's not the best way of handling blank nodes. These
>> objects could be transformed to EMF object directly. I tried to do that
>> by calling loadEObject again with the nested object's URI, which works
>> very well.

Now as the anonymous URIs work, this is obsolete... And looking at the
source of the Jena implementation, this would not make sense.

>> How do I get the URI into my EMF model? I don't know what's behind the
>> URI, so I would like to have it as a URI, not a modeled object. Is it
>> possible to solve this?
>
> That's not possible right now, because this RDF property has for range
> a URI, and thus could be only map to an EReference.
> To change that we could add some annotations on the EMF model, in
> order to say that this property have to be map to an EAttribute
> instead. So the
> URIs could be stored in a list of string for example.

I solved this issue in a similar way: If there is an EAttribute for some
predicate, and the object is a URI, then it will be stored as String in
the attribute.

Attached you'll find a patch that implements this and the URI handling.
Feel free to include it in the master branch!

Kind regards,
Moritz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iF4EAREIAAYFAk3ji/QACgkQ264ap80Va8eD9wD9FK1tkIO4Ifb2f7iBtBqLT8uW
5WOLDhmGe1w6R+RnwdMBAICelFKBIreMyeHDMwZ0NhrEeOV1v2KDqiH+EDDZt99j
=1ll7
-----END PGP SIGNATURE-----

moritz.patch
Reply all
Reply to author
Forward
0 new messages