mapserver java servlets
Oliver Wesp
wesp at GDV.COM
Wed Nov 24 00:52:37 PST 2004
Hi,
you're on the right way to avoid the "Native library cannot be loaded
twice" error. Your JavaMapscript-Class implements a singleton so it's
loaded only once in Tomcat. But you should not add your mapscript code
to this class. Whenever you change the class Tomcat tries to reload and
complains about the library already loaded.
Write a second class and load the library with
JavaMapscript.getInstance();
Add your mapscript code to that class and you should be fine.
best regards
Oliver
Jose Luis Gonzalez wrote:
> Hi to all
> I would implement mapserver in tomcat as servlet but I have found a lot of
> problems in start with it!
>
> So:
> 1) is there sites that implement mapserver as servlet in tomcat that I can
> view?
> 2) Some one have a piece of basic code that I can compile as servlet in
> tomcat for view how it run? I have load the java Howto.
>
> Do you have examples so I can see how can I work
> with mapserver functions and servlets?
> I have been seeing the wiki, but I can not really find what I want.
>
> I have done the example of loading a library that apears in:
>
> http://www.unicolet.org/mapserver/tomcat.html
> <https://webmail.upv.es/horde/util/go.php?url=http%3A%2F%2Fwww.unicolet.org%2Fmapserver%2Ftomcat.html&Horde=324c42e307e8eddcfaf3545b63ecab4e>
>
> and it works, but when I want to complete the JavaMapscript.java code
> with other
> mapserver comands, it doesn't work:
>
> import edu.umn.gis.mapscript.*;
>
> public class JavaMapscript {
> private static JavaMapscript instance=null;
>
> private JavaMapscript() {
> try {
> System.loadLibrary("mapscript");
> } catch (Exception e) {
> e.printStackTrace();
> System.err.println("* error loading native library *");
> System.err.println("Error is: "+e);
> }
> System.out.println(" * mapscript native library loaded *");
> mapObj map = new mapObj("test.map");
> imageObj img = map.draw();
> //img.save("result", map);*/
> }
>
> public static JavaMapscript getInstance() {
> System.out.println("Try to instantiate Mapscript");
> System.out.flush();
> if ( instance == null ) {
> instance = new JavaMapscript();
> }
> return instance;
> }
> }
>
> And even worse, when I do any modifications and I put the new .class
> file in the
> server, I have an error because it says that the library was already
> loaded, and
> my only solution now to solve it is to turn off the server and turn it
> on again.
>
> Hope someone can help me
>
> Thank you
>
> Jose Luis
>
> ------------------------------------------------------------------------
>
> Nuevo Correo Yahoo!
> <http://es.rd.yahoo.com/mail_es/tagline/mail/image/*http://es.mail.yahoo.com>
>
--
Dipl.-Geogr. Oliver Wesp
Gesellschaft fuer geografische Datenverarbeitung
Binger Strasse 49-51
D-55218 Ingelheim
fon: +49 6132 714818
fax: +49 6132 714828
http: www.gdv.com
More information about the MapServer-users
mailing list