Hi! I'm trying to use OpenSesame on android. Therefore i included the opensesame-onejar in my project.

When running the project, a exception is thrown: java.lang.NoClassDefFoundError: javax.imageio.spi.ServiceRegistry thrown in the info.aduna.lang.service.ServiceRegistry.(ServiceRegistry.java:37).

In my Code it appears, when I want to add a rdf-file: con.add(file, baseURI, RDFFormat.NTRIPLES);

I'm creating my repository as follows: Repository myRepository = new SailRepository(new MemoryStore()); myRepository.initialize(); RepositoryConnection con = myRepository.getConnection();

Can you explain how I should rewrite the ServiceRegistry?


asked 25 May '12, 04:17

kanathiny's gravatar image

accept rate: 0%

Sesame-2.7.0 updates to using Java-6, including switching to using java.util.ServiceLoader, so you shouldn't get the class not found error for that class. However, there may be other classes that are not supported by Android's Dalvik virtual machine, which isn't a full Java Virtual Machine implementation.

If you want to avoid using the service registry you can also hardcode references to your desired parsers and parse the triples directly into the RepositoryConnection using the RDFInserter implementation as your RDFHandler that is attached to your RDFParser.

// Typically RepositoryConnection.add method would use this internally:
RDFParser nTriplesParser = Rio.createParser(RDFFormat.NTRIPLES)
// However, you can also do the same thing by hardcoding the implementation using:
RDFParser nTriplesParser = new NTriplesParser(); 
nTriplesParser.setRDFHandler(new RDFInserter(repositoryConnection));
nTriplesParser.parse(input, baseURI);
permanent link

answered 02 May '13, 21:41

Peter%20Ansell's gravatar image

Peter Ansell
accept rate: 9%

Sesame's ServiceRegistry uses the javax.imageio.spi package for registering RDF parsers and writers, as well as supported query result formats and a few other things. Unfortunately, it turns out that this package, while part of the standard Java SDK, is not supported on Android by default.

I'm not immediately sure if there is an easy way to fix this. There may be a way to download and install the necessary packages separately, but someone with more experience developing for Android should be better placed to tell you that.

You could presumably work around the problem by actually creating the parser object manually instead of relying on Sesame to figure it out for you, but that would be a bit unwieldy.

I've also noticed that there may be an easy way to fix this in Sesame itself, by replacing the use of javax.imageio.spi.ServiceRegistry with java.util.ServiceLoader. I recommend that you get in touch with the Sesame development team directly via the mailinglist, if you are willing to help out test some stuff it may be possible to produce an adapted version of Sesame that will run on Android.

permanent link

answered 25 May '12, 20:14

Jeen%20Broekstra's gravatar image

Jeen Broekstra ♦
accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 25 May '12, 04:17

question was seen: 2,578 times

last updated: 02 May '13, 21:41