Set up the Geocoder

430 views
Skip to first unread message

Christian Kuntzsch

unread,
Oct 13, 2013, 9:26:19 AM10/13/13
to opentripp...@googlegroups.com
Hi everyone!

I just recently started working with OTP and got the 'stable'-branch working in Eclipse thanks to the instructions on the Wiki.

Now I wanted to add a geocoder, Nominatim specifically, and followed the instructions on this thread. But starting the server leaves me with an error, saying it couldn't start the server. Here's what the console reads:

Okt 13, 2013 3:06:19 PM org.apache.catalina.core.AprLifecycleListener init
Information: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;E:\Lenovo\Bluetooth Software\;E:\Lenovo\Bluetooth Software\syswow64;E:\Calibre2\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;.;;.;;.;;.
Okt 13, 2013 3:06:19 PM org.apache.coyote.http11.Http11BaseProtocol init
Information: Initializing Coyote HTTP/1.1 on http-8080
Okt 13, 2013 3:06:19 PM org.apache.catalina.startup.Catalina load
Information: Initialization processed in 762 ms
Okt 13, 2013 3:06:19 PM org.apache.catalina.core.StandardService start
Information: Starting service Catalina
Okt 13, 2013 3:06:19 PM org.apache.catalina.core.StandardEngine start
Information: Starting Servlet Engine: Apache Tomcat/5.5.33
Okt 13, 2013 3:06:19 PM org.apache.catalina.core.StandardHost start
Information: XML validation disabled
15:06:21.246 INFO (ApplicationContext.java:653) Initializing Spring root WebApplicationContext
15:06:23.579 INFO (GraphServiceImpl.java:123) no list of routerIds was provided for automatic registration.
15:06:23.580 INFO (GraphServiceImpl.java:126) Attempting to load graph for default routerId ''.
15:06:23.580 INFO (GraphServiceImpl.java:245) registering routerId ''
15:06:23.639 INFO (GraphServiceImpl.java:215) Loading graph...
15:06:23.680 INFO (MavenVersion.java:44) Parsed Maven artifact version: 0.9.2-SNAPSHOT => MavenVersion(0, 9, 2, SNAPSHOT, 93f94ab1f3270a2e49511d1c9a35f67f923a026f) UID=-9002
15:06:29.215 INFO (Graph.java:498) Graph version: MavenVersion(0, 9, 2, SNAPSHOT, 93f94ab1f3270a2e49511d1c9a35f67f923a026f)
15:06:29.216 INFO (Graph.java:499) OTP version:   MavenVersion(0, 9, 2, SNAPSHOT, 93f94ab1f3270a2e49511d1c9a35f67f923a026f)
15:06:29.216 INFO (Graph.java:516) This graph was built with the currently running version and commit of OTP.
15:08:49.132 INFO (Graph.java:463) Main graph read. |V|=823164 |E|=2180157
15:09:12.868 INFO (Jdk14Logger.java:99) Initializing Spring root WebApplicationContext
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.NoClassDefFoundError: com/sun/jersey/spi/container/servlet/ServletContainer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1960)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:933)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1405)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
... 6 more
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
... 24 more

I don't know how to resolve this error. Has anyone encountered something like this and can give me some advice?

Any help is much appreciated, thanks!

Laurent GRÉGOIRE

unread,
Oct 14, 2013, 12:09:33 PM10/14/13
to opentripp...@googlegroups.com
Hi Christian,

On 13/10/2013 15:26, Christian Kuntzsch wrote:
> But starting the server leaves me with an error, saying it
> couldn't start the server. Here's what the console reads:

> Caused by: java.lang.ClassNotFoundException:
> com.sun.jersey.spi.container.servlet.ServletContainer
>
> I don't know how to resolve this error. Has anyone encountered something
> like this and can give me some advice?

How do you start the server (in Eclipse, standalone Tomcat...)? If it's
in Eclipse, I sometimes get a ClassNotFoundException too, a
clean/publish on the project usually solves that. You can also try to
maven-update the project in Eclipse (right clic on the root project,
maven, update-project), it can help too.

