Geospatial Meaning

Geospatial Semantic Web Research. GeoWeb Trends

 

The Semantic Web with .NET. Pellet, Jena and SQL Server 2005

The Semantic Web is gradually going from the research cage to the real implementation world. Most of real semantic applications mix some knowledge base, inference engines, etc. with traditional object oriented software. We have to make the most of our current business knowledge and professional skills to be able to unleash the Semantic Web.

And that means that Semantic Web should be capable to talk with traditional open source software, object oriented programming languages, web services, etc. etc.

As an example, I had to add some semantic power to a Geospatial Web application for Cinespace, an European FP6 project (I will talk about it soon).

There are several posts which tell how to hack Jena and Mono/C#, or converting Jena to .NET. But there is not a source telling how to use Pellet and Jena using SLQ Server for persistence. This will allow us to have an OWL DL inference engine over a RDB store.

I’ll explain how to set up this system step by step in this post, with updated Pellet and Jena versions and two examples to test the configuration.

I recommend to download the exact versions suggested next. If you are able to make it work with more up to date jdbc driver, or ikvm version, please let me know.

Step 1: Download Pellet 1.5.1. Copy the lib directory to a new folder (for instance C:\Pellet\lib). The folder lib\jena contains Jena 2.5.

Step 2: Download IKVM 0.34.0.2 bin. I haven’t success with newer versions.

Step 3: Download Microsoft jdbc driver for SQL Server 1.1. 1.2 Versions doesn’t work for me.

Step 4: Copy all ikvm files in bin directory to the pellet directory created in step 1 (i.e. C:\Pellet\lib)

Step 5: Copy the MS jdbc driver file, sqljdbc.jar , to the pellet directory create in step 1 (i.e. C:\Pellet\lib)

Step 6: Download this Pellet and Jena converter batch file and copy to the well known pellet directory.

Step 7: Execute the .bat file.

Step 7: You should have a directory called DotNet_Libraries. Reference the libraries in this folder in your C# project, and that is.

You can test SQL Server persitence with this class: Jena SQL Server 2005 persistence

You can make a simple Jena + Pellet ontology consistence test with this class. Pellet services test

