Skip to content

Commit

Permalink
Merge pull request #273 from KonradHoeffner/fix-noclassdef
Browse files Browse the repository at this point in the history
Fix NoClassDefError.
  • Loading branch information
MSherif committed Mar 4, 2022
2 parents e03557a + c7e3407 commit c81fee3
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 65 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ target/
out/
nbactions.xml

# Eclipse
.project
.classpath
.settings

# IntelliJ IDEA #
*.iml
.idea/
Expand Down Expand Up @@ -38,4 +43,8 @@ package-lock.json
/limes-web-ui/node_modules/
# misc
release.properties
cache/
cache/

# dependency tree file generiated via `mvn dependency:tree > deptree.txt`
deptree.txt

58 changes: 39 additions & 19 deletions limes-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.6.1</version>
<version>2.17.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.21</version>
<version>1.7.35</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.21</version>
<version>1.7.35</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -132,30 +132,41 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<version>4.2.0</version>
<version>4.4.0</version>
<type>pom</type>
</dependency>


<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.17.1</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.aksw.jenax</groupId>
<artifactId>jenax-rx-dataaccess</artifactId>
<version>4.4.0-1</version>
</dependency>

<!--
<dependency>
<groupId>org.aksw.jena-sparql-api</groupId>
<artifactId>jena-sparql-api-cache-h2</artifactId>
<version>3.9.0-1</version>
<version>3.17.0-1</version>
<exclusions>
<exclusion>
<groupId>org.aksw.jena-sparql-api</groupId>
<artifactId>jena-sparql-api-resources-test-config</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aksw.jena-sparql-api</groupId>
<artifactId>jena-sparql-api-core</artifactId>
<version>3.9.0-1</version>
<version>3.17.0-1</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand All @@ -171,11 +182,12 @@
</exclusion>
</exclusions>
</dependency>
-->

<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>3.9.0</version>
<version>4.4.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand All @@ -190,7 +202,7 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>3.9.0</version>
<version>4.4.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand All @@ -209,7 +221,7 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-jdbc-driver-mem</artifactId>
<version>3.6.0</version>
<version>4.4.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand All @@ -228,7 +240,7 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-jdbc-driver-remote</artifactId>
<version>3.6.0</version>
<version>4.4.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand All @@ -247,7 +259,7 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-jdbc-driver-tdb</artifactId>
<version>3.6.0</version>
<version>4.4.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -308,7 +320,11 @@
<type>jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>edu.mit</groupId>
<artifactId>jwi</artifactId>
Expand All @@ -335,7 +351,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.2</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -363,6 +379,10 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
*/
package org.aksw.limes.core.controller;

import org.aksw.commons.util.Files;
import static org.fusesource.jansi.Ansi.ansi;
import static org.fusesource.jansi.Ansi.Color.RED;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.function.Function;

import org.aksw.limes.core.evaluation.oracle.OracleFactory;
import org.aksw.limes.core.exceptions.UnsupportedMLImplementationException;
import org.aksw.limes.core.execution.engine.ExecutionEngineFactory;
Expand All @@ -35,18 +42,16 @@
import org.aksw.limes.core.io.serializer.ISerializer;
import org.aksw.limes.core.io.serializer.SerializerFactory;
import org.aksw.limes.core.measures.mapper.MappingOperations;
import org.apache.commons.cli.*;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.lang3.time.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.util.function.Function;

import static org.fusesource.jansi.Ansi.Color.RED;
import static org.fusesource.jansi.Ansi.ansi;

/**
* This is the default LIMES Controller used to run the software as CLI.
*
Expand Down Expand Up @@ -116,9 +121,9 @@ public static void main(String[] args) {
format = cmd.getOptionValue('F');
}
AMapping reference = OracleFactory.getOracle(cmd.getOptionValue('g'), format, "simple").getMapping();
Files.writeToFile(statFile, result.getStatistics(reference), false);
Files.writeString(statFile.toPath(), result.getStatistics(reference));
} else {
Files.writeToFile(statFile, result.getStatistics(), false);
Files.writeString(statFile.toPath(), result.getStatistics());
}
} catch (IOException e) {
logger.error("Error writing JSON statistics file:");
Expand Down Expand Up @@ -204,7 +209,7 @@ static LimesResult getMapping(Configuration config, int limit, ActiveLearningOra
sourceCache = getSubCache.apply(sourceCache);
targetCache = getSubCache.apply(targetCache);
}
// 4. Apply preprocessing
// 4. Apply preprocessing
sourceCache = Preprocessor.applyFunctionsToCache(sourceCache, config.getSourceInfo().getFunctions());
targetCache = Preprocessor.applyFunctionsToCache(targetCache, config.getTargetInfo().getFunctions());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.aksw.limes.core.io.config.KBInfo;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.RDFReader;
import org.apache.jena.rdf.model.RDFReaderI;
import org.apache.jena.riot.RiotNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -60,7 +60,7 @@ public FileQueryModule(KBInfo kbinfo) {
logger.error(MarkerFactory.getMarker("FATAL"),"endpoint could not be loaded as a file or resource");
throw new RuntimeException(e);
}
RDFReader r = model.getReader(kb.getType());
RDFReaderI r = model.getReader(kb.getType());
InputStreamReader reader = new InputStreamReader(in, "UTF8");
r.read(model, reader, null);
reader.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,30 @@
*/
package org.aksw.limes.core.io.query;