HTH,

--Laurent


Christian Kuntzsch

unread,
Dec 1, 2013, 5:39:02 AM12/1/13
to opentripp...@googlegroups.com
Hi Laurent,

sorry for the delayed response, I unfortunately did not have any time to get back into this issue, but thanks a lot for your reply anyway!

How do you start the server (in Eclipse, standalone Tomcat...)?

I am trying to start the server in Eclipse, yes. 
 
clean/publish on the project usually solves that. You can also try to 
maven-update the project in Eclipse (right clic on the root project, 
maven, update-project), it can help too. 

Sorry, but that doesn't solve the problem. I googled a little bit for this specific error and it seems like I might be missing some dependecies or library files from 'jersey'. I scanned through the whole project and didn't find any files with that name at all. I tried several ways of adding new dependecies to different pom.xml-files, but no luck either.
What's strange though, is that if I only deploy the rest-servlet the server runs fine, but with the geocoder, it won't work.

Anyway, thanks again.

Christian

Kathryn Killebrew

unread,
Dec 1, 2013, 7:27:56 PM12/1/13
to opentripp...@googlegroups.com
Howdy,

I just ran into the same issue with the geocoder complaining about missing its servlet container.  I'm also using the stable branch and Nominatim, but I'm building with maven at the command line and deploying to Tomcat.

I was able to get a working geocoder by using a .war built from the version on this commit:

Kathryn

Laurent GRÉGOIRE

unread,
Dec 2, 2013, 1:07:38 PM12/2/13
to opentripp...@googlegroups.com
On 01/12/2013 11:39, Christian Kuntzsch wrote:
> Sorry, but that doesn't solve the problem. I googled a little bit for
> this specific error and it seems like I might be missing some
> dependecies or library files from 'jersey'. I scanned through the whole
> project and didn't find any files with that name at all. I tried several
> ways of adding new dependecies to different pom.xml-files, but no luck
> either.
> What's strange though, is that if I only deploy the rest-servlet the
> server runs fine, but with the geocoder, it won't work.

You can also try to import in Eclipse a freshly cloned repo to see if
the problem persist. But it could also be a bug in OTP itself with a
wrong dependency, as somebody else is experiencing the issue too.

--Laurent

Kathryn Killebrew

unread,
Dec 4, 2013, 10:45:23 AM12/4/13
to opentripp...@googlegroups.com
Okay, I think I've isolated the issue.  The geocoder's pom.xml needs the following added to work with Jersey > 1.11:

    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-servlet</artifactId>
    </dependency>

-Kathryn

Christian Kuntzsch

unread,
Dec 6, 2013, 6:18:29 AM12/6/13
to opentripp...@googlegroups.com
Thanks a lot, adding the dependency fixed it for me as well. I might want to add, that I switched to the 'master'-branch recently.

I've added a geocoder to the config.js using these lines of code:

geocoders : [
        {
        'name': 'geocoder',
        'className': 'otp.core.Geocoder',
        'addressParam': 'q'
      }
    ]

This results in showing the 'from' and 'to' fields. But when I enter addresses and click 'Plan Trip', nothing happens. In the future, I might want to set up a custom Nominatim server, but for now I would like to test this already existing instance. Is there anything else to consider, except for the config.js mentioned above, maybe in the geocoder's application-context.xml?

Thanks again, Christian

Kathryn Killebrew

unread,
Dec 6, 2013, 11:13:46 AM12/6/13
to opentripp...@googlegroups.com
Hi Christian,

The url in config.js refers to the local url of the OTP geocoder module, so if you're serving locally a master branch build, that should be:

You should be able to test it out with a query, like:

or something like that, if your addressParam is 'q'.

If you were using the stable branch, then the geocoder would be at:

The url for the Nominatim server you're using is set in the geocoder's application-context.xml, which unless it's been changed, should be the MapQuest server's address.

Best,
Kathryn



