<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2523" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=578212514-24112004><FONT face=Arial color=#0000ff size=2>Jose,
what servlet container are you using?</FONT></SPAN></DIV>
<DIV><SPAN class=578212514-24112004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=578212514-24112004><FONT face=Arial color=#0000ff size=2>Try
initializing the servlet first without calling it -- you can do this by putting
it in web.xml like this:</FONT></SPAN></DIV>
<DIV><SPAN class=578212514-24112004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=578212514-24112004><FONT face=Arial color=#0000ff
size=2><servlet></FONT></SPAN></DIV>
<DIV><SPAN class=578212514-24112004> <FONT face=Arial
color=#0000ff
size=2><servlet-name>test</servlet-name></FONT></SPAN></DIV>
<DIV><SPAN class=578212514-24112004> <FONT face=Arial
color=#0000ff size=2><servlet-class> {your class name}
</servlet-class></FONT></SPAN></DIV>
<DIV><SPAN class=578212514-24112004><FONT face=Arial color=#0000ff
size=2>
<load-on-startup>1</load-on-startup></FONT></SPAN></DIV>
<DIV><SPAN class=578212514-24112004></SPAN><SPAN class=578212514-24112004><FONT
size=2><FONT face=Arial color=#0000ff></servlet></FONT></FONT></SPAN><SPAN
class=578212514-24112004></DIV>
<DIV>
<P><FONT face=Arial><FONT color=#0000ff><FONT size=2>T<SPAN
class=578212514-24112004>his will force the init() to run without the
service(). Also you should avoid lazy initialization in Singleton
classes. </SPAN></FONT></FONT></FONT></P>
<P><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=578212514-24112004>Regards,</SPAN></FONT></FONT></FONT></P>
<P><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=578212514-24112004>Chris</SPAN></FONT></FONT></FONT></SPAN></P></DIV>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Jose Luis Gonzalez
[mailto:joseluismapserver@YAHOO.ES]<BR><B>Sent:</B> Wednesday, November 24,
2004 4:51 AM<BR><B>To:</B> MAPSERVER-USERS@LISTS.UMN.EDU<BR><B>Subject:</B>
Re: [UMN_MAPSERVER-USERS] mapserver java servlets<BR><BR></FONT></DIV>
<DIV>Hi Oliver,</DIV>
<DIV>I have just done what you recomended, 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> </DIV>
<DIV>JavaMapscript.getInstance();</DIV>
<DIV> </DIV>
<DIV>and later in the:</DIV>
<DIV>public void service (HttpServletRequest req, HttpServletResponse
res){</DIV>
<DIV> </DIV>
<DIV>I began writing my mapscript code, and it still gives me the same
error:</DIV>
<DIV> </DIV>
<DIV>javax.servlet.ServletException: Native Library
/opt/SUNappserver/domains/domain1/lib/ext/libmapscript.so already loaded in
another classloader</DIV>
<DIV> </DIV>
<DIV>Do you know why?</DIV>
<DIV> </DIV>
<DIV>Thank you</DIV>
<DIV> </DIV>
<DIV>Jose Luis<BR><BR><B><I>Oliver Wesp <wesp@gdv.com></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>> Hi to all<BR>>
I would implement mapserver in tomcat as servlet but I have found a lot
of<BR>> problems in start with it!<BR>> <BR>> So:<BR>> 1) is
there sites that implement mapserver as servlet in tomcat that I can<BR>>
view?<BR>> 2) Some one have a piece of basic code that I can compile as
servlet in<BR>> tomcat for view how it run? I have load the java
Howto.<BR>> <BR>> Do you have examples so I can see how can I
work<BR>> with mapserver functions and servlets?<BR>> I have been
seeing the wiki, but I can not really find what I want.<BR>> <BR>> I
have done the example of loading a library that apears in:<BR>> <BR>>
http://www.unicolet.org/mapserver/tomcat.html <BR>> <HTTPS:
webmail.upv.es horde util
go.php?url="http%3A%2F%2Fwww.unicolet.org%2Fmapserver%2Ftomcat.html&Horde=324c42e307e8eddcfaf3545b63ecab4e"><BR>>
<BR>> and it works, but when I want to complete the JavaMapscript.java
code <BR>> with other<BR>> mapserver comands, it doesn't work:<BR>>
<BR>> import edu.umn.gis.mapscript.*;<BR>> <BR>> public class
JavaMapscript {<BR>> private static JavaMapscript instance=null;<BR>>
<BR>> private JavaMapscript() {<BR>> try {<BR>>
System.loadLibrary("mapscript");<BR>> } catch (Exception e) {<BR>>
e.printStackTrace();<BR>> System.err.println("* error loading native
library *");<BR>> System.err.println("Error is: "+e);<BR>> }<BR>>
System.out.println(" * mapscript native library loaded *");<BR>> mapObj
map = new mapObj("test.map");<BR>> imageObj img = map.draw();<BR>>
//img.save("result", map);*/<BR>> }<BR>> <BR>> public static
JavaMapscript getInstance() {<BR>> System.out.println("Try to instantiate
Mapscript");<BR>> System.out.flush();<BR>> if ( instance == null )
{<BR>> instance = new JavaMapscript();<BR>> }<BR>> return
instance;<BR>> }<BR>> }<BR>> <BR>> And even worse, when I do any
modifications and I put the new .class <BR>> file in the<BR>> server,
I have an error because it says that the library was already <BR>>
loaded, and<BR>> my only solution now to solve it is to turn off the
server and turn it <BR>> on again.<BR>> <BR>> Hope someone can help
me<BR>> <BR>> Thank you<BR>> <BR>> Jose Luis<BR>> <BR>>
------------------------------------------------------------------------<BR>>
<BR>> Nuevo Correo Yahoo! <BR>> <HTTP: es.rd.yahoo.com mail_es tagline
mail image *http: es.mail.yahoo.com><BR>> <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>
<TBODY>
<TR>
<TD><A
href="http://es.rd.yahoo.com/mail_es/tagline/mail/image/*http://es.mail.yahoo.com"><IMG
height=80 alt="Nuevo Correo Yahoo!"
src="http://eur.i1.yimg.com/eur.yimg.com/i/es/mail/mails.gif" width=230
align=left border=0
NOSEND="1"></A></TD></TR></TBODY></TABLE></BLOCKQUOTE></BODY></HTML>