• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Run java servlet on Apache2  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi all,

I have to run a servlet on an Apache2 (Server version: Apache/2.4.18 (Ubuntu)). I'm not the owner so I can not migrate to Tomcat, is it possible? Can you point me how to do it?

Thanks in advance,
Anna.
 
Marshal
Posts: 4465
284
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem you have there is that Apache is a HTTP Server and what you need is a Servlet Container, such as Tomcat.
 
Anna Amatus
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Tim,

And there is no way I can make it work without completely replacing the server? I have read some things but I have not come along with any page that clarifies this issue.
Can apache and apache tomcat co-exist?
I'm a java programmer and I'm not very familiar with servers....

Anna
 
Tim Cooke
Marshal
Posts: 4465
284
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you not just install Tomcat?
 
Anna Amatus
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


They are already running on Apache2 so I did not want to replace it. I though you have to have one or the other. Now I read it can run Tomcat along with Apache2 as long as they use different ports, so I guess I can install it.
Do you confirm that?
Sorry for my stupid questions but I have only had a couple of experiences with servers

Thanks!
 
Tim Cooke
Marshal
Posts: 4465
284
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yes you can run both at the same time on a single machine no problem. By default a web app deployed in Apache will be available on port 80, which in the browser is the same as omitting the port value "http://server:80" and "http://server" are equivalent, and by default applications deployed in Tomcat are available on port 8080. Ports are configurable of course.

Even if you don't have sudo access to the machine in order to install tomcat through "apt" you can download the binaries from the Tomcat site and run it from your home directory. If you have sudo then it's much easier of course.
 
Anna Amatus
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Great, thanks Tim

Yes I have sudo. I'll install it now!

Anna.
 
Sheriff
Posts: 21459
96
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also configure Apache to proxy to Tomcat, using mod_proxy_http or mod_proxy_ajp.
 
Bartender
Posts: 19731
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:You can also configure Apache to proxy to Tomcat, using mod_proxy_http or mod_proxy_ajp.



Or mod_jk, although I prefer mod_proxy myself.

Actually, it's really not a good idea to have clients directly accessing Tomcat itself anyway. Tomcat's default http port is 8080, and that requires explicit notation in client URLs - DNS only resolves IP addresses, not port numbers and the universal default port (well-known port) for http is 80, just as the well-known port for https is 443.

Nor is it a good idea to run Tomcat listening to port 80. Even if you don't have something like Apache already usurping id, port numbers lower than 4096 can only be opened by processes with administrator/root privileges, which means that if someone can access Tomcat directly via port 80 and manages to exploit the server, the entire JVM is available for exploit. Servers such as Apache and Nginx have mechanisms that keep them safe, but such mechanisms are not available to Java, since they're OS-specific.
 
Rob Spoor
Sheriff
Posts: 21459
96
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does mod_jk still exist? I thought that was an Apache 2.2 thing, and was replaced by mod_proxy_ajp.
 
Tim Holloway
Bartender
Posts: 19731
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:Does mod_jk still exist? I thought that was an Apache 2.2 thing, and was replaced by mod_proxy_ajp.



I'm pretty sure is does. Although mod_jk2 was abandoned long ago as a dead end. We were getting questions in the Tomcat forum about mod_jk on a regular basis long after Apache 2 came out. The original mod_jk was introduced more like Apache 2.0 or even Apache 1.

I've alway gotten the impression that mod_jk might have more flexibility for load-balancing, but never had the need to research it.

In any event, mod_proxy has been the recommended option for a long time and it's what I prefer to use.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!