Re: Mark certain contexts inactive?

2005-10-06 Thread Rob Hills
Hi Scott,

On 6 Oct 2005 at 13:43, Scott Purcell wrote:

 On my development machine, I have created quite a few contexts or webapp 
 instances, and due to that fact, the startup time is increasing. I do not 
 want to remove any of the contexts as they all mean something to me, but I 
 would like to be able to mark them so they do not start up. And then be 
 able to turn them on when needed. 
 
 Is there a clean way of doing this? 

Not sure that you can do much at the Context level, but have you 
looked at the deployOnStartup attribute of the Host element in your 
server.xml file?  As I understand it, if that is set to false, it will prevent 
a 
Host from being deployed until the server receives a request for that 
application.

I usually create a new Host for each web application rather than adding 
contexts under the default host.  The only functionality I lose this way is 
automated deployment of a _new_ application, but the benefits 
outweigh that loss for me.  One benefit is the ability to stop an 
application from loading up on startup.

HTH,

Rob Hills
Western Australia

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tracking Datasource Connection Usage?

2005-10-06 Thread Rob Hills
Hi,

On 6 Oct 2005 at 15:09, JWM wrote:

 I started getting exceptions saying no connections were available on my JDBC
 datasource  (org.gjt.mm.mysql.Driver).  The pool was definitely large enough
 to handle the load.  So it appears that I'm not freeing the all the
 connections as I should.  I noticed that I did not have the
 'removeAbandoned' flag set on the Resource tag.  Changing that has
 apparently fixed the out of connections problem.  But I really want to clean
 up the code and fix it the right way.  I've got the close() statements in
 place.  But obviously, I'm missing some of them somewhere.  Is there any
 process for logging/tracking allocating and freeing connections (and absence
 thereof.), available connections, etc?  Or are there any methods I can call
 to give me this type of debug info?  What's the recommended way to debug
 this?

There have already been useful tips on debugging, but I've found that 
the most common way to chew up connections is to not put the code 
that frees the conneciton inside a finally {} block.  If you don't free the 
connection in a finally {} block, it may not be freed if an exception 
occurs.

HTH,

Rob Hills
Western Australia


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Installing Tomcat 5.5 on Fedora 4 via Yum

2005-09-30 Thread Rob Hills
Hi All,

I'm a relative newbie to Linux but I've successfully managed to get TC 
5.0 up and running with Sun's JDK 1.5 after much Googling.

I've also managed to do this using Yum (thanks to JPackage) so far to 
make it easier to keep things up to date.

However, I've so far been unsuccessful in finding any way to upgrade 
Tomcat beyond 5.0 using Yum.  Has anyone else achieved this?

If anyone on this list happens to know, it'd be nice to find out when TC 
5.5 will be considered stable enough to make it to the RedHat 
downloads

TIA,

Rob Hills
Western Australia

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Does Tomcat run better on Linux or Windows?

2005-08-30 Thread Rob Hills
Hi All,

