0

I get the following error when trying to run my code.

"C:\Program Files\Java\jdk1.8.0_151\bin\java" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.5\lib\idea_rt.jar=61473:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_151\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\rt.jar;C:\Users\Stefan\Desktop\jmapviewer-2.4\out\production\jmapviewer-2.4;C:\Users\Stefan\Desktop\jmapviewer-2.4\lib\json-20140107.jar;C:\Users\Stefan\Desktop\jmapviewer-2.4\lib\commons-io-2.6.jar;C:\Users\Stefan\Desktop\jmapviewer-2.4\lib\slf4j-api-1.7.25.jar;C:\Users\Stefan\Desktop\jmapviewer-2.4\lib\commons-lang3-3.7.jar;C:\Users\Stefan\Desktop\jmapviewer-2.4\lib\apacheds-all-1.5.4.jar;C:\Users\Stefan\Desktop\jmapviewer-2.4\lib\apache-httpcomponents-httpcore.jar;C:\Users\Stefan\Desktop\jmapviewer-2.4\lib\WEB-INF\lib\httpclient-4.5.4.jar" org.openstreetmap.gui.jmapviewer.Demo
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.NoClassDefFoundError: org/apache/http/concurrent/Cancellable
    at se.kodapan.osm.services.nominatim.Nominatim.search(Nominatim.java:24)
    at org.openstreetmap.gui.jmapviewer.Demo.main(Demo.java:260)
Caused by: java.lang.ClassNotFoundException: org.apache.http.concurrent.Cancellable
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

Process finished with exit code 1

I'm trying to use the JMapViewer Demo and Nominatim to get the coordinates of a certain location. I imported the HttpClient library as suggested in a thread with a similar exception(I couldn't compile without it anyway)

Here is a list of my imports(not sure if that's of any use):

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.kodapan.osm.services.HttpService;

import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;

How do I solve this?

aholbreich
  • 4,951
  • 2
  • 23
  • 38
Stefan Watt
  • 57
  • 2
  • 7

1 Answers1

0

It looks like you need the Apache httpcore library

This is available here :

https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/4.4.8

As an aside, SLF4J requires a logging implementation jar for log output. Examples for that are available here:

http://saltnlight5.blogspot.co.uk/2013/08/how-to-configure-slf4j-with-different.html

Sam
  • 670
  • 1
  • 6
  • 20
  • Thanks for your response. I added the httpcore library and am no longer getting the exception. I also followed the instructions of the second link and added the dependencies to my pom.xml but with no success. It still fails to load StaticLoggerBinder. Also I'm now getting a NullPointerException because apparently I haven't set a UserAgent in HttpService. You wouldn't happen to how to solve that as well ? ^^ – Stefan Watt Dec 12 '17 at 17:04
  • It's probably best to post another question for your UserAgent in HttpService issue. To assist it's important to see the stack trace and the code. For the logging class - see here : https://stackoverflow.com/questions/7421612/slf4j-failed-to-load-class-org-slf4j-impl-staticloggerbinder – Sam Dec 12 '17 at 17:07