--
You received this message because you are subscribed to the Google Groups "OpenTripPlanner Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opentripplanner...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Christian Kuntzsch

unread,
Dec 6, 2013, 1:03:01 PM12/6/13
to opentripp...@googlegroups.com
Oh my god, it works! This is a huge step forward for me. THANK YOU!! I'm feeling like step by step this whole thing is finally coming together :)

Christian
To unsubscribe from this group and stop receiving emails from it, send an email to opentripplanner-dev+unsub...@googlegroups.com.

Andrew Byrd

unread,
Dec 7, 2013, 9:39:56 AM12/7/13
to opentripp...@googlegroups.com
Hi everyone,

Glad you were able to sort this out. Clearly we need to update the
documentation on setting up a geocoder. I rarely use one myself so I'll
need your help on this. I have collected the information from recent
posts on geocoder setup and placed it at:
https://github.com/opentripplanner/OpenTripPlanner/wiki/GeoCoders

Everyone who has recently set up a geocoder, please take a moment to
verify this documentation. Contact me off-list or edit the wiki page
directly if you spot any incorrect information.

-Andrew

On 12/06/2013 07:03 PM, Christian Kuntzsch wrote:
> Oh my god, it works! This is a huge step forward for me. *THANK
> YOU!!* I'm feeling like step by step this whole thing is finally coming
> <groupId>com.sun.jersey</__groupId>
> <artifactId>jersey-servlet</__artifactId>
> </dependency>
>
> -Kathryn
>
>
> On Mon, Dec 2, 2013 at 1:07 PM, Laurent GR�GOIRE
> opentripplanner...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "OpenTripPlanner Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opentripplanner...@googlegroups.com.

Andrew Byrd

unread,
Dec 7, 2013, 9:45:46 AM12/7/13
to opentripp...@googlegroups.com

Thanks Kathryn for tracking this down. I have committed this change and
pushed to master.

Browsing the latest Jersey documentation I am reminded that Jersey 2.0
has been released. It seems to have changed quite a bit. It looks like
more work has been done Grizzly integration, which could be beneficial
for OTP standalone mode.

I am going to create a ticket about investigating a bump to Jersey 2.0.
Does anyone have experience working with Jersey 2.0? Any positive or
negative experiences?

-Andrew

Kathryn Killebrew

unread,
Dec 8, 2013, 4:05:55 PM12/8/13
to opentripp...@googlegroups.com
Thanks for posting the geocoder documentation, Andrew.  I just put in a few small edits.  (Changed the address parameter to "address," which might be a litter clearer, and changed the url in config.js to be relative to root.)

Kathryn


>                 </dependency>
>
>             -Kathryn
>
>
>             On Mon, Dec 2, 2013 at 1:07 PM, Laurent GRÉGOIRE

Daniel Steiner

unread,
Mar 18, 2014, 6:47:00 PM3/18/14
to opentripp...@googlegroups.com
Hi,

I am using exact the same settings that are described in the geocoder documentation in my config.js:


geocoders : [
    {
       'name': 'geocoder',
        'className': 'otp.core.Geocoder',
        'url': '/otp-geocoder/geocode',
        'addressParam': 'address'
   
    },
    ],

but the geocoder isn't able to find any places when entering some letters in the start and end textfield.
Even if I try to open the http://localhost:8014/otp-geocoder/geocode?address=city%20hall, I always get the same error "Resource identified by path '/otp-geocoder/geocode', does not exist."
Are there any additional settings necessary?

Thanks,
Daniel

Laurent Gregoire

unread,
Mar 19, 2014, 3:38:59 AM3/19/14
to opentripp...@googlegroups.com
Hi Daniel,

On 18/03/14 23:47, Daniel Steiner wrote:
> Even if I try to open the
> http://localhost:8014/otp-geocoder/geocode?address=city%20hall, I always
> get the same error "Resource identified by path '/otp-geocoder/geocode',
> does not exist."