On 30 Aug 2005 at 18:12, Caldarale, Charles R wrote:

  From: Brian Cook [mailto:[EMAIL PROTECTED] 
  Subject: Re: Does Tomcat run better on Linux or Windows?
  
  The only thing that comes to mind is that you have to 
  reboot windows every time you need to make a change to 
  the CLASSPATH, JAVA_HOME, or TOMCAT_HOME variables 
 
 That's simply not true. Opening up a new instance of the command prompt
 will pick up any modified or added environment variables.  (But don't
 construe this statement as an endorsement of Windows over Linux, by any
 means.)

That is correct, but many of us run Tomcat as a Service.  I've not yet 
been able to find a way of changing environment variables in Windows 
and have the OS pick up the changes and pass them to a service (no 
matter how often you stop and start the service) without rebooting.

Cheers,

Rob Hills
MBBS, Grad Dip Com Stud, MACS
Senior Consultant
Netpaver Web Solutions
Tel:(08) 9485 2555
Mob:(0412) 904 357
Fax:(08) 9485 2555



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: configuration files for war deployments

2005-08-28 Thread Rob Hills
Hi Patrick,

On 26 Aug 2005 at 17:24, QM wrote:

 On Fri, Aug 26, 2005 at 02:16:26AM +0800, Patrick Lacson wrote:
 : I know that's typically where they go, but if the file is inside the
 : .war, how is the file going to be configured by the sysadming folks?

Our approach to this problem has been to:

1.  Have a configuration file with application-specific properties 
that lives in the WEB-INF tree and is loaded in the usual way via a 
context-parameter reference in web.xml.  This file contains properties 
that vary from one application to another, but are the same for every 
server.

2.  Within our application-specific properties file (I'll call it 
myapp.properties, we define a relative reference to a server-
specific properties file (myapp.local.properties).  That file is then 
located and loaded by code that tries several different ways to locate 
the local properties file - see below

On our app server, we define a directory that contains all of our 
configuration files.  Each application's configuration files is in its own 
subdirectory under the main config directory.  So, for example, if our 
main config directory is c:\serverconfig, under this will be a 
subdirectory for each web application, containing that web application's 
configuration file(s) - c:\serverconfig\myapp1 etc..

The main configuration path (c:\serverconfig in the example above) is 
then placed in Tomcat's class path - in my development environment 
(windoze) I do this by opening the Tomcat configuration applet and 
adding it to the Java Classpath on the Java tab.

As mentioned before each application's properties file contains a 
relative reference to it's local properties file.  So our application 
myapp1 will have in its myapp1.properties file (in its WEB-INF 
directory) a property called local-properties-path with the value 
myapp1/myapp1.local.properties.

In our application, we locate the local properties file by:
1.  using the .getClassLoader().getResourceAsStream(..) method 
first (using the relative path loaded from our application properties file, it 
could also probably come straight from a context-parameter in web.xml 
I guess);
2.  If that fails to locate the file, we then recursively load the 
classloader's parent (using the .getClassLoader().getParent() method) 
and use that to try and load the file, either until we find it, or until we 
reach the top parent;
3.  If we've still not located the file, we try simply instantiating a File 
object using the relative path;

Using this methodology, we've been able to load local server-specific 
properties files in Tomcat on Windows and in OC4J on Windows and 
Unix (don't have the actual OS to hand sorry).

HTH,

Rob Hills
MBBS, Grad Dip Com Stud, MACS
Senior Consultant
Netpaver Web Solutions
Tel:(08) 9485 2555
Mob:(0412) 904 357
Fax:(08) 9485 2555



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie: Connection refused first time on Tomcat

2005-07-26 Thread Rob Hills
Hi Bruce, 

On 25 Jul 2005 at 18:39, Bruce E. Stemplewski wrote: 

 Where does this get installed?  Remember, I am a total newbie at this. 
  
 And do I even need this?  The error says: 
  
 This release of Apache Tomcat was packaged to run on J2SE 5.0 
 or later. It can be run on earlier JVMs by downloading and 
 installing a compatibility package from the Apache Tomcat 
 binary download page. 
  
 But my Tomcat JVM setting is at: 
  
 C:\Program Files\Java\jre1.5.0_04\bin\client\jvm.dll 
  
 Isn't 1.5.0   J2SE 5.0? 

Basically yes, though there's a difference between the JRE and J2SE - the  
latter includes a compiler, though I seem to recall that recent versions of  
Tomcat are no longer dependant on having access to the Java compiler. 

I suspect you may have a path problem here. 

A trap for the unwary Windows player is that, as far as I am aware, Tomcat  
(and Java) struggle with Windows' standard approach to paths with spaces  
in them.  What I mean by that is that Windows mostly copes happily with  
paths with spaces in them, whereas programs like Java require such paths  
to be inside quotes. 

IIRC, by default, the tomcat installer puts at least one space in the path 
(  
Tomcat 5.5 - between Tomcat and 5 - there will be at least one more if you  
put it in the C:\Program Files\ directory), but doesn't put any quotes around  
that path in program settings and shortcuts, so installation using the default  
settings on Windows simply doesn't work.  Note, this problem may have  
been fixed in recent versions - I now habitually ensure I have no spaces in  
the tomcat (or JVM) path when I install it.  If you have any spaces in the  
path, I suggest you: 

1.  Uninstall Tomcat and the JVM/JRE 
2.  Reinstall being sure to choose paths for Tomcat and the JRE that  
have no spaces in them - be sure to remove the space in the path the  
installer offers for Tomcat (Tomcat 5.5) - it's not always obvious. 

HTH, 

Rob Hills 
www.netpaver.com.au 
West Perth, Western Australia 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic server configuration...

2005-07-21 Thread Rob Hills
Hi Rodrigo,

On 21 Jul 2005 at 19:12, Rodrigo Spievak Cavalcanti wrote:

 Is there any way to change tomcat engine configuration at runtime, 
 without restarting the entire engine ? Some kind of dynamic engine 
 configuration, being able to change hosts, add hosts, and changing host 
 configurations ?

As far as I am aware, Tomcat currently has to be restarted if anything that is 
configured in server.xml is changed, whether by editing server.xml directly 
or by changing it using the Admin console.

I have previously asked a question on this list about automated 
management of server.xml (eg via an api or whatever) but have not 
received a reply to date.

Rob Hills
www.netpaver.com.au
Western Australia

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Error 500 messages

2005-07-21 Thread Rob Hills
Hi Adile,

On 21 Jul 2005 at 19:09, Adile Abbadi wrote:

 Now I did a little more experimenting and discovered something interesting -
 as I said I can get an exception to be thrown to the page in a simple JSP
 file (I made it do a null pointer for example) and I can get it do pretty
 any other exception as well. Now what I did is I took one my more
 complicated JSP pages, made a copy and made a few changes to force some
 exceptions - now here is the weird thing - some exceptions are thrown to the
 screen and some are not.
 
 For example I had a ResultSet DB object and I made a syntax error and I got
 an Error 500 screen to come up as follows (note I took out the extra stuff
 to shorten the email)
 
 org.apache.jasper.JasperException: Unable to compile class for JSP

Note, you will always get a stacktrace if Tomcat can't compile a JSP - I 
believe this is appropriate as this is a developer error rather than a 
runtime error.

 However I tried to get it to do a syntax error in the query - and I end up
 with a blank page. The catalina log shows nothing, but my context log shows
 the following (clown is the word I used to screw up the query)
 
 javax.servlet.ServletException: ERROR:  syntax error at or near CLOWN at
 character 260
 
 --Root Cause--
 java.sql.SQLException: ERROR:  syntax error at or near CLOWN at character
 260
 
 Its almost as it the page refuses to compile with this error.

No, it has compiled OK or else you'd get the same kind of message as you 
did previously.

I suspect the reason you get a blank page is that for reason's I've never 
been able to discover, SQL Exceptions are nested and the last error (the 
one shown on your error page) is always empty :-(

to see the true error(s), you have to write some code that works its way 
back through the nested SQL Exceptions, printing out the message for each 
as you go.

Something like the following (untested) in your error.jsp should do the trick:

%
  if (exception == null) {
%
H1A null exception was encountered/H1
%
  } else {
if (exception instanceof SQLException) {
  Exception e = exception;
  while (e != null) {
%
PError Code: %=e.getErrorCode()%/P
PMessage: %=e.getMessage()%/P
%
e = e.getNextException();
  }
} else {
  // non-sql error handling here...
}
  }

HTH,

Rob Hills
www.netpaver.com.au
Western Australia

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Automated Server Configuration (was api for server.xml maintenance)

2005-07-21 Thread Rob Hills
Hi All,

I received no reply to my earlier email in this thread so I thought I'd try and 
come up with a less verbose description of my problem.

I'm looking to automate the management of hosts on my server.

Our tomcat servers operate multiple applications, each of which has its own 
host entry and root context.  We do this because each application has its 
own domain name and the domain name and root context is an important 
feature for our clients.

I've read the documentation on the Tomcat Manger and the Tomcat 
Deployer in great detail, but as far as I can tell, both only support the 
management of contexts under a previously established host.

I'm also aware of the ability to auto-deploy applications by depositing their 
WAR files into the %CATALINA_HOME%/webapps directory.  However, 
these are then associated with a context under the default host, which is not 
what I want to achieve.

I'd thought maybe there I could write a request filter that redirects requests 
for a specified url (domain name + url) to a context in the default host, but 
I'm not even sure that would do what I need, let alone how it would 
perform/scale.

Any thoughts, suggestions, comments welcome.

Rob Hills
www.netpaver.com.au
Western Australia

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Error 500 messages

2005-07-21 Thread Rob Hills
Hi Adile,

I did say it was untested, and I've spotted a problem in my code already 
(why are bugs so invisible BEFORE you press the send button??!!)

On 22 Jul 2005 at 9:41, Rob Hills wrote:

 Something like the following (untested) in your error.jsp should do the trick:
 
 %
   if (exception == null) {
 %
 H1A null exception was encountered/H1
 %
   } else {
 if (exception instanceof SQLException) {
   Exception e = exception;  // WRONG

the line above should read:
  SQLException e = (SQLException)exception;

   while (e != null) {
 %
 PError Code: %=e.getErrorCode()%/P
 PMessage: %=e.getMessage()%/P
 %
 e = e.getNextException();
   }
 } else {
   // non-sql error handling here...
 }
   }
 
 HTH,
 
 Rob Hills
 www.netpaver.com.au
 Western Australia
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


Rob Hills
MBBS, Grad Dip Com Stud, MACS
Senior Consultant
Netpaver Web Solutions
Tel:(08) 9485 2555
Mob:(0412) 904 357
Fax:(08) 9485 2555



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Problem with refreshing JSP

2005-07-12 Thread Rob Hills
Hi Rahul,

On 12 Jul 2005 at 8:19, Rahul Joshi wrote:

 It is Tomcat that has these compiled files which it continues to read
 from work/Catalina/localhost/ instead of the new ones. The questions
 is how do we make Tomcat clear or over-write these stored compiled
 files. 

If you set the Reloadable attribute of your application's Context element to 
True you will find that Tomcat will recompile any JSP file 
shortly after it changes ( see 
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html ).

As described in the documentation, this can slow down the performance of your 
application so it's best to switch it off on a production 
server.

Rob Hills
Western Australia

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: web app url config question

2005-07-11 Thread Rob Hills
HI Erik,

On 11 Jul 2005 at 19:34, Erik Weibust wrote:

 i have a question that after reading the majority of the online docs is
 still unanswered.
 
 how can i set my tomcat url to default to a specific page in a webapp?
 
 i.e. i would like http://localhost:8080 to load
 http://localhost:8080/testwebapp/home.jsp.

There are a number of ways to do this.  One is listed at the bottom of the 
wiki howto page:

http://wiki.apache.org/jakarta-tomcat/HowTo

HTH,

Rob Hills


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



api for server.xml maintenance

2005-07-11 Thread Rob Hills
Hi All,

We typically use one Tomcat instance to serve multiple applications, each 
with its own domain name.

I have always managed this by creating a host entry for each application, 
primarily so that we can have the application rooted at the default (empty-
path) context.

However, this has meant I've always had to manually create a host entry 
each time I deploy a new application, either by editing server.xml in the old 
days, or via the admin application in TC 5.5.

We're now automating the process of deployment and I've been hunting 
around for some kind of API to enable me to create new host entries.  After 
much time hunting documentation and Google, time pressure led me to 
write some code that stops tomcat and directly modifies server.xml, but the 
whole process is very flakey and I feel this is the wrong way to do things, 
leaving aside the fact that one needs direct access to the file system to do 
it.

I'm tantalised by the Monitoring and Management (section 21) part of the 
User Guide, but unfortunately it only tells me how to enable JMX, not how I 
could use that to manage Tomcat.

I've read and re-read the Manager documentation, and the Deployer 
documentation, but I can't see any way of using those processes to deploy 
multiple applications on one server such that each has its own root context.

So, I have two questions:

1.  Is there some sort of API I can use to programmatically 
create/modify host entries in server.xml.  If so, how can I find out how to use 
that.

2.  Alternatively, is there any way to deploy multiple root context 
applications using the built in manager?

TIA,

Rob Hills
Perth, Western Australia

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]