- From: Andy Seaborne <andy@seaborne.org>
- Date: Mon, 6 Dec 2021 12:19:03 +0000
- To: public-rdf-ruby@w3.org
For Jena, we don't use assemblies - we use the shade pluguin. Maybe jar-with-dependencies has a similar feature. If you are shading to get the jar, https://jena.apache.org/documentation/notes/jena-repack.html it needs the services files merged. <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> ... other transformers ... </transformers> which merges the META-INF/services/org.apache.jena.sys.JenaSubsystemLifecycle files from each dependency and they drive initialization (java's ServiceLoader) See for example: https://github.com/apache/jena/blob/0a96c6fd1ecac9ffd68d33b536b2d1ce7fd334b6/jena-fuseki2/jena-fuseki-server/pom.xml#L78 Andy On 06/12/2021 08:23, Daniel Hernandez wrote: > > Daniel Hernandez <daniel@degu.cl> writes: > >> I followed your sugestion, but I had the same issue. To make the issue >> reproducible, I published the code in: >> >> https://github.com/danielhz/test-OpAsQuery >> >> Daniel > > The code works inside vscode, but not with the jar. So, I guess that it > is an issue in the way I am creating the jar file. I am going to review > the pom file, because it could be a problem with managing dependencies. > > Daniel > > >> Andy Seaborne <andy@seaborne.org> writes: >> >>> Works for me in a single file but it looks like missed initialization >>> or in the wrong order and Java is complicated in the os static class >>> initialization. >>> >>> Could you try with >>> >>> public static void main( String[] args ) { >>> JenaSystem.init(); >>> .... >>> } >>> >>> please >>> >>> Andy >>> >>> On 05/12/2021 19:39, Daniel Hernandez wrote: >>>> Hi Andy, >>>> Andy Seaborne <andy@seaborne.org> writes: >>>>> Jena tries to - it's quite pragmatic: >>>>> >>>>> https://github.com/apache/jena/blob/main/jena-arq/src/main/java/org/apache/jena/sparql/algebra/OpAsQuery.java >>>>> >>>>> Andy >>>> When I was reviewing the OpAsQuery implementaion in Jena, and I had >>>> a >>>> problem: It works with some S-expressions, but fails with others. My >>>> testing code includes the following files: >>>> File 1: >>>> package cl.degu.sparql; >>>> import org.apache.jena.query.Query; >>>> import org.apache.jena.sparql.algebra.OpAsQuery; >>>> import org.apache.jena.sparql.algebra.Algebra; >>>> public class SSEtoSPARQL { >>>> public static Query translate(String sse) { >>>> return OpAsQuery.asQuery(Algebra.parse(sse)); >>>> } >>>> } >>>> FILE 2: >>>> package cl.degu.sparql; >>>> public class App >>>> { >>>> public static void main( String[] args ) >>>> { >>>> String sse; >>>> // First example >>>> sse = "(project ?s (bgp (triple ?s ?p ?c)))"; >>>> System.out.println(SSEtoSPARQL.translate(sse)); >>>> // Second example >>>> sse = "(project ?s (bgp (triple ?s <http://example.org> ?c)))"; >>>> System.out.println(SSEtoSPARQL.translate(sse)); >>>> } >>>> } >>>> The first example works, but the second example produces an >>>> error. The >>>> output of the main function is the following: >>>> SELECT ?s >>>> WHERE >>>> { ?s ?p ?c } >>>> Exception in thread "main" java.lang.ExceptionInInitializerError >>>> at org.apache.jena.sparql.sse.lang.ParseHandlerPlain.emitIRI(ParseHandlerPlain.java:165) >>>> at org.apache.jena.sparql.sse.lang.ParseHandlerResolver.emitIRI(ParseHandlerResolver.java:150) >>>> at org.apache.jena.sparql.sse.lang.ParserSSEBase.emitIRI(ParserSSEBase.java:46) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.IRIref(SSE_ParserCore.java:277) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.RDFTerm(SSE_ParserCore.java:230) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.Term(SSE_ParserCore.java:217) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.TermOrList(SSE_ParserCore.java:62) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.BareList(SSE_ParserCore.java:194) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.List(SSE_ParserCore.java:108) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.TermOrList(SSE_ParserCore.java:80) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.BareList(SSE_ParserCore.java:194) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.List(SSE_ParserCore.java:108) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.TermOrList(SSE_ParserCore.java:80) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.BareList(SSE_ParserCore.java:194) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.List(SSE_ParserCore.java:108) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.TermOrList(SSE_ParserCore.java:80) >>>> at org.apache.jena.sparql.sse.lang.parser.SSE_ParserCore.parse(SSE_ParserCore.java:34) >>>> at org.apache.jena.sparql.sse.lang.SSE_Parser.parse$(SSE_Parser.java:47) >>>> at org.apache.jena.sparql.sse.lang.SSE_Parser.parse(SSE_Parser.java:40) >>>> at org.apache.jena.sparql.sse.SSE.parse(SSE.java:452) >>>> at org.apache.jena.sparql.sse.SSE.parse(SSE.java:373) >>>> at org.apache.jena.sparql.sse.SSE.parse(SSE.java:368) >>>> at org.apache.jena.sparql.algebra.Algebra.parse(Algebra.java:107) >>>> at cl.degu.sparql.SSEtoSPARQL.translate(SSEtoSPARQL.java:9) >>>> at cl.degu.sparql.App.main(App.java:16) >>>> Caused by: java.lang.NullPointerException >>>> at org.apache.jena.query.ARQ.isTrueOrUndef(ARQ.java:654) >>>> at org.apache.jena.riot.system.RiotLib.<clinit>(RiotLib.java:59) >>>> ... 25 more >>>> I included Jena into the project with the following dependency: >>>> <dependency> >>>> <groupId>org.apache.jena</groupId> >>>> <artifactId>apache-jena-libs</artifactId> >>>> <version>4.2.0</version> >>>> <type>pom</type> >>>> </dependency> >>>> >>>> Daniel >>>> >
Received on Monday, 6 December 2021 12:19:18 UTC