On 31/10/16 06:24, [email protected] wrote:
Hi - I'm trying to use the JDBC driver with Teiid in a JBoss environment.
I have a query that will execute fine (redacted)
prefix example: <http://semanticweb.com/entity#>
select DISTINCT *
{?a example:hasName ?b . } LIMIT 100
But when I add a filter as below, it breaks with
java.lang.NoClassDefFoundError: Could not initialize class
org.apache.jena.sparql.expr.NodeValue
prefix example: <http://semanticweb.com/entity#>
select DISTINCT *
{?a example:hasName ?b . FILTER regex(?b, "value", "i") } LIMIT 100
It's interesting how I can make queries without a FILTER clause, it doesn't
seem to be syntax, but I could be mistaken?
The problem is not the query. It's to do with system initialization ...
see below.
Caused by: java.sql.SQLException: Not a valid SPARQL query/update
at
org.apache.jena.jdbc.statements.JenaStatement.execute(JenaStatement.java:273)
at
org.jboss.jca.adapters.jdbc.WrappedStatement.execute(WrappedStatement.java:182)
at
org.teiid.translator.jdbc.JDBCDirectQueryExecution.execute(JDBCDirectQueryExecution.java:83)
... 17 more
Caused by: org.apache.jena.query.QueryParseException: Could not initialize
class org.apache.jena.sparql.expr.NodeValue
at
org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
at
org.apache.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:52)
at
org.apache.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
at
org.apache.jena.query.QueryFactory.parse(QueryFactory.java:147)
at
org.apache.jena.query.QueryFactory.create(QueryFactory.java:79)
at
org.apache.jena.query.QueryFactory.create(QueryFactory.java:52)
at
org.apache.jena.query.QueryFactory.create(QueryFactory.java:40)
at
org.apache.jena.jdbc.statements.JenaStatement.execute(JenaStatement.java:266)
... 19 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class
org.apache.jena.sparql.expr.NodeValue
This indicates an initialization problem.
at
org.apache.jena.sparql.util.ExprUtils.nodeToExpr(ExprUtils.java:56)
at
org.apache.jena.sparql.lang.ParserBase.asExpr(ParserBase.java:410)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.PrimaryExpression(SPARQLParser11.java:3865)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.UnaryExpression(SPARQLParser11.java:3772)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.MultiplicativeExpression(SPARQLParser11.java:3639)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.AdditiveExpression(SPARQLParser11.java:3537)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.NumericExpression(SPARQLParser11.java:3530)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.RelationalExpression(SPARQLParser11.java:3490)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.ValueLogical(SPARQLParser11.java:3455)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.ConditionalAndExpression(SPARQLParser11.java:3434)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.ConditionalOrExpression(SPARQLParser11.java:3413)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.Expression(SPARQLParser11.java:3406)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.BrackettedExpression(SPARQLParser11.java:3900)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.Constraint(SPARQLParser11.java:2177)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.Filter(SPARQLParser11.java:2168)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.GraphPatternNotTriples(SPARQLParser11.java:1856)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.GroupGraphPatternSub(SPARQLParser11.java:1738)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.GroupGraphPattern(SPARQLParser11.java:1675)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.WhereClause(SPARQLParser11.java:431)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.SelectQuery(SPARQLParser11.java:124)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.Query(SPARQLParser11.java:29)
at
org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.QueryUnit(SPARQLParser11.java:20)
at
org.apache.jena.sparql.lang.ParserSPARQL11$1.exec(ParserSPARQL11.java:48)
at
org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:97)
... 26 more
My Teiid module.xml definition is below, maybe I'm missing a class ? Seems like
I am from the message, but I couldn't find the class.
(I also did try the : jena-jdbc-driver-bundle-3.1.0.jar without the individual
declares but same behavior)
(I have not used Teiid / JBoss)
Jena uses the Java platform ServiceLoader to initialize the various
components. Each component has a
META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle
file. jena-core and jena-arq both have one and they are different.
If there is any repackaging of the bianries going on, then the
JenaSubsystemLifecycle files need to be combined.
For example, if using the maven-shade-plugin:
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"
/>
I checked and the jena-jdbc-driver-bundle does not set up the
ServiceLoader services correctly. We'll fix that.
But I don't immediately see why using the jars directly does not work,
but that's due to my lack of knowledge about Teiid and JBoss.
Is there any repackaging going on?
Andy
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.apache.jena">
<resources>
<resource-root path="jena-jdbc-core-3.1.0.jar"/>
<resource-root path="jena-jdbc-driver-remote-3.1.0.jar"/>
<resource-root path="jena-arq-3.1.0.jar"/>
<resource-root path="jena-core-3.1.0.jar"/>
<resource-root path="jena-base-3.1.0.jar"/>
<resource-root path="jena-cmds-3.1.0.jar"/>
<resource-root path="jena-shaded-guava-3.1.0.jar"/>
<resource-root path="log4j-1.2.17.jar"/>
<resource-root path="slf4j-api-1.7.20.jar"/>
<resource-root path="slf4j-log4j12-1.7.20.jar"/>
<resource-root path="xml-apis-1.4.01.jar"/>
<resource-root path="xercesImpl-2.11.0.jar"/>
<resource-root path="jena-iri-3.1.0.jar"/>
<resource-root path="httpcore-4.2.5.jar"/>
<resource-root path="httpclient-4.2.6.jar"/>
<resource-root path="httpclient-cache-4.2.6.jar"/>
<resource-root path="commons-io-2.4.jar"/>
<resource-root path="commons-cli-1.3.jar"/>
<resource-root path="commons-lang3-3.3.2.jar"/>
<resource-root path="commons-codec-1.9.jar"/>
<resource-root path="commons-csv-1.0.jar"/>
<resource-root path="collection-0.6.jar"/>
<resource-root path="jcl-over-slf4j-1.7.20.jar"/>
<resource-root path="jackson-annotations-2.3.0.jar"/>
<resource-root path="jackson-core-2.3.3.jar"/>
<resource-root path="jackson-databind-2.3.3.jar"/>
<resource-root path="libthrift-0.9.2.jar"/>
<resource-root path="jsonld-java-0.7.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>