2
votes

I'm trying to get my installation of Tomcat on a VPS to run on port 80 instead of 8080, but when I edit the settings for the server.xml file in my Tomcat directory, and try to restart Tomcat, I'm getting this error:

Jan 23, 2012 9:55:46 AM org.apache.coyote.http11.Http11Protocol init SEVERE: Error initializing endpoint java.net.SocketException: Cannot allocate memory at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:353) at java.net.ServerSocket.bind(ServerSocket.java:336) at java.net.ServerSocket.(ServerSocket.java:202) at java.net.ServerSocket.(ServerSocket.java:158) at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50) at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538) at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176) at org.apache.catalina.connector.Connector.initialize(Connector.java:1014) at org.apache.catalina.core.StandardService.initialize(StandardService.java:680) at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:795) at org.apache.catalina.startup.Catalina.load(Catalina.java:524) at org.apache.catalina.startup.Catalina.load(Catalina.java:548) 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.load(Bootstrap.java:261) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Jan 23, 2012 9:55:46 AM org.apache.catalina.startup.Catalina load SEVERE: Catalina.start LifecycleException: Protocol handler initialization failed: java.net.SocketException: Cannot allocate memory at org.apache.catalina.connector.Connector.initialize(Connector.java:1016) at org.apache.catalina.core.StandardService.initialize(StandardService.java:680) at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:795) at org.apache.catalina.startup.Catalina.load(Catalina.java:524) at org.apache.catalina.startup.Catalina.load(Catalina.java:548) 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.load(Bootstrap.java:261) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Not really sure what that means... Does it mean I don't have enough memory? Are there alternative ways to get Tomcat to run on port 80?

Edit: Here is the output when I type in free -m:

total       used       free     shared    buffers     cached
Mem:   1024        748        275          0          0          0
-/+ buffers/cache:   748        275
Swap:   0          0          0
1
something else already binded to port 80? check netstatYou Qi
I have apache2 running, but when I close apache2 I still get the same errors.Raymond
Try port 81 or 89 just to see what happens. Also, you can see what ports are in use using the netstat -a command. If you hate command line tools, try TCPView.user785262
Same thing happens with port 81. I used netstat and it doesn't look like anything is using port 81. I'm not sure if this is relevant, but I'm using Ubuntu Linux. Maybe there's a problem with root access?Raymond
Please edit your question to include the output of free -m.sarnold

1 Answers

3
votes

I got the same issue with Tomcat on OpenVZ using authbind to run on port 80. I solved it by switching from OpenJDK to Sun Java.