Posted by Saba Ansari on August 30, 2010
Hello
I would like to know the best way to broadcast a message for many clients. Should I use a executor from a thread pool and dispatch the message to each context.getResponse in a different thread like this:
for (final AsyncContext ctx : clients) { executors.execute(new Runnable() { public void run() { try { PrintWriter writer = ctx.getResponse().getWriter(); writer .println(message); writer.flush(); } catch (IOException e) { e.printStackTrace(); } }
}); }
Or the best way would be to send the message to each ctx.getResponse() inside the same thread (putting the foreach inside the Runnable)? The question is: is ctx.getResponse().print really fast that it only puts the String inside the buffer that will be dispatched later (in an async fashion) to the client?
Even more, is ctx.getResponse().getWriter().print() a thread safe call? If there are two broadcasts, what happens if we have a concurrent call to the writer.print()? can the buffer loose data or both calls will succeed without guaranting the order.
thanks
Posted by Saba Ansari on August 30, 2010
Hi
I see this under 6.0.29 [and I think under 6.0.18 before, but I am not sure], but as this is pure java code, not calling any tomcat code and not probably affected by tomcat code, I don’t think that matters. (That’s why I labeled that off-topic.)
However, if it even could be of any help solving this mystery, I will provide any information needed.
Regards, Steffen
wrote: ); { line 331):
smime.p7s
Posted by Saba Ansari on August 30, 2010
On Tue, Aug 31, 2010 at 12:05 AM, Wesley Acheson wrote:
More Info it seems to work correctly if the war file is deployed after tomcat has started. However if the war file is there when I start tomcat it is undeployable.
SEVERE: [C:icarustomcatwebappsROOTWEB-INFlib] could not be completely dele ted. The presence of the remaining files may cause problems 31-Aug-2010 00:18:29 org.apache.catalina.startup.ExpandWar deleteDir SEVERE: [C:icarustomcatwebappsROOTWEB-INF] could not be completely deleted. The presence of the remaining files may cause problems 31-Aug-2010 00:18:29 org.apache.catalina.startup.ExpandWar deleteDir SEVERE: [C:icarustomcatwebappsROOT] could not be completely deleted. The pre sence of the remaining files may cause problems 31-Aug-2010 00:18:29 org.apache.catalina.startup.ExpandWar delete SEVERE: [C:icarustomcatwebappsROOT] could not be completely deleted. The pre sence of the remaining files may cause problems 31-Aug-2010 00:18:29 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive ROOT.war
Posted by Saba Ansari on August 30, 2010
On 30/08/2010 19:41, Paulo Silveira wrote:
Yep. Already fixed in svn and will be in 7.0.3 onwards. Until then you’ll need to fix it manually.
Mark
Posted by Saba Ansari on August 30, 2010
I suppose it depends on your definition of memory leak, but I’d certainly consider it one. It adds to the heap, and doesn’t go away automatically when the application is undeployed (and likely prevents complete undeployment). Furthermore, when the application is redeployed, you’ll get an additional set per thread, since the net.fortuna.ical4j.* classes will be loaded from a new classloader.
“All I changed was…” No, it’s doing a lot more than that.
http://download.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html
And, as usual, GIYF.
Not easily. Most uses of ThreadLocal seem to be blissfully (sometimes arrogantly) unaware of thread-pooling mechanisms and app servers. Ideally, these ThreadLocal instances would instead be created in a pool for the webapp to use, rather than being tied to individual threads.
It’s not harmless. I think you can inhibit the checks by disabling the JreMemoryLeakPreventionListener:
http://tomcat.apache.org/tomcat-6.0-doc/config/listeners.html
but that pretty much means that, for safety’s sake, you should restart Tomcat on every webapp deployment.
– Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
Posted by Saba Ansari on August 30, 2010
I have an axis2 aar webservice deployed in Tomcat. The serviceClass’s init(ServiceContext) method doesn’t at all get called. There is no error message seen in the tomcat logs what is going on. I only see a sentence in the Catalina logs that the application has been deployed. How am I to proceed? Please advice.
Thanks Kannan
Posted by Saba Ansari on August 30, 2010
On 30/08/2010 16:58, Jamie wrote:
Certificate stores are set per connector. It has to be this way since the SSL connection needs to be established before the request can be parsed and the correct host & context identified.
To do what you want to do sounds like you’ll need one connector per webapp which equates to one service + connector + engine + host per web app.
Mark
Posted by Saba Ansari on August 30, 2010
On 30.08.2010 11:47, Honey Bajaj wrote:
1) Update to a recent version of Tomcat, e.g. 5.5.30 or 6.0.29.
2) Identify the thread numbers of the threads consuming CPU, using “ps” and the appropriate flags on your platform to list individual threads/lightweight processes.
3) Take a few consecutive Java thread dumps of the Java process and look for the stacks of the thread in question. The decimal ID(s) retrieved by 2) are equal to the nid or tid (hexadecimal) in the header lines of each thread stack.
Regards,
Rainer
Posted by Saba Ansari on August 30, 2010
The Microsoft characters are encoded in CP-1252 (http://en.wikipedia.org/wiki/Windows-1252).
However, if the problem is the database-driven content, then you also need to consider the encoding that the dB is using. For example, MySQL might by default use latin1 (ISO-8859-1), so your data might be “corrupted” before it is even seen by Tomcat. So be careful — you might have to go deeper than just the Tomcat encoding.
BTW, in our application we solved the same problem by catching the data before it is saved to the dB, converting any CP-1252 characters into reasonable latin-1 characters. It is not the perfect solution, but is enough for our clients.
Good luck,
Posted by Saba Ansari on August 29, 2010
I need to override a single method in a standard tomcat6 realm for a particular webApp/context.
The method: RealmBase.getPrincipal(X509Certificate usercert)
Q1) Should I create a new custom realm (..subClass of RealmBase) which is based-on/copied-from the original/standard tomcat realm?
Q2) what all classes will I need in my new custom realm? (…only MyCustomRealm class itself? )
Q3) Should I reference my new realm via my webapp’s META-INF/context.xml file?
Q4) Should I put my realm class(es) in a jar inside the tomcat6/lib directory?
…I am new to tweaking realm’s, so appreciate the feedback.