Saturday, July 28, 2007

Basic Authentication For XDB Realm With Tomcat

I've seen a few people asking this question recently: "When I try to access my instance of Tomcat with the URL http://localhost:8080, I get a dialog box asking for a username and password to log into the XDB Realm". Even with fresh installs, people face this problem.

The problem is that by default, Oracle listens at port 8080. And coincidentally, so does Tomcat, with default settings! And so, if you start Oracle first and Tomcat after, port 8080 is already in use when Tomcat tries to bind to it. In fact, if you look at the console or the logs, you'll see an error which says something like

Address already in use:JVM_BIND 8080

When you try to access http://localhost:8080, you are actually trying to connect to Oracle and not to Tomcat. That's why none of the default username/password combinations that come with Tomcat work.

The solution is simple: change the port that Tomcat listens on. This is assuming, of course, you want to use Oracle also. You could just get rid of it :D.

Changing the port is simple. You'll find lots of detailed explanations if you Google'ed for it. But to give it in short, open $CATALINA_HOME/conf/server.xml and look for a line which starts with

<Connector port="8080"

and change the port value to something different. I prefer using 8888. It's so much easier to type than 8080 or 8081!

11 comments:

Anonymous said...

The post is very useful.Could you plz let me know how to change the tomcat port in winXP.

no.good.at.coding said...

Thanks :)

Changing the port is the same on any platform ( AFAIK ). If you read the last paragraph, I've mentioned that you need to modify server.xml. The easiest way is to search the file for the port number you're currently using and then modify it to the port number you want.

If you Google for it, you're bound to find lots of step-by-step explanations.

Anonymous said...

....Excellent, it helped very much....

Anonymous said...

Thank youuu !!
You save me :)

Anu said...

Thanks, this post helped me.

Praveen Munaga said...

Thank you :)

Adrian said...

ty very much ;)

Anonymous said...

Thanks a lot. Its very helpful.
-Raj

Unknown said...

It didnt work..please help me

Anonymous said...

Excelent!! it perfectly worked

thanks

Anonymous said...

Excelent!