views:

1531

answers:

3

Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app server), is there some way I can configure things so Tomcat will start with security turned on (i.e. as if I ran catalina.sh start -security)?

A: 

which version of tomcat is this ?

anjanb
Yes, version 5.5
Matt Sheppard
A: 

I'm assuming that you're using Tomcat 5.5.x

after looking at catalina.bat/catalina.sh, all the -security flag does is to set -Djava.security.policy=="%CATALINA_BASE%\conf\catalina.policy"

Most people have CATALINA_BASE set to TOMCAT_HOME or CATALINA_HOME

So, if you have installed tomcat in the directoryc:\tomcat, then all you need to do is to set an option in the tomcat plugin to include the above policy.
i.e, add this to JAVA_OPTIONS : -Djava.security.policy=="c:\tomcat\conf\catalina.policy".

That's all and restart.

anjanb
Where do I set it in Eclipse so it will take effect when Tomcat is started? Looking at the server properties does not seem to give me any way to set command line options.
Matt Sheppard
+1  A: 

Go into 'Window' -> 'Preferences' then select 'Java' -> 'Installed JREs', clone the JRE used by Tomcat and add the following to the default VM Arguments

-Djava.security.manager -Djava.security.policy="XXXX\conf\catalina.policy"

With XXXX replaced by the appropriate path - Mine was C:\Program Files\Apache Software Foundation\Tomcat 5.5). Then change the JRE name (I added "security enabled" to the end) and click 'Finish'.

After that, open 'Server' -> 'Runtime Environments' in the preferences, and select your Apache Tomcat environment, then click the 'Edit...' button. In the resulting window, select the new security enabled JRE, then click 'Finish' and restart Tomcat.

Matt Sheppard