[ 
https://issues.apache.org/jira/browse/LUCENE-5471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13912070#comment-13912070
 ] 

Uwe Schindler edited comment on LUCENE-5471 at 2/25/14 9:18 PM:
----------------------------------------------------------------

Hoss: We don't swallow the SecurityException. I think, with a SecurityManager 
enabled and some missing persmissions, stuff like ClassLoader#getResources() 
simply don't work and return an empty enumeration. So it does not find any 
resources from classloader, because code has no permissions to "see" the code.

This is defined in the spec - see 
[http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResources(java.lang.String)]:
 "An enumeration of URL objects for the resource. If no resources could be 
found, the enumeration will be empty. Resources that the class loader doesn't 
have access to will not be in the enumeration." This is a bit unclear, but 
getResource() is very good documented: "A URL object for reading the resource, 
or null if the resource could not be found or *the invoker doesn't have 
adequate privileges to get the resource*."

So there is nothing we can do against that.


was (Author: thetaphi):
Hoss: We don't swallow the SecurityException. I think, with a SecurityManager 
enabled and some missing persmissions, stuff like ClassLoader#getResources() 
simply don't work and return an empty enumeration. So it does not find any 
resources from classloader, because code has no permissions to "see" the code.

This is defined in the spec - see 
[http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResources(java.lang.String)]:
 "An enumeration of URL objects for the resource. If no resources could be 
found, the enumeration will be empty. Resources that the class loader doesn't 
have access to will not be in the enumeration."

So there is nothing we can do against that.

> Classloader issues when running Lucene under a java SecurityManager
> -------------------------------------------------------------------
>
>                 Key: LUCENE-5471
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5471
>             Project: Lucene - Core
>          Issue Type: Bug
>    Affects Versions: 4.5
>            Reporter: Rick Hillegas
>         Attachments: SecureLucene.java
>
>
> I see the following error when I run Lucene 4.5.0 under a java 
> SecurityManager. I will attach a test program which shows this problem. The 
> program works fine when a SecurityManager is not installed. But the program 
> fails when I install a SecurityManager. Even more puzzling, the program works 
> if I first run it without a SecurityManager, then install a SecurityManager, 
> then re-run the program, all within the lifetime of a single JVM. I would 
> appreciate advice about how to work around this problem:
> Exception in thread "main" java.lang.ExceptionInInitializerError
>       at 
> org.apache.lucene.index.LiveIndexWriterConfig.<init>(LiveIndexWriterConfig.java:122)
>       at 
> org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.java:165)
>       at SecureLucene$1.run(SecureLucene.java:129)
>       at SecureLucene$1.run(SecureLucene.java:122)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at SecureLucene.getIndexWriter(SecureLucene.java:120)
>       at SecureLucene.runTest(SecureLucene.java:72)
>       at SecureLucene.main(SecureLucene.java:52)
> Caused by: java.lang.IllegalArgumentException: A SPI class of type 
> org.apache.lucene.codecs.Codec with name 'Lucene45' does not exist. You need 
> to add the corresponding JAR file supporting this SPI to your classpath.The 
> current classpath supports the following names: []
>       at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109)
>       at org.apache.lucene.codecs.Codec.forName(Codec.java:95)
>       at org.apache.lucene.codecs.Codec.<clinit>(Codec.java:122)
>       ... 8 more



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to