aspose file tools*
The moose likes Tomcat and the fly likes Binding and running tomcat 6 on a virtual ip address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Binding and running tomcat 6 on a virtual ip address" Watch "Binding and running tomcat 6 on a virtual ip address" New topic
Author

Binding and running tomcat 6 on a virtual ip address

Leif Torger Gr�ndahl
Greenhorn

Joined: Oct 23, 2008
Posts: 1
Hi,

We have a linux server environment (rhel5.2 - redhat enterprise ed.) where we host several jboss 4.05 -servers (with tomcat 5.5).
Each servers is bound to a specific virtual IP (defined in /etc/sysconfig/network-scripts/ifcfg-eth0:X)
Here is an example config for a virtual IP defined for one of our hosts (/etc/sysconfig/network-scripts/ifcfg-eth0:2):
GATEWAY=192.168.2.1
TYPE=Ethernet
DEVICE=eth0:2
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=192.168.2.62
USERCTL=no
IPV6INIT=no
ONPARENT=yes
PEERDNS=yes

The jboss-servers are bound to the virtual addresses by adding the attribute "-b" to the startup-script like so:
/usr/local/jboss/bin/run.sh -c appservername -b 192.168.2.62 > out.log


The Jboss setup works fine, but we now want to use tomcat 6 as a standalone container and run tomcat-servers in a similar way.
I tried to bind one Tomcat-instance to a specific virtual IP be adding "address=192.168.2.62'" as an xml-attribute to the HTTP Connetor, to the AJP 1.3 Connector, to the Catalina engine (defaultHost="192.168.2.62"), to the Host for "webapps" inside the Catalina engine (name="192.168.2.62") and then start Tomcat like so /usr/local/tomcat/bin/startup.sh


When starting Tomcat the following is reported in the logs:

INFO: Starting service Catalina
21.okt.2008 11:35:03 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
21.okt.2008 11:35:04 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.eclipse.birt.report.listener.ViewerServletContextListener" is already configured for this context. The duplicate definition has been$
21.okt.2008 11:35:04 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.eclipse.birt.report.listener.ViewerHttpSessionListener" is already configured for this context. The duplicate definition has been ig$
21.okt.2008 11:35:08 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.ContextListener" is already configured for this context. The duplicate definition has been ignored.
21.okt.2008 11:35:08 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.SessionListener" is already configured for this context. The duplicate definition has been ignored.
21.okt.2008 11:35:08 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.eclipse.birt.report.listener.ViewerServletContextListener" is already configured for this context. The duplicate definition has been$
21.okt.2008 11:35:08 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.eclipse.birt.report.listener.ViewerHttpSessionListener" is already configured for this context. The duplicate definition has been ig$
21.okt.2008 11:35:13 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-192.168.2.62-8080
21.okt.2008 11:35:13 org.apache.jk.common.ChannelSocket init
INFO: Port busy 8009 java.net.BindException: Address already in use
21.okt.2008 11:35:13 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8010
21.okt.2008 11:35:13 org.apache.jk.server.JkMain start
INFO: Jk running ID=1 time=0/88 config=null
21.okt.2008 11:35:13 org.apache.catalina.startup.Catalina start
INFO: Server startup in 9748 ms
21.okt.2008 11:35:13 org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[8005]:
java.net.BindException: Cannot assign requested address[/B]
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
etc..


If I bind the tomcat server to IP-address 192.168.2.60 (which is the "actual"/"parent"/physical nic for the linux server then everything works fine.
The only difference between the config that works and the one that does not work is the IP-address I set in server.xml.

Both IP-addresses are free on all the ports that are beeing used by tomcat. I checked this by trying to access both IP's on the relevant ports through telnet, I also checked the server config for potential busy/taken ports

I'm guessing that I am missing something in the tomcat configuration since it seems like there is a reference to localhost somewhere but I cannot see where..
Hints, anyone? : )

We could of cource bind the server to the physical IP and then use different tomcat hosts for each of our applications. However, this is not the preferred approach for us since we need to stop, start, reload configs etc. for each application independently.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Binding and running tomcat 6 on a virtual ip address
 
Similar Threads
Two Web App communicating problem
Tomcat not Responding!!
SEVERE: Error initializing endpoint
Tomcat 6.0 server Error occured during page access
SEVERE: Error listenerStart