java.lang.NoSuchMethodError: org.openrdf.model.IRI.stringValue()Ljava/lang/String;


(Frederico) #1

I followed the tutorial dictionary linker and created the Class CreateLinker.

import java.io.File;
import java.io.IOException;
import com.complexible.stardog.docs.nlp.impl.DictionaryLinker;
import com.google.common.collect.ImmutableMultimap;
import org.openrdf.model.IRI;
import static com.complexible.common.rdf.model.Values.iri;

public class CreateLinker {

	public static void main(String[] args) throws IOException {
		ImmutableMultimap<String, IRI> aDictionary = ImmutableMultimap.<String, IRI>builder()
			                                             .putAll("Tom Hanks", iri("https://en.wikipedia.org/wiki/Tom_Hanks"), iri("http://www.imdb.com/name/nm0000158"))
			                                             .build();

		DictionaryLinker.Linker aLinker = new DictionaryLinker.Linker(aDictionary);

		aLinker.to(new File("/Users/fredsantos/npl/npl/src/main/java/npl/TomHanks.linker"));
	}
}

When I run it I get the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: org.openrdf.model.IRI.stringValue()Ljava/lang/String;
	at com.complexible.stardog.docs.nlp.impl.DictionaryLinker$LinkerSerializer.write(DictionaryLinker.java:167)
	at com.complexible.stardog.docs.nlp.impl.DictionaryLinker$LinkerSerializer.write(DictionaryLinker.java:156)
	at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:651)
	at com.complexible.stardog.docs.nlp.impl.DictionaryLinker$Linker.to(DictionaryLinker.java:147)
	at npl.CreateLinker.main(CreateLinker.java:19)

(Jess Balint) #2

Hi Frederico,

How did you setup your classpath?


(Frederico) #3

Please find attached my Java Build Path.


(Jess Balint) #4

Are you using Maven? Can you share your POM file?


(Frederico) #5
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>npl</groupId>
  <artifactId>npl</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <repositories>
    <repository>
      <id>stardog-public</id>
      <url>http://maven.stardog.com</url>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>org.apache.opennlp</groupId>
      <artifactId>opennlp-tools</artifactId>
      <version>1.6.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.opennlp</groupId>
      <artifactId>opennlp-uima</artifactId>
      <version>1.6.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-csv</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>com.google.collections</groupId>
      <artifactId>google-collections</artifactId>
      <version>1.0-rc2</version>
    </dependency>
    <dependency>
      <groupId>org.openrdf</groupId>
      <artifactId>openrdf-model</artifactId>
      <version>1.2.7</version>
    </dependency>
    <dependency>
      <groupId>com.complexible.stardog</groupId>
      <artifactId>server</artifactId>
      <version>5.3.4</version>
      <type>pom</type>
    </dependency>
    <dependency>
      <groupId>com.complexible.stardog</groupId>
      <artifactId>client-http</artifactId>
      <version>5.3.4</version>
      <type>pom</type>
    </dependency>
  </dependencies>
</project>

(Jess Balint) #6

Thanks for sharing that. It looks like you've added a dependency on a very old version of Sesame:

    <dependency>
      <groupId>org.openrdf</groupId>
      <artifactId>openrdf-model</artifactId>
      <version>1.2.7</version>
    </dependency>

Is that required for your application? It's conflicting with the version present in Stardog.


(Frederico) #7

Thanks Jess,

I removed that dependency and it worked!

Thank you very much!