Problem starting tomcat6 on Debian Squeeze
I was having problem when trying to start tomcat6(6.0.28-7) service on my Debian Squeeze, fortunately I found the solution on the web[0].
The following message was in /var/log/tomcat6/catalina.xxxx.log:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | (...) java.net.SocketException: Invalid argument at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:336) at java.net.ServerSocket.bind(ServerSocket.java:336) at java.net.ServerSocket.<init>(ServerSocket.java:202) at org.apache.catalina.core.StandardServer.await(StandardServer.java:373) at org.apache.catalina.startup.Catalina.await(Catalina.java:662) at org.apache.catalina.startup.Catalina.start(Catalina.java:614) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) (...) |
As said in eFreedom.com[1], it has something to do with IPv6. To solve this problem you’ll have to check if net.ipv6.bidv6only is set to 1/true:
1 | # sysctl net.ipv6.bindv6only |
If it is set to 1/true, you’ll have to set it to 0/false:
1 | # sysctl -w net.ipv6.bindv6only = 0 |
Then you can restart the tomcat6 service and it will work, but only while your computer is running, if the you reboot the system it will fail again.
To make it permanent you will have to make sure that the -Djava.net.preferIPv4Stack option is set to true and is being added to JAVA_OPTS in catalina_sh() function, inside /etc/init.d/tomcat6. The line which does that is:
1 | JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true" |
And that’s it.
[0] http://efreedom.com/Question/1-2876231/Start-Tomcat-6026-Update-Debian-Squeeze
[1] http://efreedom.com/
:wq

