-1

I have the following code running in my project as i am trying to access the repositories in the sesame server:

   try{
    String serverUrl = "http://localhost:8080/openrdf-sesame";
    String repositoryID ="200"; 
     RepositoryProvider.getRepositoryManager(serverUrl);
     Repository myRepository =new HTTPRepository(serverUrl,repositoryID);
                myRepository.initialize();
                RepositoryConnection con= myRepository.getConnection();
    }

I have even used the debug to locate where the error comes from but it seesm its coming from:

    RepositoryConnection con= myRepository.getConnection();

When i run the code the get the following error.

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NoSuchMethodError: org.openrdf.model.impl.ValueFactoryImpl.getInstance()Lorg/openrdf/model/impl/ValueFactoryImpl;

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.
Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
Kinuthia
  • 61
  • 10
  • possible duplicate of [How do I fix a NoSuchMethodError?](http://stackoverflow.com/questions/35186/how-do-i-fix-a-nosuchmethoderror) – Jeen Broekstra Jan 25 '15 at 18:45

1 Answers1

0

A NoSuchMethodError usually indicates that you are running your program with a different version of a library than you used to compile it with. A common cause is that your runtime classpath contains more than one version of the same library, and the JRE picks "the wrong one".

Since the error in this case happens on the server side, you should look at your GlassFish deployment, and make sure it does not contain more than one version of the Sesame libraries.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
  • I've tried following the error but when i open the org.openrdf.model.impl.ValueFactoryImpl there is no getInstance() method and i don't know why getConnection() is calling getInstance() – Kinuthia Jan 25 '15 at 21:06
  • Because you are using the wrong version of the sesame library (or libraries). ValueFactoryImpl _does_ have a static `getInstance()` method, if your copy doesn't, that means you're using a very old version. – Jeen Broekstra Jan 25 '15 at 21:10
  • Generally speaking, you should probably have a good look at your project setup, and check that you are including the correct versions of libraries (and not including any old/obsolete versions). – Jeen Broekstra Jan 25 '15 at 21:11
  • I have updated to the latest version of sesame-model-2.8.0-beta2.jar and i have checked that the method indeed exists. But still i am getting the same error message. – Kinuthia Jan 26 '15 at 03:42
  • Are you actually checking the version of Sesame running on the (Glassfish) server? Because as I said before: it is that which is causing the error, according to the error message, _not_ the version of Sesame you use in your own (client) program. And to repeat: you need to _also_ check that no older version of Sesame is included somewhere. Different versions of the same library on the classpath are a common cause for this error. – Jeen Broekstra Jan 26 '15 at 04:33
  • How do i check the version of Sesame running on the (Glassfish) server? – Kinuthia Jan 26 '15 at 16:57