Remote access to Tomcat web server

E

eliliano

Hi,

I'm trying Tomcat for the first time .

I've installed Tomcat (apache-tomcat-6.0.13, zip-version). It runs ok.
Then I've installed MySQL and there I've created my database.
Then I've writed a java servlet for querying the data.

Well, this is what happens.

1) In localhost, it's all ok: the servlet runs, reads data from tables
and displays them in a browser window.

2) From another host (of my LAN), nothing: a 404 error appears.

My question:

what can I modify to allow remote access to tomcat web-server?

Note: I call my servlet using these URL:

http://localhost:8080/database_access/listadb (in a local contest)

http://192.168.1.55:8080/database_access/listadb (in a remote contest)

Can you help me?

Thanks! Luigi
 
M

mikwiat

Hi,

I'm trying Tomcat for the first time .

I've installed Tomcat (apache-tomcat-6.0.13, zip-version). It runs ok.
Then I've installed MySQL and there I've created my database.
Then I've writed a java servlet for querying the data.

Well, this is what happens.

1) In localhost, it's all ok: the servlet runs, reads data from tables
and displays them in a browser window.

2) From another host (of my LAN), nothing: a 404 error appears.

My question:

what can I modify to allow remote access to tomcat web-server?

Note: I call my servlet using these URL:

http://localhost:8080/database_access/listadb(in a local contest)

http://192.168.1.55:8080/database_access/listadb(in a remote contest)

Can you help me?

Thanks! Luigi

I don't know how it is with Tomcat, but i know that Apache have some
string in configuration that "says" that server can just be entered
writing 127.0.0.1 || localhost.

You can use this site: http://www.coreservlets.com/Apache-Tomcat-Tutorial/
hope that helps :)
 
D

David Segall

Hi,

I'm trying Tomcat for the first time .

I've installed Tomcat (apache-tomcat-6.0.13, zip-version). It runs ok.
Then I've installed MySQL and there I've created my database.
Then I've writed a java servlet for querying the data.

Well, this is what happens.

1) In localhost, it's all ok: the servlet runs, reads data from tables
and displays them in a browser window.

2) From another host (of my LAN), nothing: a 404 error appears.

My question:

what can I modify to allow remote access to tomcat web-server?

Note: I call my servlet using these URL:

http://localhost:8080/database_access/listadb (in a local contest)

http://192.168.1.55:8080/database_access/listadb (in a remote contest)
I suspect that you have not granted access to your MySql database from
your network. Otherwise, look in the Tomcat and MySQL logs to find the
error and, if that does not help, post the logs here.
 
D

David Segall

David Segall said:
I suspect that you have not granted access to your MySql database from
your network.
Oops! That was a dumb suggestion; you are not accessing the database
from the network.
 
E

eliliano

I don't know how it is with Tomcat, but i know that Apache have some
string in configuration that "says" that server can just be entered
writing 127.0.0.1 || localhost.

Yes, I know that... In fact I didn't have any problems with Apache.
I'm having problems with Tomcat....


Thanks, I'll read that.... (A quickly reading didn't give to me any
useful notice, so far: in all of the document it seems that is just
mentioned "localhost", not another IP).

Luigi
 
D

David Segall

That is my target! :)
Not exactly. The problem of MySQL permissions only occurs if you send
a request from a different host directly to the MySQL server which is
listening on 192.168.1.55:3306. You are using a servlet on the same
host as the MySQL server to access your database even if the request
comes from a remote machine.
So far, if I type http://192.168.1.55/folder_name/servlet_name
on a different host of my LAN, I get: ERROR 404 (page not found). That
is: web server not found, in fact, in a local environment, that page
appears (and the servlet itself runs).
My other suggestion of checking the Tomcat and MySQL logs was more
sensible. I find it easier to delete the logs and start again rather
than wading through the old data. I assume http://localhost:8080/ and
http://192.168.1.55:8080/ from the remote machine both give you the
default Tomcat home page.
 
E

eliliano

I assume http://localhost:8080/ and http://192.168.1.55:8080/ from the remote machine both give you the
default Tomcat home page.

That is my problem!

http://localhost:8080/ (in a local contest) gives me the Tomcat home
page, while

http://192.168.1.55:8080/ (in a remote contest) doesn't :-(

I think I would change some of the server.xml settings, but I read the
Tomcat's documentation and it seems "never ending!". Is it so hard for
everybody to understand those documentation pages?

By the way, I tried another way to solve my problem.

First of all, I installed "Easy PHP" (a free sw that contains an
Apache web server, also);
Then I activated it;
And than I installed Tomcat (Windows auto-installing version);

Well, this time I noted that server.xml was very different than
before.

And (yes!) it works!

Remote access to Tomcat home page is ok;
Running of my servlet is ok;
Accessing to the MySQL (remote) database is ok.

What is happening? Why is it working, now, while before didn't?
I can't post the two server.xml files, since they are so large...

Now, I'm almost sure my problem is a setting problem.

Must I read all of the documentation pages to understand how to allow
remote access?

Are there anybody that can tell me how I can do?

