Antus
Antus

Reputation: 1

org.eclipse.rdf4j.rio.UnsupportedRDFormatException for Turtle format

I'm facing a problem using RDF4J, as I get "org.eclipse.rdf4j.rio.UnsupportedRDFormatException: Did not recognise RDF format object Turtle" error. Following https://stackoverflow.com/a/40920378/17731560 and https://stackoverflow.com/a/23364261/17731560 I reconfigured my Maven pom.xml file as follows:

        <!-- Set a compiler level -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

        <!-- Copy project dependency -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.5.1</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <!-- exclude junit, we need runtime and system dependency only -->
                        <outputDirectory>${project.build.directory}/libs/</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

In this way will my problem be solved? Thanks in advance, I'm new to Maven

Upvotes: 0

Views: 686

Answers (1)

Jeen Broekstra
Jeen Broekstra

Reputation: 22053

It's not really possible to tell if this will fix your problem, because the snippet of your pom doesn't show anything about how you're including RDF4J into your project, or how you're running your project. Certainly how you've configured the dependency plugin looks fishy to me - I've never seen that in use, and it's not something you should need unless you have very specific requirements.

The error you're seeing indicates that the Rio Turtle parser can not be found. The most likely cause is that you didn't include the right dependencies. An alternative problem is mentioned in the first question you link to, specifically about the situation where people produce a "fat jar" (a single jar file containing all code from all dependencies) without getting the SPI registry files merged properly. It's not clear from your description which situation applies, but since you're new to Maven, I will for now assume that you are not producing a fat jar (because this is not something most Maven projects do).

In general, the simplest way to include RDF4J in your Java project is to include one of two available pom dependencies (as explained in https://rdf4j.org/documentation/programming/setup/):

<dependency>
  <groupId>org.eclipse.rdf4j</groupId>
  <artifactId>rdf4j-storage</artifactId>
  <version>3.7.4</version>
  <type>pom</type>
</dependency>

or, if you only need the parsers and client APIs, not the full set of databases:

<dependency>
  <groupId>org.eclipse.rdf4j</groupId>
  <artifactId>rdf4j-client</artifactId>
  <version>3.7.4</version>
  <type>pom</type>
</dependency>

Either of these will automatically also include the rdf4j-rio-turtle dependency, which contains the Turtle parser implementation.

Having said all that, you also have this in your config:

            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>

You've configured your project to use Java 7 (1.7), but RDF4J requires Java 8 (1.8) at a minimum. It's possible it simply doesn't work because of that (and even if that isn't the cause of this specific error, other things will break too). You'll need to upgrade to Java 8 or better (we recommend Java 11 at a minimum for best performance).

Upvotes: 0

Related Questions