views:

320

answers:

1

I'm using NetBeans 6.8 and Tomcat 6.0.xx. I've created a custom realm and updated the NetBeans project build.xml to deploy the realm to Tomcat. When I debug the project, NetBeans starts the Tomcat server and makes an initial HTTP GET request for 'manager/list'. Tomcat graciously hands this request off to my custom realm for authentication. The request gets denied and NetBeans displays the following error in the output window: (note: error is displayed after NetBeans gets access denied)

Access to Tomcat server has not been authorized. Set the correct username and password with the "manager" role in the Tomcat customizer in the Server Manager.

Do I have something incorrectly configured? How do I prevent NetBeans from issuing this initial request?

Thanks, Drew

A: 

So I figured this out. I had added my custom realm declaration at the engine level (e.g. inside the tag) in conf/server.xml. Therefore when NetBeans fired up my app on Tomcat, NetBeans was subject to my custom realm's authentication. The solution is to put the realm tag inside the context element, inside the host element. Here's some info about the elements in server.xml: http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

The next issue you'll run into, once you've accomplished the above, is that NetBeans does a fancy little jig called 'in-place deployment'. This essentially means it injects it's own context element into Tomcat when it fires up your app. This will conflict with the context element you just added server.xml above. To fix this, remove the context element from server.xml(I know you just added it). In the NetBeans project directory there is a file web/META-INF/context.xml. Put your custom realm element declaration in here. NetBeans feeds this file to Tomcat on startup.

Hope this helps.

Drew