I found out what the problem was and I want to post it here if it could
help someone else.
The bug wasn't with tomcat it was the JDK. It wasn't finding the policy
file I specified which is very strange since I did put it in
{java_home}/jre/lib/security and I even added a line in the
java.security file specifying that the tomcat.policy file should be
used.
As soon as I typed in the full path to the file on the command line like
so:
java
-Djava.security.policy==c:/jdk1.3/jre/lib/security/tomcat.policy
NameOfClass
It started working!
So this is obviously a bug with the JDK and not Tomcat... of course...
;o)
Regards, Stefan.
-----Original Message-----
From: Stefán F. Stefánsson [mailto:[EMAIL PROTECTED]]
Sent: 30. október 2000 11:52
To: Tomcat-Dev
Subject: java.security.policy problems with EmbededTomcat
Hi.
I'm having HUGE problems with EmbededTomcat and the Java 2 security
manager.
I'm trying to start up Tomcat through the EmbededTomcat class and adding
one context for the root.
Here is the code I'm using:
try
{
EmbededTomcat tc=new EmbededTomcat();
tc.setWorkDir( "c:/jakarta/build/tomcat/work");
ServletContext sctx;
sctx=tc.addContext("", new java.net.URL
( "file:/C:/ips"));
tc.initContext( sctx );
tc.addEndpoint( 8080, null, null);
tc.start();
while(true)
{
Thread.sleep(100);
}
}
catch (Throwable t )
{
t.printStackTrace();
}
And here is the output I'm getting from Tomcat:
ContextManager: Adding context Ctx( )
cannot process configuration web service using " /C:/ips"
Security init for Context /C:/ips failed
java.security.AccessControlException: access denied
(java.lang.RuntimePermission createClassLoader)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.
java:272)
at
java.security.AccessController.checkPermission(AccessController.java:399
)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at
java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:61
0)
at java.lang.ClassLoader.<init>(ClassLoader.java:234)
at
org.apache.tomcat.loader.AdaptiveClassLoader.<init>(AdaptiveClassLoader.
java:213)
at
org.apache.tomcat.loader.AdaptiveServletLoader.<init>(AdaptiveServletLoa
der.java:88)
at
org.apache.tomcat.context.LoaderInterceptor.contextInit(LoaderIntercepto
r.java:93)
at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:48
0)
at
org.apache.tomcat.startup.EmbededTomcat.initContext(EmbededTomcat.java:2
37)
at TestRun.main(TestRun.java:30)
java.security.AccessControlException: access denied
(java.net.SocketPermission localhost:8080 listen,resolve)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.
java:272)
at
java.security.AccessController.checkPermission(AccessController.java:399
)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at
java.lang.SecurityManager.checkListen(SecurityManager.java:1127)
at java.net.ServerSocket.<init>(ServerSocket.java:163)
at java.net.ServerSocket.<init>(ServerSocket.java:121)
at
org.apache.tomcat.net.DefaultServerSocketFactory.createSocket(DefaultSer
verSocketFactory.java:97)
at
org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.
java:239)
at
org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:1
88)
at
org.apache.tomcat.core.ContextManager.start(ContextManager.java:516)
at
org.apache.tomcat.startup.EmbededTomcat.start(EmbededTomcat.java:267)
at TestRun.main(TestRun.java:32)
The weird thing is that I'm running the java machine with the parameters
"-Djava.security.policy==tomcat.policy" where the tomcat.policy file
resides in {JAVA_HOME}\jre\lib\security and looks like this:
grant {
permission java.security.AllPermission;
};
This is really starting to get annoying and has taken up alot of time so
please help if you can.
Kind regards, Stefan Freyr
--------------------------------------------
Stefan Freyr Stefansson
Software Developer
deCODE Genetics, Inc.
Phone: (+354) 570 2854
GSM: (+354) 861 1718
Fax: (+354) 491 3782
<<Stefan Stefansson.vcf>>
winmail.dat
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]