<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>

<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7226.0">
<TITLE>Re: [UMN_MAPSERVER-USERS] Java MapScript issues Servlet</TITLE>
</HEAD>
<BODY>
<DIV id=idOWAReplyText68143 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>To All,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>Umberto and Mario are correct about the 
problems I've had.&nbsp; They are definitely related to the lack of thread 
safety in my mapscript.dll that I built using MS Visual C tools.&nbsp; Can 
anyone tell me why I don't have the option to turn on thread safety in nmake.opt 
(unlike in *Nix flavors of the build option files)?&nbsp; Was it an oversight, 
future feature or excluded because it is included by default whenever mapserver 
is built in Windows and there is no need to turn it off?</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>Joe Miller</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> UMN MapServer Users List on behalf of 
Umberto Nicoletti<BR><B>Sent:</B> Mon 2/28/2005 10:31 AM<BR><B>To:</B> 
MAPSERVER-USERS@LISTS.UMN.EDU<BR><B>Subject:</B> Re: [UMN_MAPSERVER-USERS] Java 
MapScript issues Servlet<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Quoting "Mario H. Basa" &lt;mhbasa@YAHOO.COM&gt;:<BR><BR>&gt; 
Hi.<BR>&gt;<BR>&gt; &gt;From my experience, Java Mapscript still has 
some<BR>&gt; problems with threads, and can still easily bring down<BR>&gt; 
Tomcat even with the thread compile option is set.<BR>&gt; Please correct me if 
I am wrong.<BR>&gt;<BR><BR>Yes, that is probably correct, although it is not 
*that easy*. I have also<BR>stressed mapscript with jmeter and actually not 
found errors, but I did not<BR>cover querying.<BR>That is why I voted for 
improved thread safety when the devs showed their wishlists.<BR><BR><BR>&gt; 
What I did was I synchronized the class that does the<BR>&gt; map processing, 
and now my test app can survive<BR>&gt; benchmarking with JMeter. Here are my 
results as<BR>&gt; compared with a simillar PHP CGI program:<BR>&gt;<BR><BR>This 
is definitely a correct workaround.<BR><BR>&gt; 4 threads (requests) per second, 
repeated 25 times<BR>&gt;<BR>&gt; PHP Mapscript 1.8 to 1.9 pages per 
second<BR>&gt; Java Mapscript 2.3 to 2.5 pages per second<BR>&gt;<BR>&gt; I was 
honestly surprised with the result and it is<BR>&gt; encouraging me to work with 
Java Mapscript even in a<BR>&gt; synchronized mode.<BR>&gt;<BR><BR>Were you 
using apache 1.3 or 2.x in the php tests? Apache 1.3 uses a fork based<BR>model, 
that while being extremely safe and sound is not as fast as a threaded<BR>model. 
Apache 2.x has threads and should be 
faster.<BR><BR>Regards,<BR>Umberto<BR><BR>&gt; mario<BR>&gt; 
yokohama,japan<BR>&gt;<BR>&gt;<BR>&gt; --- Joseph Miller 
&lt;miller_joseph@BAH.COM&gt; wrote:<BR>&gt;<BR>&gt; &gt; Umberto,<BR>&gt; 
&gt;<BR>&gt; &gt; 1)I don't think I compiled specifically with<BR>&gt; &gt; 
multi-threading because it<BR>&gt; &gt; wasn't an option listed in the nmake.opt 
for<BR>&gt; &gt; Microsoft Visual C++&nbsp; options<BR>&gt; &gt; file???&nbsp; 
The last I heard multithreading was not<BR>&gt; &gt; even on the horizon 
for<BR>&gt; &gt; mapserver and yet I see it in the Unix build options<BR>&gt; 
&gt; file?&nbsp; What do I need<BR>&gt; &gt; to do this?<BR>&gt; &gt;<BR>&gt; 
&gt; 2)I tried both options you mentioned, I had the<BR>&gt; &gt; problem when 
passed the<BR>&gt; &gt; same mapObj from request to request and stored it 
in<BR>&gt; &gt; the session and when I<BR>&gt; &gt; set it to null after every 
request and instantiated<BR>&gt; &gt; it and assigned<BR>&gt; &gt; attributes 
based on other variables stored in the<BR>&gt; &gt; requests and 
sessions?<BR>&gt; &gt; I'm assuming the latter is preferred?<BR>&gt; 
&gt;<BR>&gt; &gt; Thanks,<BR>&gt; &gt; Joe Miller<BR>&gt; &gt;<BR>&gt; &gt; On 
Mon, 28 Feb 2005 09:44:21 +0100, Umberto<BR>&gt; &gt; Nicoletti<BR>&gt; &gt; 
&lt;unicoletti@PROMETEO.IT&gt; wrote:<BR>&gt; &gt;<BR>&gt; &gt; &gt;Did you 
enable threads support?<BR>&gt; &gt; &gt;Java, and especially servlets, are 
definitely<BR>&gt; &gt; highly concurrent<BR>&gt; &gt; &gt;environment, so you 
have to enable thread support<BR>&gt; &gt; when compiling<BR>&gt; &gt; 
&gt;mapserver and mapscript. One very problematic spot<BR>&gt; &gt; with regards 
to<BR>&gt; &gt; &gt;threads is in fact the parser of .map files.<BR>&gt; &gt; 
&gt;<BR>&gt; &gt; &gt;Do you attempt to reuse the same mapObj across<BR>&gt; 
&gt; multiple requests or just<BR>&gt; &gt; &gt;create one and dispose as soon 
as you are done<BR>&gt; &gt; within a single request?<BR>&gt; &gt; &gt;<BR>&gt; 
&gt; &gt;HTH,<BR>&gt; &gt; &gt;Umberto<BR>&gt; &gt; &gt;<BR>&gt; &gt; 
&gt;<BR>&gt; &gt; &gt;On Mon, 2005-02-28 at 00:53 -0500, Miller Joseph<BR>&gt; 
&gt; wrote:<BR>&gt; &gt; &gt;&gt; Hi,<BR>&gt; &gt; &gt;&gt; I'm having a 
baffling problem with a nightly<BR>&gt; &gt; build of Java Mapscript<BR>&gt; 
&gt; &gt;&gt; from about a month ago that I am running on<BR>&gt; &gt; Windows 
2000 with Tomcat<BR>&gt; &gt; &gt;&gt; 5.5.4.<BR>&gt; &gt; &gt;&gt;<BR>&gt; &gt; 
&gt;&gt; The symptom I see is that I can generate the<BR>&gt; &gt; default image 
but after the<BR>&gt; &gt; &gt;&gt; fourth or fifth time that I pass a new 
envelope<BR>&gt; &gt; to change the extent of<BR>&gt; &gt; &gt;&gt; the image I 
get the following error:<BR>&gt; &gt; &gt;&gt;<BR>&gt; &gt; &gt;&gt; The 
relevant part of the stack trace:<BR>&gt; &gt; &gt;&gt; java.lang.UnknownError: 
Failed to draw layer<BR>&gt; &gt; named 'world'.<BR>&gt; &gt; 
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at<BR>&gt; &gt;<BR>&gt; 
edu.umn.gis.mapscript.mapscriptJNI.mapObj_draw(Native<BR>&gt; &gt; 
Method)<BR>&gt; &gt; &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
at<BR>&gt; &gt; edu.umn.gis.mapscript.mapObj.draw(mapObj.java:397)<BR>&gt; &gt; 
&gt;&gt;<BR>&gt; &gt; &gt;&gt; Occasionally I'll get a flex scanner error 
or<BR>&gt; &gt; tomcat will crash with an<BR>&gt; &gt; &gt;&gt; 
Exception_Access_Violation memmove error similar<BR>&gt; &gt; to the one 
referred to<BR>&gt; &gt; &gt;&gt; here:<BR>&gt; &gt; &gt;&gt;<BR>&gt; 
&gt;<BR>&gt; <A 
href="http://forum.java.sun.com/thread.jspa?forumID=52&amp;messageID=1124599&amp;threa">http://forum.java.sun.com/thread.jspa?forumID=52&amp;messageID=1124599&amp;threa</A><BR>&gt; 
&gt; &gt;&gt; dID=286832<BR>&gt; &gt; &gt;&gt;<BR>&gt; &gt; &gt;&gt; All of this 
happens whether I instatiate new<BR>&gt; &gt; instances of the mapObj 
and<BR>&gt; &gt; &gt;&gt; set everything to null or if I use the same<BR>&gt; 
&gt; mapObj throughout and only<BR>&gt; &gt; &gt;&gt; after a few passes, 
suggesting to me that there<BR>&gt; &gt; is a memory issue<BR>&gt; &gt; &gt;&gt; 
somewhere.&nbsp; I can pass on some specific code, but<BR>&gt; &gt; all I am 
really doing<BR>&gt; &gt; &gt;&gt; is creating new envelopes to store extents 
and<BR>&gt; &gt; then assigning them to<BR>&gt; &gt; &gt;&gt; the mapObj or 
extracting the corner coordinates<BR>&gt; &gt; and setting the extent<BR>&gt; 
&gt; &gt;&gt; with them.<BR>&gt; &gt; &gt;&gt;<BR>&gt; &gt; &gt;&gt; I've been 
fighting this for a frustrating week<BR>&gt; &gt; now.&nbsp; Does anyone 
have<BR>&gt; &gt; &gt;&gt; any advice?<BR>&gt; &gt; &gt;&gt;<BR>&gt; &gt; 
&gt;&gt; Thanks,<BR>&gt; &gt; &gt;&gt; Joe Miller<BR>&gt; &gt; &gt;--<BR>&gt; 
&gt; &gt;Umberto Nicoletti<BR>&gt; &gt; &lt;Mercury&gt; At that point it<BR>&gt; 
&gt; will<BR>&gt; &gt; &gt;+390415701366&nbsp;&nbsp; 
unicoletti@prometeo.it<BR>&gt; &gt; compile, but segfault, as<BR>&gt; &gt; it 
should..<BR>&gt; &gt; &gt;Prometeo S.R.L. The Software Experience<BR>&gt; 
&gt;<BR>&gt; &gt; Umberto,<BR>&gt; &gt;<BR>&gt; &gt; 1)I don't think I compiled 
specifically with<BR>&gt; &gt; multi-threading because it<BR>&gt; &gt; wasn't an 
option listed in the nmake.opt for<BR>&gt; &gt; Microsoft Visual C++&nbsp; 
options<BR>&gt; &gt; file???&nbsp; The last I heard multithreading was 
not<BR>&gt; &gt; even on the horizon for<BR>&gt; &gt; mapserver and yet I see it 
in the Unix build options<BR>&gt; &gt; file?&nbsp; What do I need<BR>&gt; &gt; 
to do this?<BR>&gt; &gt;<BR>&gt; &gt; 2)I tried both options you mentioned, I 
had the<BR>&gt; &gt; problem when passed the<BR>&gt; &gt; same mapObj from 
request to request and stored it in<BR>&gt; &gt; the session and when I<BR>&gt; 
&gt; set it to null after every request and instantiated<BR>&gt; &gt; it and 
assigned<BR>&gt; &gt; attributes based on other variables stored in the<BR>&gt; 
&gt; requests and sessions?<BR>&gt; &gt; I'm assuming the latter is 
preferred?<BR>&gt; &gt;<BR>&gt; &gt; Thanks,<BR>&gt; &gt; Joe Miller<BR>&gt; 
&gt;<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; 
__________________________________<BR>&gt; Do you Yahoo!?<BR>&gt; Yahoo! Sports 
- Sign up for Fantasy Baseball.<BR>&gt; <A 
href="http://baseball.fantasysports.yahoo.com/">http://baseball.fantasysports.yahoo.com/</A><BR>&gt;<BR></FONT></P></DIV>

</BODY>
</HTML>