9 Replies Latest reply: Nov 23, 2011 7:18 PM by JorgeB-Oracle RSS

    java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite

    896511
      Hello,

      i'm trying a sample from your documentation.

      -----
      package examples;

      import oracle.spatial.rdf.client.jena.*;
      import com.hp.hpl.jena.rdf.model.Model;
      import com.hp.hpl.jena.graph.*;
      import com.hp.hpl.jena.query.*;


      public class Test {

      public static void main(String[] args) throws Exception
      {
      String szJdbcURL = args[0];
      String szUser = args[1];
      String szPasswd = args[2];

      String szModelName = args[3];
           
      Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
      Model model = ModelOracleSem.createOracleSemModel(
      oracle, szModelName);

      model.getGraph().add(Triple.create(
      Node.createURI("http://example.com/John"),
      Node.createURI("http://example.com/fatherOf"),
      Node.createURI("http://example.com/Mary")));

      Query query = QueryFactory.create(
      "select ?f ?k WHERE {?f <http://example.com/fatherOf> ?k .}");
      QueryExecution qexec = QueryExecutionFactory.create(query, model);
      ResultSet results = qexec.execSelect();
      ResultSetFormatter.out(System.out, results, query);

      model.close();
      oracle.dispose();
      }
      }
      -----


      but a receive this error message :

      -----
      Exception in thread "main" java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite
           at java.lang.ClassLoader.defineClass1(Native Method)
           at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
           at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
           at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
           at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
           at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
           at java.security.AccessController.doPrivileged(Native Method)
           at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
           at oracle.spatial.rdf.client.jena.QueryEngineSem.modifyOp(QueryEngineSem.java:179)
           at com.hp.hpl.jena.sparql.engine.QueryEngineBase.createPlan(QueryEngineBase.java:104)
           at com.hp.hpl.jena.sparql.engine.QueryEngineBase.getPlan(QueryEngineBase.java:97)
           at oracle.spatial.rdf.client.jena.QueryEngineSem$1.create(QueryEngineSem.java:202)
           at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.getPlan(QueryExecutionBase.java:426)
           at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.startQueryIterator(QueryExecutionBase.java:400)
           at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execResultSet(QueryExecutionBase.java:408)
           at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execSelect(QueryExecutionBase.java:135)
           at examples.Test.main(Test.java:30)
      Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.sparql.algebra.opt.Rewrite
           at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
           at java.security.AccessController.doPrivileged(Native Method)
           at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
      -----

      A have these librairies in my Build Path :
      arq-2.8.8.jar
      icu4j-3.4.4.jar
      iri-0.8.jar
      jena-2.6.4.jar
      junit-4.5.jar
      log4j-1.2.13.jar
      lucene-core-2.3.1.jar
      ojdbc6.jar
      sdonm.jar
      sdordf.jar
      sdordfclient.jar
      sdoutl.jar
      slf4j-api-1.5.8.jar
      slf4j-log4j12-1.5.8.jar
      stax-api-1.0.1.jar
      wstx-asl-3.2.9.jar
      xercesImpl-2.7.1.jar
      xmlparserv2.jar


      Thanks for your help.

      Cyril.
        • 1. Re: java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite
          694433
          Hi Cyril,
          I think these .jar files must be in your classpath to be used. Try and let us know the issue.
          Good luck
          Dacko
          • 2. Re: java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite
            896511
            Hi Dacko,

            it's not a problem of classpath ....

            I'm trying with
            arq-2.8.8.jar
            or
            arq-2.8.7.jar
            or
            arq-2.8.6.jar

            and it's only ok with the arq-2.8.5.jar version.

            In the last documentation of Oracle with Jena 2.6.4, we have this information :

            -----
            Note that Jena 2.6.4 comes with ARQ version 2.8.7 (arq-2.8.7.jar); however, this version of the Jena Adapter actually requires a newer ARQ version (arq-2.8.8.jar). You can download arq-2.8.8.jar from http://sourceforge.net/projects/jena/files/ARQ/ARQ-2.8.8/arq-2.8.8.zip/download and unzip it to a temporary directory. Remove the arq-2.8.7.jar file from <Jena_DIR>/Jena-2.6.4/lib/, and copy arq-2.8.8.jar from the temporary directory into <Jena_DIR>/Jena-2.6.4/lib/.
            -----


            But with the arq-2.8.8.jar, I have this error NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite

            Some news ?

            Thanks.

            Cyril.
            • 3. Re: java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite
              896511
              Dacko,

              An other information.

              On the first thread of this forum :"Announcement: Announcing Jena Adapter for Oracle Database 11g Release 2 (11.2.0.3)"

              https://forums.oracle.com/forums/ann.jspa?annID=1690

              they said :

              -----
              +The Jena Adapter Release 11.2.0.3 requires Oracle Database 11.2.0.3 (or release 11.2.0.2 and patch 9825019: SEMANTIC TECHNOLOGIES 11G R2 FIX BUNDLE 3 for release 11.2.0.2), ARQ 2.8.8, Jena 2.6.4, Joseki 3.4.4, and JDK 1.6. It includes the enhancements in release 11.2.0.2 and adds more enhancements, including support for: named graphs for Java APIs and Joseki Web service endpoints, SPARQL 1.1, options for entailment calls, analytical functions for RDF data, improved OntModel support, JSON format support for SPARQL query responses and virtual models. The same SPARQL Gateway feature as that in Release 11.2.0.2 is included as well.+
              -----
              But I have this error message with ARQ 2.8.8.

              Thanks for your help.

              Cyril.
              • 4. Re: java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite
                alwu-Oracle
                Hi Cyril,

                Just to be 100% sure, which version of Jena Adapter are you using (what is the size of the sdordfclient.jar)?

                Thanks,

                Zhe
                • 5. Re: java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite
                  896511
                  Hello,

                  I tested with the last version of sdordfclient.jar, and now, it's ok.

                  Very sorry for this mistakes.

                  I think that it's the moment to add the version number in the name of the .jar files

                  Something like sdordfclient-11.2.0.3.jar ?

                  Sorry again and thanks for your help.

                  Regards

                  Cyril
                  • 6. Re: java.lang.NoClassDefFoundError: com/hp/hpl/jena/sparql/algebra/opt/Rewrite
                    alwu-Oracle
                    Hi,

                    That is good news. I like the idea of using something like sdordfclient-11.2.0.3.jar. We will take that into consideration for our next release.

                    Thanks

                    Zhe Wu
                    • 7. Re: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
                      901795
                      can anybody suggest..!! please..why this error is coming while i run this
                      package javaapplication2;

                      import oracle.spatial.rdf.client.jena.*;
                      import com.hp.hpl.jena.rdf.model.Model;
                      import com.hp.hpl.jena.graph.*;
                      import com.hp.hpl.jena.query.*;

                      public class test {

                      public static void main(String[] args) throws Exception
                      {

                           
                      Oracle oracle = new Oracle("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
                      Model model = ModelOracleSem.createOracleSemModel(
                      oracle, "M1");

                      model.getGraph().add(Triple.create(
                      Node.createURI("http://example.com/John"),
                      Node.createURI("http://example.com/fatherOf"),
                      Node.createURI("http://example.com/Mary")));

                      Query query = QueryFactory.create(
                      "select ?f ?k WHERE {?f <http://example.com/fatherOf> ?k .}");
                      QueryExecution qexec = QueryExecutionFactory.create(query, model);
                      ResultSet results = qexec.execSelect();
                      ResultSetFormatter.out(System.out, results, query);

                      model.close();
                      oracle.dispose();
                      }

                      Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
                           at com.hp.hpl.jena.rdf.model.impl.PropertyImpl.<clinit>(PropertyImpl.java:61)
                           at com.hp.hpl.jena.rdf.model.ResourceFactory$Impl.createProperty(ResourceFactory.java:244)
                           at com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty(ResourceFactory.java:120)
                           at com.hp.hpl.jena.vocabulary.RDF.property(RDF.java:32)
                           at com.hp.hpl.jena.vocabulary.RDF.<clinit>(RDF.java:45)
                           at com.hp.hpl.jena.sparql.ARQConstants.<clinit>(ARQConstants.java:27)
                           at com.hp.hpl.jena.query.ARQ.<clinit>(ARQ.java:61)
                           at oracle.spatial.rdf.client.jena.GraphOracleSem.<clinit>(GraphOracleSem.java:275)
                           at oracle.spatial.rdf.client.jena.ModelOracleSem.createOracleSemModel(ModelOracleSem.java:75)
                           at javaapplication2.test.main(test.java:16)
                      Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
                           at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
                           at java.security.AccessController.doPrivileged(Native Method)
                           at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
                           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
                           at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

                      Edited by: 898792 on 23-Nov-2011 04:48
                      • 8. Re: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
                        JorgeB-Oracle
                        Hi,

                        I think somehow your compilation is reaching old version of Jena (jena-2.5.X.jar, ) These versions have a dependency on:

                        org.apache.commons.logging.Log
                        org.apache.commons.logging.LogFactory

                        as described here: (Go to imports section)

                        http://www.jarvana.com/jarvana/view/com/hp/hpl/jena/jena/2.5.4/jena-2.5.4.jar!/com/hp/hpl/jena/rdf/model/impl/PropertyImpl.class?classDetails=ok

                        Since jena-2.6.0 there is no dependency on org.apache.commons because now this version uses

                        org.slf4j.Logger
                        org.slf4j.LoggerFactory

                        which should be in slf4j-log4j12-1.5.8.jar

                        http://www.jarvana.com/jarvana/view/com/hp/hpl/jena/jena/2.6.0/jena-2.6.0.jar!/com/hp/hpl/jena/rdf/model/impl/PropertyImpl.class?classDetails=ok

                        The top level of descriptions are here:

                        http://www.jarvana.com/jarvana/search?search_type=class&java_class=com.hp.hpl.jena.rdf.model.impl.PropertyImpl

                        Regards!
                        Jorge
                        • 9. Re: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
                          JorgeB-Oracle
                          Correction,

                          the imports
                          org.slf4j.Logger
                          org.slf4j.LoggerFactory

                          are not in slf4j-log4j12-1.5.8.jar

                          They are in slf4j-api-1.5.8.jar

                          To fix the java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
                          just make sure you have jena-2.6.4.jar if using the latest sdordfclient.jar

                          Regards!
                          Jorge