You need to have an answer back here. Please check if your otp-geocoder
webapp is started (depending on which container you use, you have to add
the geocoder server module). Do you use the standalone version of OTP or
do you run it in a container such as Tomcat?

--Laurent

Daniel Steiner

unread,
Mar 19, 2014, 11:28:01 AM3/19/14
to opentripp...@googlegroups.com
Hi, Laurent,

I just use the following commands in the command line:

  1. cd /path/to/projects
  2. git clone https://github.com/opentripplanner/OpenTripPlanner.git
  3. cd OpenTripPlanner
  4. --> insert the lines for the geocoder into config.js
  5. mvn clean package -DskipTests
  6. java -server -Xmx30G -jar otp-core/target/otp.jar -a --transitIndex -l -b --build "C:\OpenTripPlanner\var\otp\downloads"
  7. java -Xmx10G -jar otp-core/target/otp.jar -s -a -l -p 8010 -g "C:\OpenTripPlanner\var\otp\graphs" --server

I don't use the Tomcat, just execute everything in the Windows console.
Do I have to start anything else to get the default geocoder server module run?

Daniel

Laurent Gregoire

unread,
Mar 19, 2014, 11:31:02 AM3/19/14
to opentripp...@googlegroups.com
Hi Daniel,

On 19/03/14 16:28, Daniel Steiner wrote:
> I don't use the Tomcat, just execute everything in the Windows console.
> Do I have to start anything else to get the default geocoder server module
> run?

Yes, AFAIK the standalone mode won't start the geocoder, which is
another webapp/module than the router. To start it you need
Tomcat/Glassfish/Jetty or any other container.

But the geocoder is really only a thin layer which redirect request to
an external server. It's there to solve the same-origin policy in
browsers. You can maybe devise other ways to do geocoding (such as
setting up a proxy and communicating directly with an external geocodeur
server).

HTH,

--
Laurent GRÉGOIRE
laurent....@gmail.com

Andrew Byrd

unread,
Mar 19, 2014, 11:33:30 AM3/19/14
to opentripp...@googlegroups.com
On 03/19/2014 04:28 PM, Daniel Steiner wrote:
> Hi, Laurent,
>
> I just use the following commands in the command line:
>
> 1. cd /path/to/projects
> 2. git clone https://github.com/opentripplanner/OpenTripPlanner.git
> 3. cd OpenTripPlanner
> 4. --> insert the lines for the geocoder into config.js
> 5. mvn clean package -DskipTests
> 6. java -server -Xmx30G -jar otp-core/target/otp.jar -a --transitIndex
> -l -b --build "C:\OpenTripPlanner\var\otp\downloads"
> 7. java -Xmx10G -jar otp-core/target/otp.jar -s -a -l -p 8010 -g
> "C:\OpenTripPlanner\var\otp\graphs" --server
>
> I don't use the Tomcat, just execute everything in the Windows console.
> Do I have to start anything else to get the default geocoder server
> module run?

In master and all past versions, the geocoder module (geocoder proxy
module, if we call it what it really is) was separate from otp-core, and
is not included in standalone mode. I have merged the geocoder into the
main OTP module on a branch, but that is an unfinished modification and
I'm not sure it's possible to configure or use it properly.

In short, the geocoder is not currently available unless you're running
a servlet container.

-Andrew

Andrew Byrd

unread,
Mar 19, 2014, 11:35:15 AM3/19/14
to opentripp...@googlegroups.com
On 03/19/2014 04:31 PM, Laurent Gregoire wrote:
> But the geocoder is really only a thin layer which redirect request to
> an external server. It's there to solve the same-origin policy in
> browsers. You can maybe devise other ways to do geocoding (such as
> setting up a proxy and communicating directly with an external geocodeur
> server).

Eventually maybe OTP will actually have its own integrated geocoder, see
ticket #1371:
https://github.com/opentripplanner/OpenTripPlanner/issues/1371

Anyone who is familiar with OSM and Lucene and wants to work on this,
please do give it a shot!

-Andrew
Reply all
Reply to author
Forward
0 new messages