Keith Visco wrote:

> 
> Robert Marcano wrote:
> 
>>2)When Unmarshalling a stream using one of the generated Classes, an
>>AccessControlException is thrown accesing the java.home system property.
>>I�m using Castor inside a secured Tomcat server, so I fixed this adding
>>to the method "loadProperties" in the class named
>>"org.exolab.castor.util.Configuration" to ignore the exception
>>
>>        try {
>>            file = new File( System.getProperty( "java.home" ), "lib" );
>>            file = new File( file, fileName );
>>            if ( file.exists() ) {
>>                properties = new Properties( properties );
>>                properties.load( new FileInputStream( file ) );
>>            }
>>        } catch ( IOException except ) {
>>            // Do nothing
>>        } catch ( AccessControlException except ) {
>>            //AccessControl patch added
>>            // Do nothing
>>        }
>>
> 
> 
> Cool...using Castor for only 3 hours and you're already contributing
> back to the project!
> I think it would be better to make this configurable, as some people
> might want to know about the exceptions and further grant proprerties
> permissions.
> 


I have also noticed that I have to set a number of extra (unneeded in my view)
permissions for Castor when running within a container like Tomcat with the
Java SecurityManager.

I looked at the loadProperties() method in Configuration and would like
to suggest the following changes:

The current behaviour is:

load properties using current class loader getResource from jar.
load properties using FileInputStream from java.home lib directory.
load properties using current class loader getResource as a file.

Note that if all three are available, all three get loaded, but only
the last loaded properties get used.

I recommend the following change:

load properties using current class loader getResource as a file,
if it gets loaded, return.

load properties using FileInputStream from java.home lib directory,
if it gets loaded, return.

load properties using current class loader getResource from jar,
if it exists return, else throw an exception.

With the above changes, the extra attemps to load the properties will
never happen if you have a castor.properties in your /WEB-INF/classes
directory.

Regards,

Glenn


----------------------------------------------------------------------
Glenn Nielsen             [EMAIL PROTECTED] | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to