Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

RDF in Java - Runtime Problem

Options
  • 26-02-2014 9:30pm
    #1
    Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭


    Trying to convert a file from csv to rdf. No problems reading the data, but I'm having issues with the following and it's starting to become somewhat cumbersome at the moment. Maybe I'm just having one of those days.
    public void makeFile(String[] array2)
    {
    this.array2 = array2;

    try
    {
    Model model = ModelFactory.createDefaultModel();
    Resource node;
    FileOutputStream fout = new FileOutputStream("dir\\file.rdf");

    for(int x = 0; x < array2.length; x++)
    {
    System.out.println(array2[x]);
    System.out.println();

    node = model.createResource(personURI).addProperty(VCARD.FN, fullName).addProperty(VCARD.N, model.createResource().addProperty(VCARD.Given, givenName).addProperty(VCARD.Family, familyName));
    model.write(fout);
    }
    }
    catch(IOException e)
    {
    System.out.println("IOException: " + e.getMessage());
    }
    catch(Exception a){}
    }

    The code itself doesn't have any problems and compiles fine. I'm using Jena as I want to write an RDF document, but the above in bold seems to throw problems every time, in every example I use. The following runtime issue appears in everything I try:
    SLF4J built for org.grlea.log.adapters.slf4j.Slf4jAdapterFA
    Exception in thread "main" java.lang.NoClassDefFoundError: org/grlea/log/SimpleLogger
    at org.grlea.log.adapters.slf4j.Slf4jAdapterFA.getLogger(Unknown Source)
    at org.slf4j.LoggerFactory.getLogger(Unknown Source)
    at com.hp.hpl.jena.util.Metadata.<clinit>(Metadata.java:39)
    at com.hp.hpl.jena.JenaRuntime.<clinit>(JenaRuntime.java:34)
    at com.hp.hpl.jena.rdf.model.impl.RDFReaderFImpl.reset(RDFReaderFImpl.java:79)
    at com.hp.hpl.jena.rdf.model.impl.RDFReaderFImpl.<clinit>(RDFReaderFImpl.java:72)
    at com.hp.hpl.jena.rdf.model.impl.ModelCom.<clinit>(ModelCom.java:54)
    at com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(ModelFactory.java:140)
    at Tutorial04.main(Tutorial04.java:24)
    Caused by: java.lang.ClassNotFoundException: org.grlea.log.SimpleLogger
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 9 more

    Process completed.

    I've searched everywhere possible and used additional jar files as suggested. Anyone have any ideas on what may be the issue?


Comments

  • Registered Users Posts: 27,088 ✭✭✭✭GreeBo


    Your model factory/Jena code needs some slf4j implementation provided at runtime. It probably has the slf4j-api as a compilation dependency, but to run you'll need to give it a concrete implementation... Just grab the log 4j slf4j impl jar and stick it on your class path, should fix it.

    Take a look at slf4j site for more info, possibly Jena explains it too


  • Registered Users Posts: 27,088 ✭✭✭✭GreeBo


    Actually looks like you need a specific implementation, try this one


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭L.Jenkins


    Still working on the problem and I've added the jars to the project. Seem to still have the same runtime issue.


  • Registered Users Posts: 27,088 ✭✭✭✭GreeBo


    Are the jars on your runtime class path?
    What ide are you using?


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭L.Jenkins


    Using JCreator and adding the Jars to the relevant lib folder as required.


  • Advertisement
  • Registered Users Posts: 27,088 ✭✭✭✭GreeBo


    check your runtime classpath, the stacktrace is telling you that it doesnt have the jar I listed on your classpath...

    Check you runtime/run env, or try running it directly from command line and specify the classpath manually


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭L.Jenkins


    Using the Eclipse now and set the paths to the required jars and locations. Like a demon, because I'm still having similar problems.
    SLF4J built for org.grlea.log.adapters.slf4j.Slf4jAdapterFA
    WARNING: Simple Log (Slf4jAdapterFA): Failed to find class for logger loggerName 'Semantics'. Using class 'org.slf4j.Logger' and instanceId 'Semantics'.

    Starting to test my patients some what.


  • Registered Users Posts: 27,088 ✭✭✭✭GreeBo


    thats fine, its just a warning...should still be runnung


  • Registered Users Posts: 27,088 ✭✭✭✭GreeBo


    Any follow up OP?


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭L.Jenkins


    I couldn't get the app to write an output to a file.


  • Advertisement
  • Registered Users Posts: 27,088 ✭✭✭✭GreeBo


    If the file is small try flushing and closing the file output stream, content night be stuck in buffer
    Also not sure why you are writing the file in your loop...don't seem to reference loop other than your sysouts?


Advertisement