Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Remote access to Tomcat web server

Thread view: 
eliliano@libero.it - 30 May 2007 17:22 GMT
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
mikwiat@gmail.com - 30 May 2007 20:51 GMT
On May 30, 6:22 pm, elili...@libero.it wrote:
> Hi,
>
[quoted text clipped - 24 lines]
>
> 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 :)
eliliano@libero.it - 31 May 2007 17:18 GMT
> 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....

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

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
David Segall - 31 May 2007 04:54 GMT
>Hi,
>
[quoted text clipped - 20 lines]
>
>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.
David Segall - 31 May 2007 04:58 GMT
>>Hi,
>>
[quoted text clipped - 22 lines]
>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.
>Otherwise, look in the Tomcat and MySQL logs to find the
>error and, if that does not help, post the logs here.
eliliano@libero.it - 31 May 2007 17:26 GMT
> Oops! That was a dumb suggestion; you are not accessing the database
> from the network.

That is my target! :-)
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).

Luigi
David Segall - 01 Jun 2007 08:11 GMT
>> Oops! That was a dumb suggestion; you are not accessing the database
>> from the network.
>
>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.
eliliano@libero.it - 01 Jun 2007 15:16 GMT
> 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
Gordon Beaton - 01 Jun 2007 15:29 GMT
> 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

--
Lew - 01 Jun 2007 15:34 GMT
David Segall wrote:
>> 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 am repeatedly thrown by your use of the word "contest":
<http://en.wiktionary.org/wiki/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.
>
[quoted text clipped - 14 lines]
> 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.

Signature

Lew

eliliano@libero.it - 02 Jun 2007 15:04 GMT
> 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
Lew - 02 Jun 2007 15:44 GMT
> 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
[quoted text clipped - 3 lines]
> 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>
Steve Sobol - 02 Jun 2007 23:37 GMT
> 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
[quoted text clipped - 3 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.