• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help configuring for port 80

 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm running Tomcat 5.0 as a local stand-alone on Mac OS 10.4 (not XP), and I'm trying to configure Tomcat to run on port 80.

I have a test servlet running without problems at...

http://localhost:8080/scwcd01/hello-again

But when I edit Tomcat's conf/server.xml from <Connector port="8080"... to <Connector port="80"... (and restart Tomcat), I get a connection refused error with both of the following...

http://localhost/scwcd01/hello-again
http://localhost:8080/scwcd01/hello-again

I've consulted several references (including the latest edition of Sun's Core Servlets and JavaServer Pages), all of which seem to indicate that the above should work.


[ August 13, 2005: Message edited by: marc weber ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you also running Apache?

Check your tomcat logs to make sure that it's not reporting a problem attaching to port 80.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

No, I'm not running Apache, and I don't see any errors in the log. Here's what I get when starting with server.xml set to port="80"...

2005-08-13 13:20:49 StandardContext[/balancer]org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: ,]http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: ,]http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: ]]http://jakarta.apache.org]]
2005-08-13 13:20:50 StandardContext[/jsp-examples]ContextListener: contextInitialized()
2005-08-13 13:20:50 StandardContext[/jsp-examples]SessionListener: contextInitialized()
2005-08-13 13:20:50 StandardContext[/servlets-examples]ContextListener: contextInitialized()
2005-08-13 13:20:50 StandardContext[/servlets-examples]SessionListener: contextInitialized()


I've read that on UNIX, ports below 1024 are "privileged," and can only be opened by root. I don't fully understand what this means, but I expect that if this were the problem, then the log would show an error, right?
[ August 13, 2005: Message edited by: marc weber ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try to start Tomcat on port 80 I get the following in my catalina.out:

Aug 13, 2005 6:02:04 PM org.apache.coyote.http11.Http11Protocol init
SEVERE: Error initializing endpoint
java.net.BindException: Permission denied:80



So apparently you will need to configure tomcat to run as a priveleged user.

When I use sudo to start tomcat, everything works as expected (though usually I just let it use port 8080 and leave 80 to Apache).
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With OSX (as with any Unix), only the root user is allowed to bind to ports < 1024. Often, this is why people run Tomcat with Apache.
Apache starts up as root, binds to the port and then downgrades itself to a user with fewer privileges.

Tomcat ships with jSvc which can be used to do something similar with Tomcat as a standalone.

Also, if you search this forum, Earnest Friedman Hill posted a link to an article that shows how to do the same thing with ipchains in Linux not too long ago. I'm guessing the same techique would work on OSX.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben and Bear,

Thanks for the info! I probably won't have a chance to get back to this for a few days, but I'll try starting Tomcat with sudo to verify that it's a privileged user issue. Then I'll probably try either the jSvc or start using Apache.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I finally got a chance to try this (too much "real" work going on). Indeed, the XML configuration of port 80 works fine if Tomcat is started using sudo as Bear suggested, so this seems to confirm it's a privliged port issue.

Also, I want to follow up and thank Ben for his recommendation (a couple of months ago) of the text, Core Servlets and JavaServer Pages, Vol. 1, Second Edition by Marty Hall and Larry Brown. I see that a new edition of Vol. 2 is scheduled for January, 2006.

I wish I had more time to spend on this, but I'll get there eventually...
[ August 20, 2005: Message edited by: marc weber ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the article that EFH shared with us a while back.
I haven't tried doing this ipchains yet but that looks like a nice solution.
http://www.klawitter.de/tomcat80.html
reply
    Bookmark Topic Watch Topic
  • New Topic