usc-isi-i2 / Web-Karma

Information Integration Tool

Home Page:http://www.isi.edu/integration/karma/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An exception occured to gerate rdf from mysql when executing Java class. edu.isi.karma.rdf.OfflineRdfGenerator

zhoushaokun opened this issue · comments

Describe the bug
cant generate rdf from mysql databases by r2rml model. The error main about program cant exec the OfflineRdfGenerator class.
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1:java (default-cli) on project karma-offline: An exception occured while executing the Java class. edu.isi.karma.rdf.OfflineRdfGenerator

To Reproduce
I follow the README.md to generate rdf file from r2rml file by karma-offline.

To generate RDF of a database table, go to the top level Karma directory and run the following command from terminal:
cd karma-offline
mvn exec:java -Dexec.mainClass="edu.isi.karma.rdf.OfflineRdfGenerator" -Dexec.args="--sourcetype DB
--modelfilepath --outputfile --dbtype --hostname
--username --password --portnumber --dbname --tablename --JSONOutputFile" -Dexec.classpathScope=compile
Valid argument values for dbtype are Oracle, MySQL, SQLServer, PostGIS, Sybase. Example invocation:
mvn exec:java -Dexec.mainClass="edu.isi.karma.rdf.OfflineRdfGenerator" -Dexec.args="
--sourcetype DB --dbtype SQLServer
--hostname example.com --username root --password secret
--portnumber 1433 --dbname Employees --tablename Person
--modelfilepath "/Users/shubhamgupta/Documents/db-r2rml-model.ttl"
--outputfile db-rdf.n3
--JSONOutputFile db-rdf.json" -Dexec.classpathScope=compile
You can do mvn exec:java -Dexec.mainClass="edu.isi.karma.rdf.OfflineRdfGenerator" -Dexec.args="--help" to get information about required arguments.

I followed the

  1. source install
  2. add the depency of mysql in outer web-karma and inner karma-jdbc karma-offline's pom.xml file.
  3. mvn clean install in web-karma dir
  4. cd karma-offline and run the generate rdf command
  5. See error

image

Expected behavior
can generate the right rdf file which extracts from mysql.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [win 10 and unbuntu 18 all went wrong]
  • Browser [no use browser]
  • Version [master branch in github]
  • marven version [Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)]
  • jdk version [Java version: 1.7.0_221, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-7-openjdk-amd64/jre]

Additional context
addtionally, i have tried to cd karma-offline and run the command of " mvn install -P shaded " in #258 (comment) , however in the targe dir the classes dir is temp, so when i run the command like followings:

java -cp karma-offline-0.0.1-SNAPSHOT-shaded.jar edu.isi.karma.rdf.OfflineRdfGenerator --sourcetype CSV --filepath "datos.csv" --modelfilepath "modelo.ttl" --sourcename datos --outputfile exportado.ttl

i went wrong, which error is: "Error: Could not find or load main class edu.isi.karma.rdf.OfflineRdfGenerator".

i will appreciate it if any guys can give me help.


and i make a mirror of docker which is https://hub.docker.com/r/isikies/karma-offline-error

Hi,
After the command " mvn install -P shaded ", please run " cd target " and then run the following command:
" java -cp karma-offline-0.0.1-SNAPSHOT-shaded.jar edu.isi.karma.rdf.OfflineRdfGenerator --sourcetype CSV --filepath "datos.csv" --modelfilepath "modelo.ttl" --sourcename datos --outputfile exportado.ttl "

The above error: "Error: Could not find or load main class edu.isi.karma.rdf.OfflineRdfGenerator" is generated because the jar file is not present in the same directory as from where the command is being run.

Ok thank you for your reply.
I tried to cd target, but i still went wrong. And when i change jdk version to 8, i can "exec the OfflineRdfGenerator class." but occured the error of followings

ERROR [2020-11-30 10:20:32,742] (KR2RMLWorksheetRDFGenerator->generateRDF->194): Unable to find DAG for RDF Generation!
java.lang.NullPointerException
at edu.isi.karma.kr2rml.planning.WorksheetDepthRootStrategy.findRoot(WorksheetDepthRootStrategy.java:46)
at edu.isi.karma.kr2rml.planning.SteinerTreeRootStrategy.findRoot(SteinerTreeRootStrategy.java:44)
at edu.isi.karma.kr2rml.planning.TriplesMapGraph.findRoot(TriplesMapGraph.java:130)
at edu.isi.karma.kr2rml.planning.DFSTriplesMapGraphDAGifier.dagify(DFSTriplesMapGraphDAGifier.java:54)
at edu.isi.karma.kr2rml.KR2RMLWorksheetRDFGenerator.generateRDF(KR2RMLWorksheetRDFGenerator.java:190)
at edu.isi.karma.rdf.DatabaseTableRDFGenerator.generateRDFFromWorksheet(DatabaseTableRDFGenerator.java:230)
at edu.isi.karma.rdf.DatabaseTableRDFGenerator.generateRDF(DatabaseTableRDFGenerator.java:202)
at edu.isi.karma.rdf.DatabaseTableRDFGenerator.generateRDFFromTable(DatabaseTableRDFGenerator.java:115)
at edu.isi.karma.rdf.OfflineRdfGenerator.generateRdfFromDatabaseTable(OfflineRdfGenerator.java:419)
at edu.isi.karma.rdf.OfflineRdfGenerator.generateRDF(OfflineRdfGenerator.java:178)
at edu.isi.karma.rdf.OfflineRdfGenerator.generate(OfflineRdfGenerator.java:164)
at edu.isi.karma.rdf.OfflineRdfGenerator.main(OfflineRdfGenerator.java:150)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:290)
at java.lang.Thread.run(Thread.java:748)

I think it may caused by wrong ontology file and the inproper export model file. I will go deeper to modify my ontology file and find out the reason. In short, the jdk version may be the key to the question, so I suggest that we can give the detail explanation as precise as possible in https://github.com/usc-isi-i2/Web-Karma/wiki/Installation%3A-Source-Code
turtorial If it is really related to jdk version. Hope karma will be better and better.

This problem must because my inproper mapping mode file. I tried to correct the model file and the things go well (branch development and souce code install manner).
Anyway, I found when checking out the development branch and run the code by "cd karma-web && mvn jetty:run ", there is no more problems in the web page which sometimes cannot import rdf or cannot import ontology file in other karma version. Most importantly the souce code install manner is very fast and really amazing.