Thanks, Luigi
 
G

Gordon Beaton

http://localhost:8080/ (in a local contest) gives me the Tomcat home
page, while

http://192.168.1.55:8080/ (in a remote contest) doesn't :-(

I can't tell you how to configure Tomcat, but if you've told it to
listen at "localhost port 8080" then only connections from the
localhost will succeed. Similarly, if you've told it to listen at
"192.168.1.55 port 8080" then only connections arriving on that
specific network interface will succeed.

For both to work, you need to tell it to listen at "port 8080" without
specifying an address, hostname, or network interface.

(This assumes that the host itself has properly configured network
interfaces.)

/gordon

--
 
L

Lew

That is my problem!

http://localhost:8080/ (in a local contest) gives me the Tomcat home
page, while

http://192.168.1.55:8080/ (in a remote contest) doesn't :-(

I am repeatedly thrown by your use of the word "contest":
1. (uncountable) controversy; debate
no contest

2. (uncountable) struggle for superiority; combat
3. (countable) a competition
The child entered the spelling contest.

Perhaps you mean "context"?
I think I would change some of the server.xml settings, but I read the
Tomcat's documentation and it seems "never ending!". Is it so hard for
everybody to understand those documentation pages?

If this profession were easy, anyone could do it. Programming is not for the
lazy.
By the way, I tried another way to solve my problem.

First of all, I installed "Easy PHP" (a free sw that contains an
Apache web server, also);
Then I activated it;
And than I installed Tomcat (Windows auto-installing version);

Well, this time I noted that server.xml was very different than
before.

And (yes!) it works!

Remote access to Tomcat home page is ok;
Running of my servlet is ok;
Accessing to the MySQL (remote) database is ok.

What is happening? Why is it working, now, while before didn't?
I can't post the two server.xml files, since they are so large...

On the one hand you ask for answers, on the other you withhold the information
that would let someone help.

Much of the server.xml that comes with Tomcat is comments; you can delete all
that safely.

It is a useful exercise to pare down the server.xml, item by item until it
stops working, Then you learn what makes it work and what doesn't.

It is also useful to read the documentation associated with Tomcat. Study it.

There are also many other configuration files that are relevant. For example,
Apache Web Server uses httpd.conf to set up how it responds to, say, different
IP addresses in the target URL.

It is useful to read the documentation associated with Apache Web Server.
Study it.
Now, I'm almost sure my problem is a setting problem.

Must I read all of the documentation pages to understand how to allow
remote access?
Yes.

Are there anybody that can tell me how I can do?

Yes. I could, for example, and did, here.
 
E

eliliano

I am repeatedly thrown by your use of the word "contest":
<http://en.wiktionary.org/wiki/contest>

...

Perhaps you mean "context"?

Yes, I meant that. I'm sorry, I can't write English very well, so I
made a mistake.


If this profession were easy, anyone could do it. Programming is not for the
lazy.

That's right. But I configured Apache (httpd.conf) in a while, without
reading any manual. It was easy, and the instructions are written in a
very intuitive fashion.
That's not true for Tomcat. I've already downloaded and read more than
twenty documentation pages, and I made all of the changes I think they
can be useful to the server.xml file: nothing... it doesn't still
work.


On the one hand you ask for answers, on the other you withhold the information
that would let someone help.

I tried that alternative way just few minutes before my last post.

It is also useful to read the documentation associated with Tomcat. Study it.

Now, I think this: I could compare the two server.xml files (the ono
that works and the one that doesn't) to try to understend, more
quickly, what are the options that open Tomcat access to remote
hostes.

I hope I can succeed.

Luigi
 
L

Lew

That's right. But I configured Apache (httpd.conf) in a while, without
reading any manual. It was easy, and the instructions are written in a
very intuitive fashion.
That's not true for Tomcat. I've already downloaded and read more than
twenty documentation pages, and I made all of the changes I think they
can be useful to the server.xml file: nothing... it doesn't still
work.

Tomcat can be tricky, but the minimal setup doesn't really need to be. I
actually found Web Server's configuration harder to learn than Tomcat's, but
learning styles vary.

Here's the Tomcat (6.0, but it's the same for 5.5) server.xml that I use. You
may want to use the default ports (8005, 8080, 8009, 8443) rather than the
changes I made. Not everything I use is required to make Tomcat work. YMMV.
-----
<Server port="9005" shutdown="SHUTDOWN">

<Listener className="org.apache.catalina.core.AprLifecycleListener"
SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml"
/>
</GlobalNamingResources>

<Service name="Catalina">
<Connector port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="9443"
/>
<Connector port="9009" protocol="AJP/1.3" redirectPort="9443" />

<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
 
S

Steve Sobol

That's right. But I configured Apache (httpd.conf) in a while, without
reading any manual. It was easy, and the instructions are written in a
very intuitive fashion.
That's not true for Tomcat. I've already downloaded and read more than
twenty documentation pages, and I made all of the changes I think they
can be useful to the server.xml file: nothing... it doesn't still
work.

Tomcat's config files are not terribly intuitive. I like Jetty's a lot
better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top