<DIV>Hi Oliver,</DIV>
<DIV>I have just done what you recomended,&nbsp; leaving the JavaMapscript-Class so the only thing he does is to load the library.</DIV>
<DIV>Then in another class, the one where I have my servlet, I wote in the: public void init (ServletConfig cfg){</DIV>
<DIV>&nbsp;</DIV>
<DIV>JavaMapscript.getInstance();</DIV>
<DIV>&nbsp;</DIV>
<DIV>and later in the:</DIV>
<DIV>public void service (HttpServletRequest req, HttpServletResponse res){</DIV>
<DIV>&nbsp;</DIV>
<DIV>I began writing my mapscript code, and it still gives me the same error:</DIV>
<DIV>&nbsp;</DIV>
<DIV>javax.servlet.ServletException: Native Library /opt/SUNappserver/domains/domain1/lib/ext/libmapscript.so already loaded in another classloader</DIV>
<DIV>&nbsp;</DIV>
<DIV>Do you know why?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thank you</DIV>
<DIV>&nbsp;</DIV>
<DIV>Jose Luis<BR><BR><B><I>Oliver Wesp &lt;wesp@gdv.com&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi,<BR><BR>you're on the right way to avoid the "Native library cannot be loaded <BR>twice" error. Your JavaMapscript-Class implements a singleton so it's <BR>loaded only once in Tomcat. But you should not add your mapscript code <BR>to this class. Whenever you change the class Tomcat tries to reload and <BR>complains about the library already loaded.<BR>Write a second class and load the library with<BR><BR>JavaMapscript.getInstance();<BR><BR>Add your mapscript code to that class and you should be fine.<BR><BR>best regards<BR>Oliver<BR><BR>Jose Luis Gonzalez wrote:<BR>&gt; Hi to all<BR>&gt; I would implement mapserver in tomcat as servlet but I have found a lot of<BR>&gt; problems in start with it!<BR>&gt; <BR>&gt; So:<BR>&gt; 1) is there sites that implement mapserver as servlet in tomcat that I can<BR>&gt; view?<BR>&gt; 2) Some one have a piece of basic code that I can compile as
 servlet in<BR>&gt; tomcat for view how it run? I have load the java Howto.<BR>&gt; <BR>&gt; Do you have examples so I can see how can I work<BR>&gt; with mapserver functions and servlets?<BR>&gt; I have been seeing the wiki, but I can not really find what I want.<BR>&gt; <BR>&gt; I have done the example of loading a library that apears in:<BR>&gt; <BR>&gt; http://www.unicolet.org/mapserver/tomcat.html <BR>&gt; <HTTPS: go.php?url="http%3A%2F%2Fwww.unicolet.org%2Fmapserver%2Ftomcat.html&amp;Horde=324c42e307e8eddcfaf3545b63ecab4e" util horde webmail.upv.es><BR>&gt; <BR>&gt; and it works, but when I want to complete the JavaMapscript.java code <BR>&gt; with other<BR>&gt; mapserver comands, it doesn't work:<BR>&gt; <BR>&gt; import edu.umn.gis.mapscript.*;<BR>&gt; <BR>&gt; public class JavaMapscript {<BR>&gt; private static JavaMapscript instance=null;<BR>&gt; <BR>&gt; private JavaMapscript() {<BR>&gt; try {<BR>&gt; System.loadLibrary("mapscript");<BR>&gt; } catch (Exception e) {<BR>&gt;
 e.printStackTrace();<BR>&gt; System.err.println("* error loading native library *");<BR>&gt; System.err.println("Error is: "+e);<BR>&gt; }<BR>&gt; System.out.println(" * mapscript native library loaded *");<BR>&gt; mapObj map = new mapObj("test.map");<BR>&gt; imageObj img = map.draw();<BR>&gt; //img.save("result", map);*/<BR>&gt; }<BR>&gt; <BR>&gt; public static JavaMapscript getInstance() {<BR>&gt; System.out.println("Try to instantiate Mapscript");<BR>&gt; System.out.flush();<BR>&gt; if ( instance == null ) {<BR>&gt; instance = new JavaMapscript();<BR>&gt; }<BR>&gt; return instance;<BR>&gt; }<BR>&gt; }<BR>&gt; <BR>&gt; And even worse, when I do any modifications and I put the new .class <BR>&gt; file in the<BR>&gt; server, I have an error because it says that the library was already <BR>&gt; loaded, and<BR>&gt; my only solution now to solve it is to turn off the server and turn it <BR>&gt; on again.<BR>&gt; <BR>&gt; Hope someone can help me<BR>&gt; <BR>&gt; Thank you<BR>&gt;
 <BR>&gt; Jose Luis<BR>&gt; <BR>&gt; ------------------------------------------------------------------------<BR>&gt; <BR>&gt; Nuevo Correo Yahoo! <BR>&gt; <HTTP: es.mail.yahoo.com *http: image mail tagline mail_es es.rd.yahoo.com><BR>&gt; <BR><BR><BR>-- <BR>Dipl.-Geogr. Oliver Wesp<BR>Gesellschaft fuer geografische Datenverarbeitung<BR>Binger Strasse 49-51<BR>D-55218 Ingelheim<BR>fon: +49 6132 714818<BR>fax: +49 6132 714828<BR>http: www.gdv.com<BR></BLOCKQUOTE><p>
                <hr size=1><br><table><tr><td><a href="http://es.rd.yahoo.com/mail_es/tagline/mail/image/*http://es.mail.yahoo.com"><img src="http://eur.i1.yimg.com/eur.yimg.com/i/es/mail/mails.gif" height=80 width=230 alt="Nuevo Correo Yahoo!" border=0 align="left"></a></td></tr></table>