[mapserver-users] Java Interface to MapServer

C F gis_consultant at hotmail.com
Mon Aug 19 12:42:57 EDT 2002


My take on it is that technically, it does work.... However, if your 
intention is to use it in a web environment, I *think* your server component 
will need to be as CGI as opposed to a servlet.  If I'm wrong... someone 
please let us know the solution!  I looked into this a while back and here 
are my conclusions based on experimentation and input from the group...

1)  The swig tool worked great for providing Java hooks into Mapscript.

2)  I was able to create functional mapscript programs in Java to generate 
maps.

3) Because mapserver is not thread-safe the servlet environment provides 
prohibitive limitations.  Basically what would happen is it (servlet) would 
take requests and process them fine... as long as you let your request 
finish before sending another one.  As it turns out servlets hold on to the 
same thread for browser sessions which causes problems for this 
non-thread-safe environment.  I've tried different ways of 
protecting/synchronizing the threads from these issues but without success.  
For me, the biggest scare factor is that is it seems very difficult or 
impossible to catch these errors and handle them gracefully.  Any little 
disruption in the underlying mapserver libraries I'm accessing through JNI 
causes the entire JVM to crash!  This is VERY bad.  If you're in a servlet 
environment, this also causes your servlet engine to crash, so then you're 
down for good.

4)  I thought about the possibility of still using Java, but setting it up 
as CGI instead of servlets.  This might resolve the threading issues, but 
again, the fact that any little error (let's say an invalid file path or a 
bum layer) causes the JVM to crash.  While subsequent requests should still 
work (your site wouldn't be down), I am still not able to handle errors 
gracefully and the fact that the JVM is crashing brings up scaring things 
like orphaned resources that build up over time and really screwing things 
up.

Since I'm developing everything else in Java, I would like to stick with 
Java, as it would solve a lot of my headaches... so I too would like to hear 
about any success stories.
In the meantime, I'm using a servlet to open up a URL connection to a local 
PHP/Mapscript page and returning the results as PHP/Mapscript works great 
and has excellent support and user base.

>From: Andrew Collins <andrewrcollins at yahoo.com>
>To: mapserver-users at lists.gis.umn.edu
>CC: Stephen Lime <steve.lime at dnr.state.mn.us>,        debasish sahu 
><debasish_sahu at hotmail.com>, DebasishS at riskinc.com,        
>gsims at wave.co.nz, mdp at lists.gis.umn.edu
>Subject: [mapserver-users] Java Interface to MapServer
>Date: Sun, 18 Aug 2002 23:33:07 -0700 (PDT)
>
>Oops... Sorry.
>Please respond to this posting.
>I dislike subject-free emails, too.
>
>--
>
>Hello Each and All
>
>I am having a heck of a time determing what the status of a Java
>MapScript interface is or is not... I've done a search (maybe not
>wide enough?) and found some contradictory postings and websites:
>
>   The Theory
>   http://mapserver.gis.umn.edu/wilma/mapserver-users/0006/msg00060.html
>
>   Experiments
>   http://mailman.cs.uchicago.edu/pipermail/swig/2001-November/003471.html
>
>   Questions...
>   http://mapserver.gis.umn.edu/wilma/mapserver-users/0112/msg00042.html
>
>   Possible success?
>   http://urewera.boarsnest.net/MapScript/
>
>   But, no "HOWTO" exists...
>   http://mapserver.gis.umn.edu/mdp/
>
>I'm not any sort of "Java guru" but I have a sincere interest
>in seeing a Java interface to MapServer become available. I'm
>absolutely certain that there are at least a few other people
>interested in getting a Java interface working.
>
>I would compose a "HOWTO" project for the MapServer Documentation
>Project, with some help, too: http://mapserver.gis.umn.edu/mdp/
>
>Please send responses, hints, links or information to the
>MapServer list as well as directly to me.
>
>Thanks!
>
>=====
>Andrew Collins - andrewrcollins at yahoo.com
>http://profiles.yahoo.com/andrewrcollins/
>
>__________________________________________________
>Do You Yahoo!?
>HotJobs - Search Thousands of New Jobs
>http://www.hotjobs.com




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx




More information about the mapserver-users mailing list