19 Responses to “The Semantic Web with .NET. Pellet, Jena and SQL Server 2005”

  1. Persisting with Semantic Web in .NET « Geospatial Meaning Says:

    [...] weeks ago I post a way to embed Semantic Web engines, Jena and Pellet in .NET solutions. Recently I had an odd behaviour when persisting RDF models to a file via Model.write and [...]

  2. Yagmur Konuslu Says:

    Hi,
    Thanks for the guide. Get “found no suitable driver exception” while trying to connect to and SQLExpress instance. Any suggestions?
    Best Regards

  3. admin Says:

    I also got the same error. Which versions are you using for each library and program?

    Take a look at:

    http://www.geospatialmeaning.eu/2008/06/27/persisting-with-semantic-web-in-net/

  4. Yagmur Konuslu Says:

    I use
    IKVM 0.36.0.11
    Jena 2.5.6
    JDBC Driver 1.1, 1.2 and tried JTDS also
    Pellet 1.5.2

  5. Yagmur Konuslu Says:

    I have converted the MS JDBC Driver 1.2 and all the jena jar’s into the same assembly and the “no suitable driver exception” went away. However at this time i get and exception saying
    “The database appears to be unformatted or corrupted and an attemt to automatically format the database has failed”, when calling the createModel function.
    The same approach works for Postgre exceptionless.
    I’ m using MS SqlServer 2005 Express

  6. admin Says:

    It is the first time I see that error.

    I have found two links talking about the same problem: http://jira.nuxeo.org/browse/NXP-1890, http://jira.nuxeo.org/browse/NXP-697

    Also in the following piece of code, http://www.javadocexamples.com/java_source/com/hp/hpl/jena/db/impl/DriverRDB.java.html they control the formatting of the database. Perhaps you could clean the db…

  7. maya Says:

    if we change the schema of database which is automatically generated by RDF file when generated in .net with the help of pellet and IKVM will SPARQL run?
    if we create own RDF data base in form of triples subject, predicate and object in sql server 2005 whitout using an RDF file can we query it by using pellet through SPARQl if yes then please tell me how.

  8. maya Says:

    hi i have implemented jena in .net as an input i am giving it northwind file as shown below but it is not creating model for that plz help me why it is not creating model

    Northwind
    Northwind database classes and properties
    Northwind
    1.

    Product

    1
    Category

    1
    Supplier

    1
    ProductName

  9. admin Says:

    And RDB model doesn’t provide RDF functionality. You need a ‘translation’ between the RDF/OWL triples and a traditional RDB model.

    Jena provides a way (not the only one) to persist this information, using its own DB schema. You should look at the Jena code or ask Jena to learn about the consequences of a change in their database schema.

    But please explain me what you intend to do, perhaps there exists another solution.

    To my knowledge, you need to load a Jena or Pellet Model to be able to query it via SPARQL. This model can be modified, executed an inference engine over it, etc. etc. but you need a compatible source, for instance an RDF or OWL file, or an RDF/OWL file persited with Jena API.

    Again, if you explain what you want to achieve perhaps I can help you.

  10. Alex Golubev Says:

    Hi,
    I also got “found no suitable driver” exception with

    IKVM 0.36.0.11
    Jena 2.5.6
    JDBC Driver 1.1, 1.2 and tried JTDS also
    Pellet 1.5.2

    All possible combinations failed too.

    But additional string in jenapersistencerdb.cs resulted good connection:

    java.sql.Connection c = java.sql.DriverManager.getConnection(”jdbc:sqlserver://localhost\\SQLEXPRESS;user=sa;password=****;databaseName=OWLworks”);

    I guess, that driver is OK. What’s wrong?

  11. admin Says:

    Try to convert all the jar’s into the same dll, including pellet, jena and the sql driver.
    That way I always get it working.
    If you still have problems I can send you the conversion.

  12. Alex Golubev Says:

    Thank you.Nice to meet you on next level!Eventually tables appeared in my base.
    But I got except.:”Graph properties not found after creating graph.”
    I can’t owercome, help!

  13. Samuel Says:

    Hi! I follow your tutorial and it happens the same that Alex Golubev.

    Failure to instantiate DB Driver:MsSQL java.sql.SQLException: No suitable driver found for jdbc:sqlserver://…

    What do you mean by “Try to convert all the jar’s into the same dll, including pellet, jena and the sql driver.” You are talking about convertion with IKVM? I also read your other post and i used the new tool versions.

    Any ideia of what i might doing wrong?

    Can u help?

  14. admin Says:

    You have several options for making IKVM conversion, build a dll for each jar (As I proposed in the post) or build only one dll containing all jar conversions.

    I also had several times the problem of “No suitable driver found” but I resolved it by converting all jena, pellet, sql driver etc. in the same dll with IKVM.

    I hope this solve your doubts.

  15. Samuel Says:

    Hi!

    now is giving me this error

    “com.hp.hpl.jena.db.RDFRDBException was unhandled
    Message=”Failure to instantiate DB Driver:MsSQL com.microsoft.sqlserver.jdbc.SQLServerException: The server sqlexpress is not configured to listen with TCP/IP.”
    Source=”JenaCSharpTest3″
    StackTrace:
    em wsGeoConceptsSemWebLayer.JenaPersistenceRDB..ctor(String modelName, String dbserver, String db, String dbuser, String dbpass)…”

    i have a Windows Forms Application with a button that is calling

    ” JenaPersistenceRDB jprdb = new JenaPersistenceRDB(”dotnetmodel”, “ACER-JO\\SQLEXPRESS”, “localhost”, “ACER-JO\\Joana”, “”); ”

    am i missing something? do i need anything more then the 3 dll’s (the one that i created with ikvmc and the 2 ikvm) dont need anymore of jena or pellet?

  16. Samuel Says:

    Hi, problem solved!! The problem was in Sql Server; I had to enable the access to tcp/ip, and the way i connected to the db, etc.

    But i noticed that i’m not putting the jar’s in just 1 dll, is just add the last jar…

    how did you add the jar’s just in one??

  17. admin Says:

    By using the following:

    ikvmc .\Java_Libraries\*.jar -target:library -out:.\DotNet_Libraries\semantic_reasoners.dll -version:1.5.2.0 -nowarn:IKVMC0109

    All the jars are in Java_Libraries directory.

    Best regards.

  18. Jonh Says:

    How do you do queries with pellet in C#? You don’t show in here

  19. admin Says:

    Jonh, once you convert the jar’s to dll’s you can use java packets as C# namespaces and use Pellet and Jena API as usual. How to use these API’s is explained in their home pages :-)

Leave a Reply

Categories

Archives

Links

Affiliation

Innovation Blogs - BlogCatalog Blog Directory blogarama - the blog directory Blog Directory