Re: Strange LoggingPermission exception trying to call RMI from a Tomcat servlet

Peter Jones - JavaSoft East <[email protected]> Fri, 24 Feb 2006 15:58:13 -0500
Newsgroups gmane.comp.java.sun.rmi
Message-ID <20060224205813.GE27889@east>
> I have a simple RMI server that I can access just fine from a command-line
> Jave app, but when I try to get to it from a Tomcat 5.5.9 (running Java 5.0)
> servlet, I get a strange set of exceptions.
>
> Actually, the errors occur during a call to LocateRegistry.getRegistry (host).
>
> There is a "caused by" exception having to do with an AccessControlException
> that points, strangely, to java.util.logging.LoggingPermission. The complete
> stack dump is below. I've restarted Tomcat with a modified catalina.policy
> file that grants all permissions, but it didn't help.
>
> Any ideas on what could be wrong? Thanks.
>
> Exception in thread "Thread-36" java.lang.ExceptionInInitializerError
>         at sun.rmi.transport.tcp.TCPEndpoint.<clinit>(TCPEndpoint.java:104)
>         at java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:158)
>         at java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:106)
>         at java.rmi.registry.LocateRegistry.getRegistry(LocateRegistry.java:89)
>         at gov.sensornet.rftrax.VandyPositionClient.<init>(VandyPositionClient.java:53)
>         at gov.sensornet.rftrax.SocketHandlerThread.<init>(SocketHandlerThread.java:68)
>         at gov.sensornet.rftrax.SocketAcceptThread.run(SocketAcceptThread.java:119)
> Caused by: java.security.AccessControlException: access denied (java.util.logging.LoggingPermission control)
>         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
>         at java.security.AccessController.checkPermission(AccessController.java:427)
>         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
>         at java.util.logging.LogManager.checkAccess(LogManager.java:927)
>         at java.util.logging.Logger.setParent(Logger.java:1331)
>         at org.apache.juli.ClassLoaderLogManager$2.run(ClassLoaderLogManager.java:377)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at org.apache.juli.ClassLoaderLogManager.doSetParentLogger(ClassLoaderLogManager.java:375)
>         at org.apache.juli.ClassLoaderLogManager.addLogger(ClassLoaderLogManager.java:120)
>         at java.util.logging.Logger.getLogger(Logger.java:232)
>         at sun.rmi.runtime.Log$LoggerLogFactory.createLog(Log.java:154)
>         at sun.rmi.runtime.Log.getLog(Log.java:121)
>         at sun.rmi.transport.Transport.<clinit>(Transport.java:43)
>         ... 7 more

It appears that the custom LogManager class being used in this VM,
org.apache.juli.ClassLoaderLogManager, is not being granted the
LoggingPermission("control") permission that it needs in order to be a
successful LogManager.  (It is invoking Logger.setParent in a
doPrivileged block, like the default LogManager does, so it must be
its own code that lacks the permission grant.)  This failure doesn't
seem RMI-specific-- the API used by the RMI class's failing static
initializer, Logger.getLogger, should not require the permission.

We would need more details to speculate why the modified security
policy file didn't fix the problem (like at least the file itself).

By the way, did you mean to include the following additional exception
trace as something related?

> Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader)
>         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
>         at java.security.AccessController.checkPermission(AccessController.java:427)
>         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
>         at java.lang.Thread.setContextClassLoader(Thread.java:1306)
>         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1572)
>         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
>         at java.lang.Thread.run(Thread.java:595)

-- Peter

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html