Re: Updated Docs for Tomcat 4
Connection-pooling based on the Tyrex stuff is straightforward. If you do the Tyrex install and resource setup as indicated in the new doc, you already have everything needed to do basic connection pooling. Below is the code from the new doc, modified: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); DataSource ds = (DataSource)envCtx.lookup(jdbc/EmployeeDB); Connection conn; if ( dataSrc instanceof ConnectionPoolDataSource ) { ConnectionPoolDataSource poolDataSrc = (ConnectionPoolDataSource)dataSrc; PooledConnection pc = poolDataSrc.getPooledConnection(); conn = pc.getConnection(); } else { conn = ds.getConnection(); } ... use this connection to access the database ... conn.close(); Again, in the default Tyrex config, the DataSource you get will have the concrete class tyrex.jdbc.xa.XADataSourceImpl, which implements ConnectionPoolDataSource. I suggest you do all this in an init(), and use a static or singleton to manage the data-source retrieved via JNDI -- don't do the JNDI lookup every time you need a connection. When you use Tyrex like this, a background thread is created that will close unused connections every 10 secs or so. The pool therefore stays close to the minimum required size at all times, but if your DB takes a long time to establish connections, you'll experience delays when there is a spike in activity. If you want more control over how the pool is managed, I suggest you look into, for example, Poolman (http://www.codestudio.com/). - Fernando Rick Mann rmann@latency To: [EMAIL PROTECTED], Craig R. McClanahan [EMAIL PROTECTED], tomcat user zero.com jakarta.apache.org [EMAIL PROTECTED] cc: (bcc: Fernando Salazar/CAM/Lotus) 09/09/2001 Subject: Re: Updated Docs for Tomcat 4 09:50 PM Please respond to tomcat-dev on 9/5/01 9:04 PM, Craig R. McClanahan at [EMAIL PROTECTED] wrote: Things still on the TODO list: * Configuration instructions for populating the JNDI context that is provided to web applications (such as connection pools). Erg...ack...grr! I looked at the latest docs up there...so close! I really want to know how to make connection pools! Anyway, keep it up. It's coming together. Thanks! Roderick Mann rmann @ latencyzero.com.sansspam
Re: Cookie name is a reserved token
Does your cookie have a name that corresponds to a Java language token, or is one of the following: if (!isToken(name) || name.equalsIgnoreCase(Comment) // rfc2019 || name.equalsIgnoreCase(Discard) // 2019++ || name.equalsIgnoreCase(Domain) || name.equalsIgnoreCase(Expires) // (old cookies) || name.equalsIgnoreCase(Max-Age) // rfc2019 || name.equalsIgnoreCase(Path) || name.equalsIgnoreCase(Secure) || name.equalsIgnoreCase(Version) If so, you are supposed to be getting this exception -- the fix is to use a different name. - Fernando |+ || Gareth Coltman | || gareth_coltman@majorb| || and.co.uk| ||| || 08/07/2001 11:03 AM | || Please respond to | || tomcat-user | ||| |+ ---| | | | To: [EMAIL PROTECTED] | | cc: (bcc: Fernando Salazar/CAM/Lotus) | | Subject: Cookie name is a reserved token | ---| I am getting the following error trying to load test my app. I am looked at the bug database: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=231 and it claims this bug is fixed in Tomcat 3.3 I am using tomcat 3.3/mod_jk with the pooled tcp connector,and I still get it. I have no idea why? Could be it be a threading issue? The server seems to have enough free resources... Please help java.lang.IllegalArgumentException: Cookie name Path is a reserved token at javax.servlet.http.Cookie.init(Cookie.java:185) at org.apache.tomcat.util.RequestUtil.processCookies(RequestUtil.java:189) at org.apache.tomcat.core.RequestImpl.getCookieCount(RequestImpl.java:494) at org.apache.tomcat.session.StandardSessionInterceptor.requestMap(StandardSess ionInterceptor.java:143) at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:820 ) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:77 1) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection (Ajp12ConnectionHandler.java:166) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) -- Mike Scott Head of Technology Operations rightmove.co.uk Tel: 020 7821 9661 Mobile: 07941 576326 Email: [EMAIL PROTECTED]
Re: Application to Servlet communication
A number of folks recently posted similar questions ... I think things work better when you specify application/x-java-serialized-object as the content type of the data you are writing. In the code below, you're using application/x-www-form-urlencoded, which definitely would not help. - Fernando Hi all! I'm trying to do some application/applet to servlet communication where I want to send an object to servlet. My application code: URL testServlet = new URL(http://localhost:83/testApp/servlet/TestServlet;); URLConnection servletConnection = testServlet.openConnection (); // inform the connection that we will send output and accept input servletConnection.setDoInput(true); servletConnection.setDoOutput(true); // Don't use a cached version of URL connection. servletConnection.setUseCaches(false); servletConnection.setDefaultUseCaches(false); // Specify the content type that we will send binary data //servletConnection.setRequestProperty(Content-Type, application/octet-stream); servletConnection.setRequestProperty(Content-Type, application/x-www-form-urlencoded); // send the student object to the servlet using serialization ObjectOutputStream outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream()); // serialize the object outputToServlet.writeObject(new HelloObject(message)); outputToServlet.flush(); outputToServlet.close(); results in Http10Interceptor: SocketException reading request, ignored message on tomcat 3.3m4. Any idea what I'm doing wrong ? Any help will be appreciated. Best regards, Kovi
RE: problem with getPort()
Hmm ... you may need to file a bug, or do some Tomcat debugging. One thing to try, use: reponse.sendRedirect( http://beru.cariboulake.com/servlet/Servlet2; ); I bet that would work ... looks like the code that processes sendRedirect() first tries to make an Url out of the specified location, and if that doesn't work, it makes the request URL and formulates the new location relative to that. - Fernando Unfortuantly I did get something like that. HTTP/1.1 302 Date: Mon, 09 Jul 2001 20:56:22 GMT Server: Apache/1.3.20 (Unix) mod_jk Location: http://beru.cariboulake.com:0/servlet/Servlet2 Content-Length: 179 Connection: close This sounds odd, but what if I swiched to ajp13? Could that hopefully change anything? thanks joe
RE: problem with getPort()
Try using telnet to connect to your servlet 1 and then see what is returned. You would enter something like this: telnet beru.cariboulake.com 8765[ENTER] GET /servlet/Servlet1 HTTP/1.0[ENTER] [ENTER] You should see the HTTP response from the servlet written to the console, eg: HTTP/1.1 302 Object moved Date: Mon, 09 Jul 2001 17:39:13 GMT Location: /servlet/Servlet2 If you don't see something like this, there may be a clue as to what's not working. - Fernando I removed all the out.writes from Servlet1. Infact all servlet1 does now is a response.sendReditect(/servlet/Servlet2); I've still gottn the error. Actually I did get an IlleagalStateException at first. I had my redirect after I closded the outputstream, thats why I moved the redirect before the close. However now as I mentioned earlier All servlet1 does is response.sendReditect(/servlet/Servlet2); I'm still convinced that I have something configured wrong. joe On 09 Jul 2001 09:57:57 -0400, [EMAIL PROTECTED] wrote: Your source shows that you write HTML to the outputstream before you send the redirect. I'm surprised an exception -- like IllegalStateException -- isn't thrown. Take out the out.println() calls from servlet 1 and it should work. - Fernando Joseph D Toussaint To: [EMAIL PROTECTED] jdtoussa@caribocc: (bcc: Fernando Salazar/CAM/Lotus) ulake.com Subject: RE: problem with getPort() 07/09/2001 08:57 AM Please respond to tomcat-user Ok now I'm convinced that I have something misconfigured. I wrote 2 simple servlets http://beru.cariboulake.com:8765/servlet/Servlet1 http://beru.cariboulake.com:8765/servlet/Servlet2 As you can see from the attached source all Servlet1 does is call Servlet2. I'm going to browse though some of the tomcat docs and see if I can find what is mis-configured. joe On 09 Jul 2001 07:34:28 -0400, Randy Layman wrote: That is strange, I use response.sendRedirect(otherPage.jsp) quite frequently. The only thing that I have found strange about this method is that you need to put a return on the next line - sending a redirect does not stop the JSPs processing. Randy -Original Message- From: Joseph D Toussaint [mailto:[EMAIL PROTECTED]] Sent: Monday, July 09, 2001 8:24 AM To: [EMAIL PROTECTED] Subject: RE: problem with getPort() Believe me I agree with you about JRun (hence why were moving to tomcat) ;) The more I think about this I think this is a tomcat configuration problem. After playing around some more I simply tried a response.sendRedirect(url); This brought me to a page that said This page has moved to here. If you click on here it goes to port 0 on my host. I think my next step is going to be to create 2 simple servlets and try and move between them. Because that is where the error is occuring. From a static HTML page I get to my first servlet fine but when that servlet tries to move on to the next servlet I have problems. joe On 09 Jul 2001 07:00:37 -0400, Randy Layman wrote: JRun is just about the last place I would look to find the correct implementation of any method. Tomcat implements the specification exactly (maybe only with minor variances that we haven't found yet). Since Tomcat is the reference implementation, there isn't really any choice in the implantation, unlike JRun and the other servlet engines, which can choose what they want to do. Randy -Original Message- From: Joseph D Toussaint [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 08, 2001 6:03 PM To: [EMAIL PROTECTED] Subject: RE: problem with getPort() I'm trying to create a new URL to go to. If I wanted to use the request.getPort() method I'd have to also call getHostName() and manually construct the URL. It was my understanding that the getRequestURL method did that for you. This code ran under JRun 3.x but for some reason wont run under tomcat. Thanks joe On 03 Jul 2001 16:27:54 -0400, Randy Layman wrote: Is there a reason that you aren't using request.getPort ()? -Original Message- From: Joseph D Toussaint [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 03, 2001 4:38 PM To: [EMAIL PROTECTED] Subject: problem with getPort() I'm trying to get the port off of a request object and it is returning port 0. Here is how I'm getting the URL I came from. StringBuffer came_from =
Re: Preventing Proxy Servers From Hitting JSP Pages?
Try creating a file named robots.txt at your web-server root. Put lines in the file like so: user-agent: * disallow: /webapp where webapp is the path to your web application. Spiders and similar clients should read this file and follow the directives there. Look here: http://www.robotstxt.org/wc/robots.html for more info. - Fernando David M. Rosner To: [EMAIL PROTECTED] dave@recommecc: (bcc: Fernando Salazar/CAM/Lotus) nd-it.com Subject: Preventing Proxy Servers From Hitting JSP Pages? 06/28/2001 02:44 PM Please respond to tomcat-user Hi All, Every day I get hundreds of hits on my JSP pages from proxy servers who are trying to determine if the links are still good. This is great for my static pages, but on pages with forms and processing logic it causes havoc. For example, if I have 3 pages of forms and the final page adds something to my database, hitting just the second page throws errors. I know that there is a pragma directive I need to add to each page, but isn't there also something that can be added to the HTTP header each time. And if so, what is the easiest way to add this to every outgoing header? Thanks, David M Rosner
Re: Socket problems under heavy load on Win2K
I think 61 is connection refused. My guess is that the accept() queue length is too small. Looking through Tomcat 4 source, it looks like the default accept backlog is 10. Possibly there's a way to increase it? You could always rebuild with a larger default. But if you are throwing a lot of simultaneous connections at Tomcat, you may overflow the accept backlog. The other possibility is you're running out of file descriptors. Not sure how you increase the number per process allowed in Win2K ... The CLOSE_WAIT sockets may or may not be a problem ... one end of the connection has been closed, and now you're waiting for the other end to finish and close. If someone is not closing their end, these sockets would hang around in that state a long time. Hope this helps ... - Fernando Hi all, we have the following configuration: - Windows 2000 (Service Pack 1) (2, 4 and 8 processors) - Apache 1.3.19 with mod_ssl 2.8.3 - Tomcat 3.2.2 (Apache and Tomcat are talking AJP13) - We have a loadbalancer configured with 3 Tomcat workers - Our load generating test clients are implemented using HttpUnit 1.2.4 + JSSE 1.0.2 On heavy load (starting from 50 concurrent requests up to 200 concurrent requests) we observe non-deterministic TCP/socket problems. It seems that in almost every case, the only place where we can see some kind of exception is the mod_jk log file: ... [jk_connect.c (143)]: jk_open_socket, connect() failed errno = 61 [jk_ajp13_worker.c (173)]: In jk_endpoint_t::connect_to_tomcat, failed errno = 61 [jk_ajp13_worker.c (584)]: Error connecting to the Tomcat process. [jk_ajp13_worker.c (203)]: connection_tcp_get_message: Error - jk_tcp_socket_recvfull failed [jk_ajp13_worker.c (619)]: Error reading request ... [jk_ajp13_worker.c (271)]: read_into_msg_buff: Error - read_fully_from_server failed [jk_lb_worker.c (349)]: In jk_endpoint_t::service, none recoverable error... ... Analysing the exceptions that are thrown from HttpUnit, it looks like that sometimes the socket cannot connect at all and sometimes the response could not be retrieved completely. Most errors occur in the early startup phase of our load test. Using netstat we can observe a *lot* of sockets in CLOSE_WAIT state connected to the AJP13 port. The settings we use in our Apache configuration are as follows: ... Timeout 300 KeepAlive On MaxKeepAliveRequests 500 KeepAliveTimeout 300 MaxRequestsPerChild 0 ThreadsPerChild 500 ... I would appreciate, if there is anyone who has gone through the same kind of problems or if there is some kind of solution that may help to solve these problems. Perhaps, if there is someone with an equivalent Linux-Setup, i would appreciate, if she/he could tell us some of her/his experience? Mit freundlichen Grüßen / Kind regards, Norbert Klose
Re: SERVLET : transform XSL+XML -OUTPUT = blank page
Doesn't getServletContext().getResourceAsStream (/WEB-INF/classes/login.xml)); have to be getServletContext().getResourceAsStream(/login.xml)); ? - fs |+--- || Pedro Salazar| || pedro-b-salazar@ptin| || ovacao.pt | || | || 06/27/2001 10:34 AM | || Please respond to| || tomcat-user | || | |+--- | | | | To: [EMAIL PROTECTED] | | cc: (bcc: Fernando Salazar/CAM/Lotus) | | Subject: SERVLET : transform XSL+XML -OUTPUT = blank page | | Greetings, I made a servlet where I try to produce a result to output stream of the response object that came from a transformation of XML + XSL. But, I just get a blank page in output...!? I put the same piece of code that exists in doGet() of my servlet in a isolated test class [but redirecting the output to a file]. I ran it and it works ok... Why my servlet doesn't give nothing to my client?? I put my code below. My servlet runs in the root / of my context. In my servlet, if I put a println of a string, i will saw the string, but just the string... thanks, Pedro Salazar --- SAMPLE ISOLATED --- ... Source xmlSource = null; Source xslSource = null; xmlSource = new javax.xml.transform.stream.StreamSource(login.xml); xslSource = new javax.xml.transform.stream.StreamSource(login.xsl); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(xslSource); transformer.transform(xmlSource, new StreamResult(new java.io.FileOutputStream(login.out))); ... --- SERVLET doGet() --- ... Source xmlSource = null; Source xslSource = null; PrintWriter out = null; xmlSource = new StreamSource ( getServletContext().getResourceAsStream(/WEB-INF/classes/login.xml)); xslSource = new javax.xml.transform.stream.StreamSource ( getServletContext().getResourceAsStream(/WEB-INF/classes/login.xsl)); Transformer transformer = tFactory.newTransformer(xslSource); response.setContentType(text/html; charset=UTF-8); out = response.getWriter(); transformer.transform(xmlSource, new StreamResult(out)); //out.println(OK); ...
Re: Tomcat not putting session objects into JSP page context? (repost...)
I think the problem is, you're using: Object obj = pageContext.getAttribute(loginBean); The JSP spec defines this as returning an object that occurs at *page* scope. Try instead: Object obj = pageContext.getAttribute(loginBean, pageContext.SESSION_SCOPE ); This should work. As to why the current stuff gives you the result you want in JRun or iPlanet, can't say -- I have heard that JRun is more forgiving -- ie, provides extra behaviours beyond the spec -- and maybe this is a case of that. - Fernando Hi all- I'm sorry for the repost but this is still stumping me. I'm using Tomcat 3.2.2 natively (over port 8080). - Original Message - From: Richard Sand To: [EMAIL PROTECTED] Sent: Friday, June 22, 2001 3:19 PM Subject: Tomcat not putting session objects into JSP page context? Hi all- I've got a JSP/Javabean application that works fine under JRun and iPlanet Web Server. However, when I use Tomcat, it does not seem to be instantiating new session variables if they don't already exist. In the top of my JSP page, I have: jsp:useBean id=loginBean class=LoginBean scope=session/ And further down in the page I do (actually inside a TagLib, but I tried it in the page as well as a test): Object obj = pageContext.getAttribute(loginBean); But obj comes back as null. If I try: LoginBean tlb = (LoginBean) session.getAttribute(loginBean); then I get the bean! Why is my call to pageContext failing to get loginBean, especially considering that this works on other Java application servers? Thanks for any help! Best regards, Richard
Re: Servlet HTTP path
You need to setup a servlet-mapping entry to map the servlet to a specific URL path. - Fernando Hi Id like to specify a specific sub folder path for a servlet however I am not having any luck doing so. I have defined the servlet in the web.xml file as servlet servlet-nameaccountingxmlServlet/servlet-name description Used for exchanging data between the web page and the servlet /description servlet-class com.lfi.accounting.servlet.xmlServlet /servlet-class /servlet and access this as http:\\foo:8080\bar\servlet\accountingxmlservlet. This works but what I would like to do is to define the servlet as servlet servlet-nameaccounting/xmlServlet/servlet-name description Used for exchanging data between the web page and the servlet /description servlet-class com.lfi.accounting.servlet.xmlServlet /servlet-class /servlet and access it as http:\\foo:8080\bar\servlet\accounting\xmlservlet but this doesnt work. Is there something Im missing or is this not possible ? any suggestion or help would be appreciated... My setup is Tomcat 3.2 , WinNT SP6 IIS 5 Thanks
Re: start up tomcat from a virtual terminal
Look up man page for nohup. This will start a process that continues executing after the console that created it is killed. You'll need a command line that looks like: nohup ./startup - Fernando Mario Vera mario.vera@infomTo: TOMCAT [EMAIL PROTECTED] ap.com.mx cc: (bcc: Fernando Salazar/CAM/Lotus) Subject: start up tomcat from a virtual terminal 06/20/2001 02:18 PM Please respond to tomcat-user Hi I have installed Tomcat 3.2 on SUN1 SERVER (O.S. Solaris 2.7),I start up Tomcat from a remote machine using a virtual terminal, if I close the terminal window, TOMCAT shut down too. I have tried to use Telnet to start up TOMCAT, but this way the X SERVER cannot started Any idea will be appreciated. Thank you