72

I'm trying to follow a tutorial to make an extremely basic Java web application in NetBeans.

When I try to run it, a dialogue box appears title "Authentication Required". Inside the dialogue box there the heading "Tomcat Manager Application" and fields for "User Name" and "Password."

Investigating this, I've come to understand that I should edit the file

\TOMCAT_HOME\conf\tomcat-users.xml

to include something like:

<user username="user" password="password" roles="standard,manager"/>

so I've done that, but it hasn't helped yet.

Can anyone provide some insight? I'm using Tomcat 6.0.20, NetBeans 6.7.1, and Windows Vista. I'm using jdk1.7.0, but Java hasn't really entered into this project yet.

Eric Wilson
  • 57,719
  • 77
  • 200
  • 270

11 Answers11

96

When you're launching tomcat server from netbeans IDE you need to check in menu "tools->servers" on connection tab for tomcat server - there is catalina base directory. And you need to include something like:

 <role rolename="manager"/>
  <user username="admin" password="admin" roles="manager"/>

at file

\CATALINA_BASE\conf\tomcat-users.xml

or use username automatically generated by IDE with description already placed in this file or on connection tab

For Manager Apps : GUI access:

<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Abhijeet
  • 8,561
  • 5
  • 70
  • 76
  • 9
    if you are using the User Interface you should change it to – M.C. Feb 08 '13 at 03:21
  • 2
    Remember to delete the encapsulated comments from the tomcat-users file so that you actually APPLY the role changes ("") – Hightower Nov 04 '14 at 07:58
  • In my case tomcat was placed in to folder with admin access(program files). Hence I reunzipped the tomcat to 'user/documents' folder, removed tomcat server from netbeans , reassigned new location and added the tomcat again and now it works. – CodeToLife Apr 28 '17 at 12:21
  • After applying this the error changed, but the output window requested that I should set the role to "manager-script" instead of "manager" or "manager-gui" as suggested – Adindu Stevens Jul 26 '21 at 21:11
18

Netbeans Problem: For apache Tomcat server Authentication required dialog box requesting user name and password

This dialog box appear If a user role and his credentials are not set or is incorrect for Tomcat startup via NetBeans IDE,

OR when user/pass set in IDE is not matches with user/pass in "canf/tomcat-user.xml" file

1..Need to check user name and password set in IDE tools-->server

2..Check \CATALINA_BASE\conf\tomcat-users.xml. whether user and his role is defined or not. If not add these lines

<user username="ide" password="EiWnNlBG" roles="manager-script,admin"/>
</tomcat-users>

3.. set the same user/pass in IDE tools->server

  1. restart your server to get effect of changes

Source: http://ohmjavaclasses.blogspot.com/2011/12/netbeans-problem-for-apache-tomcat.html

Sheo
  • 1,034
  • 12
  • 24
  • I hope your answer is useful for someone. As for me, I'm not using NetBeans these days, and I have no real guess how I might have resolved this problem from over two years ago. So I'll not be able to evaluate your answer and determine if it merits an upvote. – Eric Wilson Dec 12 '11 at 18:06
16

I case of tomcat 7 the role has changed from manager to manager-gui so set it as below in the tomcat-user.xml file.

enter image description here

Praveen Kumar
  • 1,515
  • 1
  • 21
  • 39
  • 1
    Tomcat8 also used these roles, see: [Configuring Manager application access](https://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html#Configuring_Manager_Application_Access). **Netbeans** is looking for the **_manager-script_** role - Server / Tomcat Properties dialogue. – will Apr 13 '16 at 02:57
  • Don't post pictures of text here. Post the text. Waste of your time and our bandwidth. – user207421 May 21 '18 at 22:34
12

Well if you are using Netbeans in Linux, then you should look for the tomcat-user.xml in

/home/Username/.netbeans/8.0/apache-tomcat-8.0.3.0_base/conf

(its called Catalina Base and is often hidden) instead of the Apache installation directory.

open tomcat-user.xml inside that folder, uncomment the user and roles and add/replace the following line.

    <user username="tomcat" password="tomcat" roles="tomcat,admin,admin-gui,manager,manager-gui"/>

restart the server . That's all

user207421
  • 305,947
  • 44
  • 307
  • 483
Prazzy Kumar
  • 994
  • 1
  • 11
  • 16
  • 1
    Thanks. I recommend that if you choose to answer questions posted nearly 5 years ago, you explain what it is that your answer provides that the existing answers lack. – Eric Wilson May 09 '14 at 09:51
2

Follow my steps and be happy:

1.- When you are configuring Netbeans for the first time, they will ask you for a "user" and "pass" for the Catalina-Server.

2.- Type whatever "user" and "pass" . This will modify your "tomcat-users.xml" and will add:

user password="MYPASS" roles="manager-script,admin,tomcat" username="MYUSER"

3.- To use this "user" just restart your TOMCAT WEB SERVER and NETBEANS.

2

File \conf\tomcat-users.xml, before this line

</tomcat-users>

add these lines

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>   
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
Vy Do
  • 46,709
  • 59
  • 215
  • 313
1

Update the 'apache-tomcat-8.5.5\conf\tomcat-users.xml file. uncomment the roles and add/replace the following line.and restart server

tomcat-users.xml file

<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="standard,manager,admin,manager-gui,manager-script"/>
Bheem Singh
  • 607
  • 7
  • 13
1

Use something like this to update your tomcat users.

<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-gui"/>

Tomcat users file is located inside conf folder of tomcat installation. To find the path of catalina_base you can use the command: ps aux | grep catalina You can find one of the values -Dcatalina.base=/usr/local/Cellar/tomcat/9.0.37/libexec

Most Important:

Don't forget to remove the comment lines from the tomcat-users.xml just before the start of the roles. <!-- -->

0

You will find the tomcat-users.xml in \Users\<Name>\AppData\Roaming\Netbeans\. It exists at least twice on your machine, depending on the number of Tomcat installations you have.

Oliver Gondža
  • 3,386
  • 4
  • 29
  • 49
JensD
  • 13
  • 4
-1

One simple way to check your changes to that file in Tomcat 8 + is to open a browser to: http://localhost:8080/manager/text/list

DoesEatOats
  • 625
  • 7
  • 13
-1

Go to apache-tomcat\conf folder add these lines in

tomcat-users.xml file

<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-gui"/>

and restart server

Usman Yaqoob
  • 535
  • 5
  • 13