> But in my assembly jar, I still have the
> org.apache.jena.system.JenaSubsystemLifecycle file. How to make it
> works as well with assembly jars?

Using an assembly to make a combined jar? I've not tried. It will need somewhat to combine the service files into one - the transformer is basically concatenating the contents of each file. Somehow, the same process needs to happen. The shade plugin seems to make such things easier.

    Andy



On 05/02/16 11:41, Julien Plu wrote:
Hi Andy,

Thanks! It indeed now works with the following lines added in my pom:

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-shade-plugin</artifactId>
     <version>1.6</version>
     <configuration>
         <shadedArtifactAttached>false</shadedArtifactAttached>
         <transformers>
             <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                 <mainClass>Test</mainClass>
             </transformer>
             <transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"
/>
         </transformers>
         <filters>
             <filter>
                 <artifact>*:*</artifact>
             </filter>
         </filters>
     </configuration>
     <executions>
         <execution>
             <phase>package</phase>
             <goals>
                 <goal>shade</goal>
             </goals>
         </execution>
     </executions>
</plugin>

And it works with the new non executable jar that the plugin is creating.
But in my assembly jar, I still have the
org.apache.jena.system.JenaSubsystemLifecycle file. How to make it works as
well with assembly jars?

--
Julien Plu

PhD Student at Eurecom.
Personal webpage: http://jplu.developpez.com
FOAF file : http://jplu.developpez.com/julien
Email address : [email protected] && *[email protected]
<[email protected]>*
Phone : +33493008103
Twitter : @julienplu

2016-02-05 11:38 GMT+01:00 Andy Seaborne <[email protected]>:

Hi Julien,

The NPE is happening during system initialization.  It looks like TDB init
running before ARQ init.

Jena now uses ServiceLoader for initialization.  Each jena jar has a
META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle file which
are combined to form the initializationprocess.

My guess is that the combined jar has one services/JenaSubsystemLifecycle
file at random, in this case TDB's.

Combining jars needs to cope with the services files.

We do have a combined jar for Fuseki - the process it uses is to shade
(maven-shade-plugin) the jars together with a specific step to combine
services via ServicesResourceTransformer.  See [*] for details.

If you look in your executable jar, look for the services directory and
check the files there to see if that agrees with the guess above.

     Andy

[*]

https://github.com/apache/jena/blob/master/jena-fuseki2/jena-fuseki-server/pom.xml#L62




On 05/02/16 08:49, Julien Plu wrote:

Hello,

I have an issue to load RDF files only with the new Jena 3.0.1. With this
simple code:

import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.rdf.model.Model;
public class Test {
    public static void main(String[] args) {
      Model model = RDFDataMgr.loadModel("test.nt");
    }
}

Where "test.nt" contains one simple triple:

<http://dbpedia.org/resource/Barack_Obama> <
http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <
http://dbpedia.org/ontology/Person> .

If I compile this code with Maven to build an executable jar and run it
with the command line:

java -jar target/test.jar

I get the following exception:

log4j:WARN No appenders could be found for logger (Jena).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.

Exception in thread "main" java.lang.ExceptionInInitializerError

at

Test.main(Test.java:5)

Caused by: java.lang.NullPointerException

at

org.apache.jena.tdb.sys.EnvTDB.processGlobalSystemProperties(EnvTDB.java:33)

at org.apache.jena.tdb.TDB.init(TDB.java:250)

at org.apache.jena.tdb.sys.InitTDB.start(InitTDB.java:29)

at org.apache.jena.system.JenaSystem.lambda$init$40(JenaSystem.java:114)

at java.util.ArrayList.forEach(ArrayList.java:1249)

at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:179)

at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:156)

at org.apache.jena.system.JenaSystem.init(JenaSystem.java:111)

at org.apache.jena.riot.RDFDataMgr.<clinit>(RDFDataMgr.java:81)

... 2 more
Any idea of what is going wrong?

Thanks in advance.

--
Julien Plu

PhD Student at Eurecom.
Personal webpage: http://jplu.developpez.com
FOAF file : http://jplu.developpez.com/julien
Email address : [email protected] && *[email protected]
<[email protected]>*
Phone : +33493008103
Twitter : @julienplu





Reply via email to