How to get name of Engine a servlet is running in?
I'm trying to gain access to the name of the Engine that a servlet is running in. In most cases this will be Catalina as configured in the /conf/server.xml file. But when another Engine is configured, say CatalinaTesting, I need to get that name instead. I've tried to navigate the methods and classes from: request.getSession().getServletContext() request.getSession() but I haven't been able to find the Engine name in any of the attributes or properties. Is there any way to get it? Actually, all I really need is a small string that's unique to each Engine configured on the server and stays the same after application deployments/restarts. What I'm currently using is code that grabs the last two directories in the root app path and concatenates them... something like webappsROOT or webappsTestingROOT. It's unique, but ugly. Thanks, Joe
Embedded Tomcat JDBC Issue
Any tips on how to get a JDBC connection going using the embedded version of Tomcat? Where does the MySql driver go? How is the JNDI resource configured? I've tried deploying a .war file with a context.xml, but have had some problems (below). Thanks, Joe -Original Message- From: Joe Reger, Jr. [mailto:[EMAIL PROTECTED] Sent: Sunday, May 29, 2005 3:56 PM To: tomcat-user@jakarta.apache.org Subject: Embedded Tomcat JNDI/JDBC Configuration Questions Hi! I've successfully created a project that embeds Tomcat. Excellent! I can see the sample page and the manager app, reporting Tomcat 5.5.9. Now I'm working on deploying a .war file programatically: public void registerWAR(String contextPath, String absolutePath) throws Exception { Context context = this.embedded.createContext(contextPath, absolutePath); context.setReloadable(false); this.host.addChild(context); } I pass in the path and the location of the .war file. When I run the application the .war file is found and exploded to the /ROOT directory properly. Inside of the .war file is a context.xml file. The jdbc/db resource is defined in context.xml, inside of the .war file with the following: Resource name=jdbc/db auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/db parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name valuefoo/value /parameter parameter namepassword/name valuebar/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/reger?autoReconnect=true/value /parameter /ResourceParams When I make a call to my application the code inside the .war file attempts to connect to the database like this: private static final String jndiPrePend = java:comp/env/; private static final String jndiDB = jdbc/db; public static Connection getConnection(){ Connection conn=null; try{ Context ctx = new InitialContext(); if(ctx != null){ DataSource ds = (DataSource)ctx.lookup(jndiPrePend + jndiDB); if(ds != null){ conn = ds.getConnection(); return conn; } } } catch (Exception e){ e.printStackTrace(); util.errorsave(e); } return null; } But I get the following error in the console window, repeatedly, each time my app tries to connect to the db: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory. java:132) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:792) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136) at javax.naming.InitialContext.lookup(InitialContext.java:351) at reger.db.RunSQL(db.java:64) at reger.db.RunSQL(db.java:124) at reger.scheduler.MasterThread.setupThread(MasterThread.java:377) at reger.scheduler.MasterThread.run(MasterThread.java:48) It looks like the jndi/jdbc resource isn't configured correctly and/or isn't available to the code from the .war file running inside of the embedded tomcat. Questions: 1) Is my jndiPrePend variable correct? It works for a standard deployment on a non-embedded tomcat. 2) Is there anything special I need to do to get a jndi/jdbc resource configured under the embedded tomcat? 3) Does the error message I'm seeing point to anything that I need to change? Thanks, Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Embedded Tomcat JNDI/JDBC Configuration Questions
Hi! I've successfully created a project that embeds Tomcat. Excellent! I can see the sample page and the manager app, reporting Tomcat 5.5.9. Now I'm working on deploying a .war file programatically: public void registerWAR(String contextPath, String absolutePath) throws Exception { Context context = this.embedded.createContext(contextPath, absolutePath); context.setReloadable(false); this.host.addChild(context); } I pass in the path and the location of the .war file. When I run the application the .war file is found and exploded to the /ROOT directory properly. Inside of the .war file is a context.xml file. The jdbc/db resource is defined in context.xml, inside of the .war file with the following: Resource name=jdbc/db auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/db parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name valuefoo/value /parameter parameter namepassword/name valuebar/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/reger?autoReconnect=true/value /parameter /ResourceParams When I make a call to my application the code inside the .war file attempts to connect to the database like this: private static final String jndiPrePend = java:comp/env/; private static final String jndiDB = jdbc/db; public static Connection getConnection(){ Connection conn=null; try{ Context ctx = new InitialContext(); if(ctx != null){ DataSource ds = (DataSource)ctx.lookup(jndiPrePend + jndiDB); if(ds != null){ conn = ds.getConnection(); return conn; } } } catch (Exception e){ e.printStackTrace(); util.errorsave(e); } return null; } But I get the following error in the console window, repeatedly, each time my app tries to connect to the db: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory. java:132) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:792) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136) at javax.naming.InitialContext.lookup(InitialContext.java:351) at reger.db.RunSQL(db.java:64) at reger.db.RunSQL(db.java:124) at reger.scheduler.MasterThread.setupThread(MasterThread.java:377) at reger.scheduler.MasterThread.run(MasterThread.java:48) It looks like the jndi/jdbc resource isn't configured correctly and/or isn't available to the code from the .war file running inside of the embedded tomcat. Questions: 1) Is my jndiPrePend variable correct? It works for a standard deployment on a non-embedded tomcat. 2) Is there anything special I need to do to get a jndi/jdbc resource configured under the embedded tomcat? 3) Does the error message I'm seeing point to anything that I need to change? Thanks, Joe
Tomcat Won't Start When 1024Mb JVM Memory Specified
Hi All! I'm trying to configure Tomcat to use 2.5Gb of memory on Windows 2000 Server SP4 with Java 1.4.2_04. To configure memory I'm using Start - Programs - Apache Tomcat 5.0 - Configure Tomcat - Java Tab. When I set the Maximum Memory Pool to anything greater than 1024Mb the Tomcat service bombs immediately and gives an error popup (when done from the Services control panel). Sorry, I didn't write down the error code. Is there a 1Gb limit on the JVM? On Tomcat? Should I configure by editing startup.bat/catalina.bat instead? I'm open to suggestions/workarounds. Thanks, Joe Reger
Limit stdout.log file size?
Hi, Is there any way to limit the file size of stdout.log? Thanks, Joe
RE: out of memory when there is plenty
Throw the following code into a jsp and view it. It'll give you a little graph showing you how much memory Tomcat can use, has allocated and is using. This will tell you if you've properly set the max memory value and may help you figure out what's happening. Best, Joe StringBuffer mb = new StringBuffer(); mb.append(font face=arial size=-1); mb.append(brbr); Runtime rt = Runtime.getRuntime(); mb.append(Maximum memory available: + rt.maxMemory() + br); mb.append(Total memory allocated: + rt.totalMemory() + br); mb.append(Free memory unused: + rt.freeMemory() + br); double used = 0; double free = 0; double available = 0; used = rt.totalMemory()-rt.freeMemory(); free = rt.freeMemory(); available = rt.maxMemory()-rt.totalMemory(); double usedpercent = (used/rt.maxMemory()) * 100; double freepercent = (free/rt.maxMemory()) * 100; double availablepercent = (available/rt.maxMemory()) * 100; mb.append(brbr); mb.append(table cellpadding=0 cellspacing=1 border=4 width=100% ); mb.append(tr); mb.append(td bgcolor=#ff width=+(int)usedpercent+% align=center); mb.append(font face=arial size=-2 color=#ff); mb.append(U); mb.append(/font); mb.append(/td); mb.append(td bgcolor=#00ff00 width=+(int)freepercent+% align=center); mb.append(font face=arial size=-2 color=#ff); mb.append(F); mb.append(/font); mb.append(/td); mb.append(td bgcolor=#cc width=+(int)availablepercent+% align=center); mb.append(font face=arial size=-2 color=#ff); mb.append(A); mb.append(/font); mb.append(/td); mb.append(/tr); mb.append(/table); mb.append(brbr); mb.append((int)used + bU/bsed - +(int)usedpercent+%br); mb.append((int)free + bF/bree - +(int)freepercent+%br); mb.append((int)available + bA/bvailable - +(int)availablepercent+%br); out.print(mb.toString()); -Original Message- From: Oleg [mailto:[EMAIL PROTECTED] Sent: Saturday, February 19, 2005 4:09 AM To: Tomcat Users List Subject: out of memory when there is plenty Windows 2003 Tomcat 5.0.28 Ok I searched and searched endless and still cannot understand what the problem in my case. Ok, I understand that there can be a leak in teh code and thats why Tomcat runs out of memory. However, the server got total 2GB Ram memory, Tomcat is set to use min 512, max 1024. When I start getting an out of memory error, Tomcat5 in task manager shows anywhere 350MB to 390MB, I run a script on the server to check Runtime and it shows that memeory usage is very low compared to max/min settings and there are about 600MB available. My question is what can cause Tomcat to report out of memory error when so much is still available. Thank you Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Missing application web.xml, using defaults only
Hi, I get the same error as Abhay when deploying a WAR file through the manager application. In my situation I do have the proper /WEB-INF/web.xml structure but I get the Missing application web.xml, using defaults only error. When I manually explode the WAR file the application works fine. More details on my situation in the archives. Best, Joe -Original Message- From: Peter Crowther [mailto:[EMAIL PROTECTED] Sent: Thursday, February 17, 2005 9:06 AM To: Tomcat Users List; Abhay Subject: RE: Missing application web.xml, using defaults only From: Abhay [mailto:[EMAIL PROTECTED] INFO: Missing application web.xml, using defaults only StandardEngine[a8050]. StandardHost[localhost].StandardContext[/OMS_ebiz] You probably have a WEB-INF directory in your webapp, but no web.xml file in it. Make one (or move it, or fix the name, or whatever the problem is). - Peter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Missing application web.xml, using defaults only
Do you know if that directory change is part of the manager application's WAR deployment process? -Original Message- From: Caldarale, Charles R [mailto:[EMAIL PROTECTED] Sent: Thursday, February 17, 2005 3:45 PM To: Tomcat Users List Subject: RE: Missing application web.xml, using defaults only From: Mike Fowler [mailto:[EMAIL PROTECTED] Subject: Re: Missing application web.xml, using defaults only I've been experiencing the problem randomly for several months, but I have been unable to pin down the cause or even more information about the error to make a guess as to the cause. I've noticed that Tomcat occasionally changes its current directory while running. Since the current directory applies to all threads in a given process, I'm wondering if one thread calling chdir() might pull the rug out from under another. Currently using 5.5.7 on a mainframe; I've noticed the same behavior with 5.0.28. - 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: FW: Re: Missing application web.xml Tomcat 5.5.7
Hi, Sorry for the confusion on the variable name. I undeploy the ROOT context that comes stock with Tomcat. I don't believe that this is a conflict with another app being installed at the same context name. Before each attempt to upload the ROOT.war file I manually shut down Tomcat and delete any /ROOT, ROOT.war and $CATALINA_HOME\conf\Catalina\localhost\ROOT.xml files so that the instance is clean. When I do the upload, Tomcat successfully moves ROOT.war to $CATALINA_HOME\webapps\ (I watch the directory manually). In the manager web interfact it says that the app is successfully installed and it lists a root context. But then, upon refreshing a few seconds later the app has been undeployed and the Missing application web.xml error appears in stdout. I can shutdown tomcat, clean all ROOT context references, manually explode the war file to $CATALINA_HOME\webapps\ROOT\, restart Tomcat and the app works perfectly. It seemed initially like Tomcat was having trouble extracting the war file but there was something I saw in the detailed log4j debugs or on the file system that made me believe that it was successfully able to get into the war, it just didn't like what it saw. I forget what I saw, but I believe that it was successfully reading in custom variables from my context.xml, inside of the war file. Thanks for the help, Joe -Original Message- From: sven morales [mailto:[EMAIL PROTECTED] Sent: Monday, February 14, 2005 11:31 PM To: Tomcat Users List Subject: RE: FW: Re: Missing application web.xml Tomcat 5.5.7 Hi, Using $CATALINA_HOME and or $CATALINA_BASE is the more proper way to describe those directory references. No I am not having trouble with web.xml file when deploying a WAR file. I'm trying to assist you troubleshoot. Are you trying to deploy an additional ROOT.war? There is an existing ROOT context that came as stock installed and this will most likely conflict with the new one with same name you are trying to deploy. So either remove the existing one or rename your ROOT.war to another name. aka_sergio --- Joe Reger, Jr. [EMAIL PROTECTED] wrote: Hi, I'm just using that to represent the root tomcat installation directory. For me it's C:\Superfly\Tomcat 5.5\. For you it may be different. Are you having any trouble with the web.xml file when deployinga WAR through the manager app? Joe -Original Message- From: sven morales [mailto:[EMAIL PROTECTED] Sent: Monday, February 14, 2005 1:12 PM To: Tomcat Users List Subject: Re: FW: Re: Missing application web.xml Tomcat 5.5.7 Hi, Where are you getting this $CatalinaRoot ? I don't see this env var set in catalina.sh. aka_sergio --- Joe Reger, Jr. [EMAIL PROTECTED] wrote: Hi All. I'm still having trouble with this issue. I'm not able to upload a .WAR file through the html web application manager but the same war manually exploded and placed into the /webapps directory works fine. I've included the web.xml to see if anybody can determine why Tomcat's rejecting it. I've Included the stdout log file. Some notes from the log4j tomcat debug file: Line 91: Tomcat has found the context.xml and moved it to $CatalinaRoot$\conf\Catalina\localhost\ROOT.xml Line 537: org.apache.catalina.core.StandardContext - Starting ROOT Line 7542: org.apache.catalina.startup.ContextConfig - Missing application web.xml, using defaults only Line 7744: org.apache.catalina.startup.HostConfig - Checking context[] redeploy resource C:\SuperFly\Tomcat 5.5\webapps\ROOT Line 7746: ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.core.StandardContext - Stopping Line 7825: Delete C:\SuperFly\Tomcat 5.5\webapps\ROOT.war Here's what I see when I deploy: Click upload. Tomcat moves ROOT.war into $CatalinaRoot$\webapps\. Context.xml, from inside the .war file seen in $CatalinaRoot$\conf\localhost. Application appears in manager/html. A few seconds later the application dissappears and all files are deleted. The tomcat sample war file appears to be broken too : http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample/ I'm open to suggestions. More info below. Thanks, Joe _ From: Joe Reger, Jr. [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 02, 2005 11:58 AM To: 'tomcat-user@jakarta.apache.org' Subject: Re: Missing application web.xml Hi! I'm having problems with the Missing application web.xml error on dev machines running Windows XP,. Tomcat 5.5.7, Java 5.0. It happens when I try to deploy a war file by using the Manager app or by placing it in the /webapps directory. Here are some of the things I've done, each time trying to deploy the resulting WAR file with no success and the same error: 1) Completely emptied the /webapps directory (per Paul's success below). 2
FW: Re: Missing application web.xml Tomcat 5.5.7
Hi All. I'm still having trouble with this issue. I'm not able to upload a .WAR file through the html web application manager but the same war manually exploded and placed into the /webapps directory works fine. I've included the web.xml to see if anybody can determine why Tomcat's rejecting it. I've Included the stdout log file. Some notesfrom thelog4j tomcat debugfile: Line 91: Tomcat has found the context.xml and moved it to $CatalinaRoot$\conf\Catalina\localhost\ROOT.xml Line 537: org.apache.catalina.core.StandardContext - Starting ROOT Line 7542: org.apache.catalina.startup.ContextConfig - Missing application web.xml, using defaults only Line 7744: org.apache.catalina.startup.HostConfig - Checking context[] redeploy resource C:\SuperFly\Tomcat 5.5\webapps\ROOT Line 7746: ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.core.StandardContext - Stopping Line 7825: Delete C:\SuperFly\Tomcat 5.5\webapps\ROOT.war Here's what I see when I deploy: Click upload. Tomcat moves ROOT.war into $CatalinaRoot$\webapps\. Context.xml, from inside the .war file seen in $CatalinaRoot$\conf\localhost. Application appears in manager/html. A few seconds later the application dissappears and all files are deleted. The tomcat sample war file appears to be broken too: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample/ I'm open to suggestions. More info below. Thanks, Joe From: Joe Reger, Jr. [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 02, 2005 11:58 AMTo: 'tomcat-user@jakarta.apache.org'Subject: Re: Missing application web.xml Hi! I'm having problems with the "Missing application web.xml" erroron dev machines running Windows XP,. Tomcat 5.5.7, Java 5.0. It happens when I try to deploy a war file by using the Manager app or by placing it in the /webapps directory. Here are some of the things I've done, each time trying to deploy the resulting WAR file with no success and the same error: 1) Completely emptied the /webapps directory (per Paul's success below). 2) Verified existence of web.xml inside WAR file. 3) Uninstalled ROOT app and verified file removal from /webapps directory. 4) Checked order of elements in web.xml to fit spec. 5) Validated web.xml in Intellij Idea against http://java.sun.com/dtd/web-app_2_3.dtd 6) Changed web-app tag from the sample web.xml in documentation to the one used in Manager app from 5.5.7 build: web-app xmlns="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" 7) Removed all comments and spaces from web.xml. When I unpack theWAR manually and place theunpacked files in /webapps the application works fine. Tomcat likes the web.xml, but it can't seem to find it inside of the WAR file. Incidentally, when I watch my /webapps directory during a Manager deploy, the ROOT.war file does appear for a few seconds. It appears that Tomcat is trying to find a web.xml inside of it, fails and then deletes the file. I use Ant to build the WAR file: jar jarfile="ROOT.war"fileset dir="${files}" excludes="**/*.java"//jar Any help appreciated. Seen this on two development XP machines today. Best, Joe Reger ---Original MessageI just wanted to follow up and get into the record what I think is the solution to the problem I asked about on 1/20. I turns out that the reason I was getting "Missing application web.xml" errors in my stdout.log was because of a problem that arose during the undeployment precipitated by my deployment of a new build. It appears (just based on Tomcat's behavior) that when you move a WAR file into the webapps directory, the first thing Tomcat tries to do is delete the old unpacked version. In my case, it failed to do that because (as I found) the servlet had open file handles to files inside the servlet's context directory. Windows XP doesn't let you delete files that it thinks are "in use", and I suspect that is the trouble Tomcat was running into. Anyway, it deleted everything except those files, including the web.xml file, which it then reported as missing. When I modified my code to make sure the files were closed after being read, the problem went away. Well, I haven't had the fix in place long enough to be sure it has gone away, but at the very least it certainly seems to have helped a great deal, so I think the problem is solved. --Paul Lynch (eph1v3t8 @ mailblocks.com) ?xml version=1.0 encoding=ISO-8859-1? !-- !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; -- web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-
RE: FW: Re: Missing application web.xml Tomcat 5.5.7
Hi, I'm just using that to represent the root tomcat installation directory. For me it's C:\Superfly\Tomcat 5.5\. For you it may be different. Are you having any trouble with the web.xml file when deployinga WAR through the manager app? Joe -Original Message- From: sven morales [mailto:[EMAIL PROTECTED] Sent: Monday, February 14, 2005 1:12 PM To: Tomcat Users List Subject: Re: FW: Re: Missing application web.xml Tomcat 5.5.7 Hi, Where are you getting this $CatalinaRoot ? I don't see this env var set in catalina.sh. aka_sergio --- Joe Reger, Jr. [EMAIL PROTECTED] wrote: Hi All. I'm still having trouble with this issue. I'm not able to upload a .WAR file through the html web application manager but the same war manually exploded and placed into the /webapps directory works fine. I've included the web.xml to see if anybody can determine why Tomcat's rejecting it. I've Included the stdout log file. Some notes from the log4j tomcat debug file: Line 91: Tomcat has found the context.xml and moved it to $CatalinaRoot$\conf\Catalina\localhost\ROOT.xml Line 537: org.apache.catalina.core.StandardContext - Starting ROOT Line 7542: org.apache.catalina.startup.ContextConfig - Missing application web.xml, using defaults only Line 7744: org.apache.catalina.startup.HostConfig - Checking context[] redeploy resource C:\SuperFly\Tomcat 5.5\webapps\ROOT Line 7746: ContainerBackgroundProcessor[StandardEngine[Catalina]] org.apache.catalina.core.StandardContext - Stopping Line 7825: Delete C:\SuperFly\Tomcat 5.5\webapps\ROOT.war Here's what I see when I deploy: Click upload. Tomcat moves ROOT.war into $CatalinaRoot$\webapps\. Context.xml, from inside the .war file seen in $CatalinaRoot$\conf\localhost. Application appears in manager/html. A few seconds later the application dissappears and all files are deleted. The tomcat sample war file appears to be broken too : http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample/ I'm open to suggestions. More info below. Thanks, Joe _ From: Joe Reger, Jr. [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 02, 2005 11:58 AM To: 'tomcat-user@jakarta.apache.org' Subject: Re: Missing application web.xml Hi! I'm having problems with the Missing application web.xml error on dev machines running Windows XP,. Tomcat 5.5.7, Java 5.0. It happens when I try to deploy a war file by using the Manager app or by placing it in the /webapps directory. Here are some of the things I've done, each time trying to deploy the resulting WAR file with no success and the same error: 1) Completely emptied the /webapps directory (per Paul's success below). 2) Verified existence of web.xml inside WAR file. 3) Uninstalled ROOT app and verified file removal from /webapps directory. 4) Checked order of elements in web.xml to fit spec. 5) Validated web.xml in Intellij Idea against http://java.sun.com/dtd/web-app_2_3.dtd 6) Changed web-app tag from the sample web.xml in documentation to the one used in Manager app from 5.5.7 build: web-app xmlns=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 7) Removed all comments and spaces from web.xml. When I unpack the WAR manually and place the unpacked files in /webapps the application works fine. Tomcat likes the web.xml, but it can't seem to find it inside of the WAR file. Incidentally, when I watch my /webapps directory during a Manager deploy, the ROOT.war file does appear for a few seconds. It appears that Tomcat is trying to find a web.xml inside of it, fails and then deletes the file. I use Ant to build the WAR file: jar jarfile=ROOT.war fileset dir=${files} excludes=**/*.java/ /jar Any help appreciated. Seen this on two development XP machines today. Best, Joe Reger ---Original Message I just wanted to follow up and get into the record what I think is the solution to the problem I asked about on 1/20. I turns out that the reason I was getting Missing application web.xml errors in my stdout.log was because of a problem that arose during the undeployment precipitated by my deployment of a new build. It appears (just based on Tomcat's behavior) that when you move a WAR file into the webapps directory, the first thing Tomcat tries to do is delete the old unpacked version. In my case, it failed to do that because (as I found) the servlet had open file handles to files inside the servlet's context directory. Windows XP doesn't let you delete files that it thinks are in use, and I suspect that is the trouble Tomcat was running into. Anyway, it deleted everything except those files
Re: Missing application web.xml
Hi! I'm having problems with the Missing application web.xml error on dev machines running Windows XP,. Tomcat 5.5.7, Java 5.0. It happens when I try to deploy a war file by using the Manager app or by placing it in the /webapps directory. Here are some of the things I've done, each time trying to deploy the resulting WAR file with no success and the same error: 1) Completely emptied the /webapps directory (per Paul's success below). 2) Verified existence of web.xml inside WAR file. 3) Uninstalled ROOT app and verified file removal from /webapps directory. 4) Checked order of elements in web.xml to fit spec. 5) Validated web.xml in Intellij Idea against http://java.sun.com/dtd/web-app_2_3.dtd 6) Changed web-app tag from the sample web.xml in documentation to the one used in Manager app from 5.5.7 build: web-app xmlns=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 7) Removed all comments and spaces from web.xml. When I unpack the WAR manually and place the unpacked files in /webapps the application works fine. Tomcat likes the web.xml, but it can't seem to find it inside of the WAR file. Incidentally, when I watch my /webapps directory during a Manager deploy, the ROOT.war file does appear for a few seconds. It appears that Tomcat is trying to find a web.xml inside of it, fails and then deletes the file. I use Ant to build the WAR file: jar jarfile=ROOT.war fileset dir=${files} excludes=**/*.java/ /jar Any help appreciated. Seen this on two development XP machines today. Best, Joe Reger ---Original Message I just wanted to follow up and get into the record what I think is the solution to the problem I asked about on 1/20. I turns out that the reason I was getting Missing application web.xml errors in my stdout.log was because of a problem that arose during the undeployment precipitated by my deployment of a new build. It appears (just based on Tomcat's behavior) that when you move a WAR file into the webapps directory, the first thing Tomcat tries to do is delete the old unpacked version. In my case, it failed to do that because (as I found) the servlet had open file handles to files inside the servlet's context directory. Windows XP doesn't let you delete files that it thinks are in use, and I suspect that is the trouble Tomcat was running into. Anyway, it deleted everything except those files, including the web.xml file, which it then reported as missing. When I modified my code to make sure the files were closed after being read, the problem went away. Well, I haven't had the fix in place long enough to be sure it has gone away, but at the very least it certainly seems to have helped a great deal, so I think the problem is solved. --Paul Lynch (eph1v3t8 @ mailblocks.com)
Manually Populate Request Object Name/Value Parameters?
The scenario is a timed-out login session: The user writes a wonderful something in a web page form. They finally submit it but I have to redirect to the login page to collect credentials because the session has timed out. Question: Is there any way to restore that original request (with the user's hard work in it) and throw it back at the page the user was trying to hit after I collect credentials? If not then prior to redirecting for login I'd like to store the name/value pairs from the request in the session, collect login credentials and then rebuild the request manually by setting the URL and name/value request parameters? I'm using a homebrew login scheme. Would switching to form-based authentication automatically restore the original request once the user is logged-in? Thanks, Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
WAR file and context.xml overwriting on deployment
Hi. I have a java web app that I package as a WAR file. People download it. They install it on their instance of Tomcat. They configure application settings as variables in context.xml. The problem is that each time they grab updated code (a new WAR file) they overwrite their context.xml file with the default settings. Is there some more user-friendly way to deal with this configuration issue? How do others that provide downloadable WAR files do this? I understand that this may not be the traditional usage of WAR files and Tomcat. Ideas welcome. Thanks, Joe Reger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Configure Tomcat's Session Cookie Domain?
Hi. Is there any way to specify the domain of the cookie that Tomcat sets to maintain session across requests? In java there's javax.servlet.http.Cookie.setDomain(java.lang.String pattern) that allows me to set it to something like .joereger.com... which allows a cookie to persist across one.joereger.com, two.joereger.com, three.joereger.com and so on. Anything like this in Tomcat's configuration? I've also looked into the jsp:useBean tags but haven't found anything that does what I'm looking for. Thanks, Joe Reger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Embedded Tomcat deploying WAR with URL of type jar:
Hi. I have a question regarding the embedded version of Tomcat. I'd like to have a java program start an instance of Tomcat and then deploy a WAR file to it. ... URL warFile = new URL(jar:C:/source/ROOT.war); Deployer deployer = (Deployer)host; deployer.install(/ROOT, warFile); ... I get the following error on the first line above: java.net.MalformedURLException: no !/ in spec This appears to be a known issue with Java: http://archives.java.sun.com/cgi-bin/wa?A2=ind0311L=jini-usersF=S=P=1044 6 But in the Tomcat API doc I see A URL of type jar: that points to a WAR file, or type file: that points to an unpacked directory structure containing the web application to be installed : http://jakarta.apache.org/tomcat/tomcat-5.0-doc/catalina/docs/api/org/apache /catalina/Deployer.html#install(java.net.URL,%20java.net.URL) Summary: I'd like to use a URL of type jar: but I can't seem to get it working. Any help appreciated. Sorry for the long message. Joe Reger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Configure Tomcat's Session Cookie Domain?
Thanks. What I suspected. Is this to adhere to a spec, or simply functionality not (yet?) developed for Tomcat? I've created a workaround session manager that manually sets its own cookies. One result being that my scaling strategy can't rely on the session replication of Tomcat... I'll have to use a firewall with sticky sessions. But enough whining from me... like always, there's a workaround. Best, Joe -Original Message- From: Tim Funk [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 16, 2004 7:12 PM To: Tomcat Users List Subject: Re: Configure Tomcat's Session Cookie Domain? Nope. Can't do it. But if you really need it to be more domain generic - there is nothing stopping you from expiring the JSESSIONID cookie and setting a newer one at a more generic level. (But this will probably cause future issues) -Tim Joe Reger, Jr. wrote: Hi. Is there any way to specify the domain of the cookie that Tomcat sets to maintain session across requests? In java there's javax.servlet.http.Cookie.setDomain(java.lang.String pattern) that allows me to set it to something like .joereger.com... which allows a cookie to persist across one.joereger.com, two.joereger.com, three.joereger.com and so on. Anything like this in Tomcat's configuration? I've also looked into the jsp:useBean tags but haven't found anything that does what I'm looking for. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat WAR Deployment Issue with 5.0.6
Two WAR files. Exactly the same, but with different names: myApp-(bld1035)-2003-08-07-(01-33-55PM).war myApp.war Both WARs have the same /META-INF/context.xml file with the line: Context path=/myApp docBase=myApp debug=1 reloadable=true crossContext=true On a clean Tomcat 5.0.6 I use /manager's Select WAR file to upload feature, upload the first WAR (myApp-(bld1035)-2003-08-07-(01-33-55PM).war) and click Deploy. It doesn't work. Two applications are created. One called myApp and one called myApp-(bld1035)-2003-08-07-(01-33-55PM). Neither works. myApp has the context but no files. myApp-(bld1035)-2003-08-07-(01-33-55PM) has the files but no context. That's odd. So I clean up Tomcat (removing the apps, remove the /conf/Catalina/localhost/myApp.xml file, restart Tomcat, etc.) and then upload myApp.war (the exact same file, just renamed) and it works correctly. With Tomcat 5.0.2 there was no dependency on the name of the WAR file itself. Any ideas? Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Nightly Build - What's the /manager app's default username/password?
I just installed the 8/6 nightly. What is the username/password by default for the /manager app? I usually set it in the installer but there wasn't an installer this time. Thanks, Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: 500 Custom Error
500's are tough... Doesn't putting this in web.xml call a custom 500 error page called 500.jsp? error-page error-code500/error-code location/error/500.jsp/location /error-page -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 30, 2003 8:59 AM To: Tomcat Users List; Kenneth Brooks Howdy, Are Custom Error pages available for 500 errors? 500's are tough, as they are internal server (i.e. not your webapp's) errors. I don't recall the spec on this point, but at some point I thought error page customization only had to be available for 300 and 400 range HTTP status. As 500's can occur anywhere in the request processing pipeline, it's difficult to provide the custom error page hook for them. This is under tomcat 4.0.4. (Although production will be under 4.1.24) Not a good idea: there are significant differences between the 4.0.x and 4.1.x branch of tomcat, and you should at least test, if not develop, on 4.1.24 before deploying to it. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to configure
Ted, It's a religious sort of thing (coder vs. designer) (system architect vs. usability analyst) (technology vs. sales). To make systems more stable and portable we need case sensitivity. To make systems easier to use designers relax restrictions to make systems a little easier to deal with. Does portability outweigh the user's need to do finger gymnastics? Who knows. Like anything in life there's always a tradeoff. You're speaking in a very code-oriented forum right now. You might also want to check out a usability forum for another perspective. Bottom line with Tomcat... case insensitive is not possible. But you can explore case insensitivity for passwords, usernames, etc. Many times those are the areas where case sensitivity can more severly affect application usability. My humble (and uninformed) opinion is that users don't type URLs much. They search and click. Or they type a domain-level URL and click. Or they bookmark and click. But they all have to log on at some point (most systems). Which brings up the mathematical argument that case insensitive passwords are easier to break... which brings up the usability argument that if users can't log in they won't use the system... which brings up the argument that users won't use a system that's insecure... And on and on... Good luck, Joe -Original Message- From: John Turner [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2003 10:53 AM To: Tomcat Users List The JDK is case sensitive. Java is case sensitive. Case sensitive web applications are portable. Case insensitive web applications are not. Case sensitive installations are portable. Case insensitive installations are not. 'nuf said. John On Tue, 1 Jul 2003 10:40:00 -0400, [EMAIL PROTECTED] wrote: Why shouldn't I want to configure for case insensitivity? What does it really matter whether I type http://some.server.com/Folder/MyPage.jsp -or simply, without the finger gymnastics - http://some.server.com/folder/mypage.jsp --( Forwarded letter 1 follows )- Date: Tue, 1 Jul 2003 09:03:10 -0500 To: [EMAIL PROTECTED] From: [EMAIL PROTECTED] Sender: [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] Subject: Re: How to configure you can't (and shouldn't ;-) from tomcat release notes... 6.6 URL's are now case sensitive on all operating systems As of Tomcat 3.2, URL's are case sensitive for all operating systems, including operating systems which have case insensitive file systems, such as Windows. This represents a change from Tomcat 3.1, where URL's were case insensitive on case insensitive OS's. This was done for a number of reasons, security and portability among them. A non-portable web application, i.e. one with case mismatches, which worked on a case insensitive OS under Tomcat 3.1 will show its non-portability when run under Tomcat 3.2 and later. On Tue, Jul 01, 2003 at 09:46:00AM -0400, [EMAIL PROTECTED] wrote: Tomcat URLs to NOT be case-sensitive. TIA, Ted - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Sean Bruton[EMAIL PROTECTED] Senior EngineerNetwork Services NeoSpire, Inc. www.neospire.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Bahavior of url-pattern in Tomcat 5.0.2
Hi! I'm working with the servlet-mapping tag in web.xml running on Tomcat 5.0.2. In particular, I'm working with the url-pattern schemes. I've got a simple Hello World!-style servlet that I'm trying to map various URLs to. Below I list some samples and my results. Why does Test 3 fail? Shouldn't I be able to define a mapping like *-foo.joetest? It's very similar to Test 2. Why does Test 2 work (*.joetest) but Test 5 fail (*.joetest.foo)? It seems that I can't really use the wildcard character in a traditional sense. There are some other rules. If these are desired behaviors, is there a reference for url-pattern tag rules? Thanks, Joe Test 1 --- (Basic example.) servlet-mapping servlet-namejoetest/servlet-name url-pattern/joetest/url-pattern /servlet-mapping This works for URL: http://localhost/myapp/joetest Test 2 --- (Basic wild card mapping to servlet.) servlet-mapping servlet-namejoetest/servlet-name url-pattern*.joetest/url-pattern /servlet-mapping This works for URL: http://localhost/myapp/89j98jh8hjl.joetest This works for URL: http://localhost/myapp/anything.joetest This works for URL: http://localhost/myapp/.joetest Test 3 --- (Adding something other than the . to the right of the wildcard.) servlet-mapping servlet-namejoetest/servlet-name url-pattern*-foo.joetest/url-pattern /servlet-mapping Does NOT work for: http://localhost/myapp/687-foo.joetest Does NOT work for: http://localhost/myapp/*-foo.joetest Does NOT work for: http://localhost/myapp/-foo.joetest Test 4 --- (Trying to add the absolute path reference.) servlet-mapping servlet-namejoetest/servlet-name url-pattern/*-foo.joetest/url-pattern /servlet-mapping This works for URL: http://localhost/myapp/*-foo.joetest (Note that the * above is the actual * character typed into the browser.) Test 5 --- (Similar to Test 2 but with a twist.) servlet-mapping servlet-namejoetest/servlet-name url-pattern*.joetest.foo/url-pattern /servlet-mapping Does NOT work for: http://localhost/myapp/6872434ef.joetest.foo Does NOT work for: http://localhost/myapp/*.joetest.foo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Custom 500 error page
I'm having the same problem on Tomcat 5.0.2. Tried restarting the app. Then tried restarting Tomcat. Then rebooted the machine. Still getting the stack trace. I assumed for a while that I had a compilation error in my error.jsp so I made error.jsp a very simple page with no code. It still isn't working. Open to suggestions. Thanks, Joe -Original Message- From: Nate [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 1:22 PM To: Tomcat Users List For future reference, I just upgraded from 4.1.18 to 4.1.24, and that fixed the issue. - Original Message - From: Nate [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Friday, June 27, 2003 11:38 AM Subject: Re: Custom 500 error page What version of Tomcat are you running? Perhaps I need to upgrade. - Original Message - From: Tim Davidson [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Friday, June 27, 2003 11:34 AM Subject: RE: Custom 500 error page The change notes are in the distribution under release-notes.txt. This works for me: error-page error-code500/error-code location/jsp/errorPage.jsp/location /error-page -Original Message- From: Nate [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 5:15 PM To: Tomcat Users List Subject: Custom 500 error page Hi all, I'm using tomcat 4.1.18 and am having a problem with custom error pages. I have included the following in my global web.xml file error-page error-code500/error-code location/server_err.jsp/location /error-page however, when a 500 error is returned, it still shows the stack trace instead of my custom page. Has anybody seen this before? I've tried to search the archives, but they are currently unavailable. While I'm at it, where can I track down a changelog form 4.1.18 to 4.1.24? Thanks.. Nathan McMinn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Log4j and Tomcat howto?
Does anybody know of a Log4j and Tomcat HOWTO? I've seen lots of info out there on Log4j and command line Java but little on Log4j in a Tomcat container. I'd like to see sample Logger... config tags for context.xml, sample log4j.properties files and where to put the log4j.jar file so that it's accessed correctly. It would also be great to see a sample JDBCLogAppender in action. Thanks, Joe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Log4j problem mixing 2 apps
Thanks to all for the recommendations. Good reading. Bottom line goals I have: 1) All exceptions logged through one package... jsp compilation errors, sql errors... errors that are caught by try/catch... errors that are not caught by try/catch... debug and trace that coders write... 2) I want my entire app to fit into a single WAR file with no other configuration. In other words, aside from jdk/tomcat, no server-level configuration. This doesn't mean that server config isn't done... but that it's done from within my build/deploy process (i.e. my META-INF/context.xml appends server.xml). Prabhat's link seems to address elements of this. But... my possibly incorrect understanding of the Logger/ tag in Tomcat is that it defines the package that will log anything that Tomcat thinks I need to see. What's the catch-all that I'm looking for? While I agree that it's standard practice to catch all exceptions, coders sometimes don't adhere to it. Sounds like my first goal may be impossible. Sounds like I need two things: 1) %@ page errorPage=error.jsp % on each jsp page and then on error.jsp write the most recent uncaught exception to the database 2) Log4j or similar to log caught exceptions What gives the rest of you comfort that you're seeing all errors that your app is generating? Thanks, Joe -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 1:55 PM To: Tomcat Users List Howdy, I read Ceki's article at http://qos.ch/logging/sc.html . Tomcat already has an implementation of the CRS, right? Is there a how-to document somewhere that explains how to configure Tomcat to use it? No to the first question, and therefore no to the second one as well. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]