Hi,

I opted for the third solution. But I still need your help.

Here is the error I am getting when I execute my final jar:

java -jar target/my-app-1.0-SNAPSHOT-jar-with-dependencies.jar
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mycompany.app.RdfWriter.main(RdfWriter.java:13)
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:248)
at org.apache.jena.tdb.sys.InitTDB.start(InitTDB.java:29)
at org.apache.jena.system.JenaSystem.lambda$init$2(JenaSystem.java:119)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:194)
at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:171)
at org.apache.jena.system.JenaSystem.init(JenaSystem.java:117)
at org.apache.jena.rdf.model.ModelFactory.<clinit>(ModelFactory.java:49)
... 1 more

I am using maven-assembly-plugin to include all dependencies in the final
jar.

Before running the jar I  used these 2 commans (successfully) after
removing everything from my .m2 folder:

mvn clean install
mvn clean compile assembly:single

And then  I run this command that gives me the error above:

java -jar target/my-app-1.0-SNAPSHOT-jar-with-dependencies.jar


Thank you




On Sun, Jan 29, 2017 at 4:46 AM, Lorenz B. <
[email protected]> wrote:

> That doesn't work because only your own classes are in the classpath then.
>
> Options:
>
> 1) Add all necessary JAR files from the Jena distribution to the classpath
> 2) Use the Maven exec plugin from the command line
> 3) build a fat JAR that also contains the classes of the Maven dependencies
> > Hi,
> >
> > I am trying to do the first example of the jena rdf tutorial.
> > It seems that the class is not found even the maven build was successful.
> >
> > Here is my class code:
> >
> > package com.mycompany.app;
> >
> > import org.apache.jena.rdf.model.*;
> > import org.apache.jena.vocabulary.*;
> >
> > public class RdfWriter {
> >     static String personURI    = "http://somewhere/JohnSmith";;
> >     static String fullName     = "John Smith";
> >
> > public static void main(String[] args) {
> > //        // create an empty model
> >         Model model = ModelFactory.createDefaultModel();
> > //       // create the resource
> > //       Resource johnSmith = model.createResource(personURI);
> > //      // add the property
> > //      johnSmith.addProperty(VCARD.FN, fullName);
> > System.out.println("this is rdf writer");
> > }
> >
> > }
> >
> > I am running it like this:
> >
> > java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.RdfWriter
> >
> > And here is my pom file:
> >
> > <project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance";
> >   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd";>
> >   <modelVersion>4.0.0</modelVersion>
> >   <groupId>com.mycompany.app</groupId>
> >   <artifactId>my-app</artifactId>
> >   <packaging>jar</packaging>
> >   <version>1.0-SNAPSHOT</version>
> >   <name>my-app</name>
> >   <url>http://maven.apache.org</url>
> >
> >   <properties>
> >     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >   </properties>
> >
> >   <dependencies>
> >     <dependency>
> >       <groupId>junit</groupId>
> >       <artifactId>junit</artifactId>
> >       <version>3.8.1</version>
> >       <scope>test</scope>
> >     </dependency>
> >     <dependency>
> >         <groupId>org.apache.jena</groupId>
> >         <artifactId>apache-jena-libs</artifactId>
> >         <version>3.1.1</version>
> >         <type>pom</type>
> >     </dependency>
> >   </dependencies>
> > </project>
> >
> > Here is the full error that I get:
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/apache/jena/rdf/model/ModelFactory
> > at com.mycompany.app.RdfWriter.main(RdfWriter.java:13)
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.jena.rdf.model.ModelFactory
> > at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> > ... 1 more
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>

Reply via email to