Trying to install Tomcat 5.x on your XP machine and getting this message:
"failed to install tomcat5 service" Abort, Retry, Ignore...?
The problem could well be that you have already installed Tomcat5 before on this machine and windows is not happy trying to install a second Tomcat5 service. In my case I had installed Tomcat5 before and had deleted it but the old service was still hanging round. The solution is to remove the old service and then the install will continue along happily.
To see if you already have a Tomcat service, you can look in the Service window (under Start-Control Panel-Administrative Tools-Services) and look for a service called "Apache Tomcat". That is the sucker. Right-click and look at the Properties. Check the service name - it will be "Tomcat5". Stop the service if it is running.
Then fire up a command window and run this command:
>sc query tomcat5
This will give you details of the service (if you spell it right). To delete the service:
> sc delete tomcat5
and you should get a nice "[SC] DeleteService SUCCESS" message.
Now you can continue your install!
Wednesday, June 20, 2007
Friday, May 11, 2007
What jar files to add to your Spring app for Xfire
To expose some of your Spring classes as web services via Xfire you can follow one of the many tutorials on the web. But nobody tells you which jar files into your class path. These worked for me (under Apache Tomcat 5.5 runing Spring 1.2.9):
- xfire-all-1.2.4.jar - the main library for xfire
- activation-1.1.jar
- commons-codec-1.3.jar
- commons-httpclient-3.0.jar
- jdom-1.0.jar
- jsr173_api-1.0.jar
- mail-1.4.jar
- stax-1.1.2-dev.jar (this was a pain in the a$%#e to determine!)
- stax-api-1.0.1.jar
- wsdl4j-1.6.1.jar
- xbean-spring-2.7.jar
- XmlSchema-1.1.jar
Spring and log4j
If you have a Java Spring web application in Apache and are getting this error:
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
Then you can fix it by making sure that the log4j.properties file gets deployed to the classes folder under .../webapps/{project}/WEB-INF/classes/
Try sticking it in there and the error should go away. Too easy!
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
Then you can fix it by making sure that the log4j.properties file gets deployed to the classes folder under .../webapps/{project}/WEB-INF/classes/
Try sticking it in there and the error should go away. Too easy!
Friday, March 16, 2007
UniVerse and XML
Parsing XML documents in UniVerse just sucks really. I don't know how to describe it any better - it really just sucks!
Oh but validating them against XML schemas works really well! 1-1!
Oh but validating them against XML schemas works really well! 1-1!
Wednesday, March 14, 2007
JDBC Connection Pooling
For JDC database connection pooling you can use this cool datasource called the BasicDataSource which comes out of the commons-dbcp library (and also requires commons-collections and commons-pool). You can set parameters like the initial pool size, the maximum pool size, whether abandoned connections are removed etc.
They key thing to remember while using the connection pooling is that the datasource object is the scope of the connection pool. ie. if you create a new datasource object then you create a new connection pool. So you need to create one datasource and then either pass it to all your child classes (which something like SPring does for you pretty well), or you refer to a static instance of it from your child classes.
This may sound pretty obvious but I've been working on some code today that had this flaw and and was pretty hard to tell it was there. If you have other users/apps hitting the same DB then it is worth creating a new users for this test. The key is to set the maximum pool size to a low number eg. 10), set the initial pool size to 5, and then run up a 20 or 30 threads. You should not see more than 10 connections to the database (use 'show processlist' in MySQL). If you do, then the pooling isn't working and your code is probably creating datasources as it goes. Nasty!
They key thing to remember while using the connection pooling is that the datasource object is the scope of the connection pool. ie. if you create a new datasource object then you create a new connection pool. So you need to create one datasource and then either pass it to all your child classes (which something like SPring does for you pretty well), or you refer to a static instance of it from your child classes.
This may sound pretty obvious but I've been working on some code today that had this flaw and and was pretty hard to tell it was there. If you have other users/apps hitting the same DB then it is worth creating a new users for this test. The key is to set the maximum pool size to a low number eg. 10), set the initial pool size to 5, and then run up a 20 or 30 threads. You should not see more than 10 connections to the database (use 'show processlist' in MySQL). If you do, then the pooling isn't working and your code is probably creating datasources as it goes. Nasty!
Thursday, March 8, 2007
Enabling multiple localhost sites in Tomcat
I'm developing code on a Mac under Tomcat for a multi-application website which looks at the domain name to determine which app to run. It was getting damn annoying changing the database tables whenever I wanted to login to a different app. "There must be a better way to do this" he cried! ... and there is!
Rather than just having localhost pointing to your machine, you can have any name you want. eg. dev.localhost, qa.localhost, test.localhost, etc.
Step 1.
Setup the new host names in your hosts file. For me this is under /etc/hosts and I have to sudo to edit it. In there you will already have localhost setup. Add your new ones underneath and save it.
127.0.0.1 localhost
127.0.0.1 qa.localhost
127.0.0.1 dev.localhost
127.0.0.1 test.localhost
Now you should now be able to ping these and see the 127.0.0.1 IP address. In fact, you can try your URL with this server-name instead of localhost and get to your site!
Step 2.
Setup Tomcat to route these hosts to your app. This will run a seperate Tomcat instance for each application. Modify the server.xml file (in the conf folder) by adding the following XML:
<Host name="qa.localhost" appBase="webapps">
<Context path="" docBase=".">
<Host>
<Host name="dev.localhost" appBase="webapps">
<Context path="" docBase=".">
<Host>
<Host name="demo.localhost" appBase="webapps">
<Context path="" docBase=".">
<Host>
I guess if you have other web applications that sit elsewhere you can just modify the appBase path. I didn't need to do this. Note that I was using Eclipse with this setup and when I tried to debug, it started a host for each server and took ages to start; and then died with an out of memory error (this was with 7 aliases setup).
Step 3.
Try it out. Fire up Tomcat, and browse to http:/qa.localhost:8080/{blah blah} and you're away! Nice one brother!
Rather than just having localhost pointing to your machine, you can have any name you want. eg. dev.localhost, qa.localhost, test.localhost, etc.
Step 1.
Setup the new host names in your hosts file. For me this is under /etc/hosts and I have to sudo to edit it. In there you will already have localhost setup. Add your new ones underneath and save it.
127.0.0.1 localhost
127.0.0.1 qa.localhost
127.0.0.1 dev.localhost
127.0.0.1 test.localhost
Now you should now be able to ping these and see the 127.0.0.1 IP address. In fact, you can try your URL with this server-name instead of localhost and get to your site!
Step 2.
Setup Tomcat to route these hosts to your app. This will run a seperate Tomcat instance for each application. Modify the server.xml file (in the conf folder) by adding the following XML:
<Host name="qa.localhost" appBase="webapps">
<Context path="" docBase=".">
<Host>
<Host name="dev.localhost" appBase="webapps">
<Context path="" docBase=".">
<Host>
<Host name="demo.localhost" appBase="webapps">
<Context path="" docBase=".">
<Host>
I guess if you have other web applications that sit elsewhere you can just modify the appBase path. I didn't need to do this. Note that I was using Eclipse with this setup and when I tried to debug, it started a host for each server and took ages to start; and then died with an out of memory error (this was with 7 aliases setup).
Step 3.
Try it out. Fire up Tomcat, and browse to http:/qa.localhost:8080/{blah blah} and you're away! Nice one brother!
Apache Tomcat URL Limit?
So how long can your URL be before Tomcat spits the dummy and gives you an HTTP 414 error?
On the site I'm currently working on it is 8208 characters. 8207 works fine, 8208 gives the 414 (Request URI too large). And that is one looooonnnnnnnnnnng URL!
That's using Tomcat 5.5.17 and Java 1.5.0_06-b05
On the site I'm currently working on it is 8208 characters. 8207 works fine, 8208 gives the 414 (Request URI too large). And that is one looooonnnnnnnnnnng URL!
That's using Tomcat 5.5.17 and Java 1.5.0_06-b05
Subscribe to:
Posts (Atom)