import org.aksw.jena_sparql_api.cache.core.QueryExecutionFactoryCacheEx;
import org.aksw.jena_sparql_api.cache.extra.CacheFrontend;
import org.aksw.jena_sparql_api.cache.h2.CacheUtilsH2;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;

import org.aksw.commons.io.cache.AdvancedRangeCacheConfigImpl;
import org.aksw.commons.io.util.PathUtils;
import org.aksw.commons.io.util.UriToPathUtils;
import org.aksw.jena_sparql_api.cache.advanced.QueryExecutionFactoryRangeCache;
import org.aksw.jena_sparql_api.core.FluentQueryExecutionFactory;
import org.aksw.jena_sparql_api.core.QueryExecutionFactory;
import org.aksw.jena_sparql_api.core.SparqlServiceReference;
import org.aksw.jena_sparql_api.pagination.core.QueryExecutionFactoryPaginated;
import org.aksw.jenax.arq.connection.core.QueryExecutionFactory;
import org.aksw.limes.core.io.cache.ACache;
import org.aksw.limes.core.io.config.KBInfo;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.sparql.core.DatasetDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.SQLException;
import java.util.concurrent.TimeUnit;


/**
* @author Mohamed Sherif (sherif@informatik.uni-leipzig.de)
Expand Down Expand Up @@ -79,11 +84,12 @@ public ResilientSparqlQueryModule(KBInfo kbinfo, Logger logger, int retryCount,
*/
public void fillCache(ACache cache, boolean sparql) {
long startTime = System.currentTimeMillis();
String query = generateQuery();
String queryStr = generateQuery();
Query query = QueryFactory.create(queryStr);

logger.info("Querying the endpoint.");
//run query
org.aksw.jena_sparql_api.core.QueryExecutionFactory qef = null;
QueryExecutionFactory qef = null;
try {
qef = initQueryExecution(kb);
} catch (Exception e) {
Expand Down Expand Up @@ -147,30 +153,44 @@ protected QueryExecutionFactory initQueryExecution(KBInfo kbInfo) throws ClassNo

SparqlServiceReference ssr = new SparqlServiceReference(kbInfo.getEndpoint(), dd);

// Since jenax 4.4.0-1 there is a new advanced range cache that unifies caching and pagination

int pageSize = kbInfo.getPageSize();

qef = FluentQueryExecutionFactory
.http(ssr)
.config()
.withRetry(retryCount, retryDelayInMS, TimeUnit.MILLISECONDS)
.withDelay(requestDelayInMs, TimeUnit.MILLISECONDS)
.withPagination(pageSize)
// Only apply pagination if there is a page size
// and no configured cache folder
.compose(internalQef -> pageSize > 0 && cacheDirectory == null
? new QueryExecutionFactoryPaginated(internalQef, pageSize)
: internalQef)
.end()
.create();

if (cacheDirectory != null) {
String dbName = kbInfo.getEndpoint().replaceAll("[:/]", "_");
CacheFrontend cacheFrontend = CacheUtilsH2.createCacheFrontend(dbName, true, timeToLive);
qef = new QueryExecutionFactoryCacheEx(qef, cacheFrontend);
// Javaify the endpoint url - e.g. http://dbpedia.org/sparql becomes org/dbepdia/sparql
String[] pathSegments = UriToPathUtils.toPathSegments(kbInfo.getEndpoint());
Path cacheFolder = PathUtils.resolve(Paths.get(cacheDirectory), pathSegments);

AdvancedRangeCacheConfigImpl cacheConfig = AdvancedRangeCacheConfigImpl.createDefault();
cacheConfig.setMaxRequestSize(pageSize > 0 ? pageSize : Integer.MAX_VALUE);

qef = QueryExecutionFactoryRangeCache.create(qef, cacheFolder, 100, cacheConfig);
} else {
logger.info("The cache directory has not been set. Creating an uncached SPARQL client.");
}

try {
qef = new QueryExecutionFactoryPaginated(qef, pageSize);
return qef;
} catch (Exception e) {
logger.warn("Couldn't create Factory with pagination. Returning Factory without pagination. Exception: " +
e.getLocalizedMessage());
return qef;
}
return qef;
// try {
// qef = new QueryExecutionFactoryPaginated(qef, pageSize);
// return qef;
// } catch (Exception e) {
// logger.warn("Couldn't create Factory with pagination. Returning Factory without pagination. Exception: " +
// e.getLocalizedMessage());
// return qef;
// }
}
}

0 comments on commit c81fee3

Please sign in to comment.