apache / apache/lucene

Classloader issues when running Lucene under a java SecurityManager [LUCENE-5471]

Open
#6,534 10 comments 0 reactions 0 assignees View on GitHub
affects-version:4.5 legacy-jira-priority:Major type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

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

---
Migrated from [LUCENE-5471](https://issues.apache.org/jira/browse/LUCENE-5471) by Richard N. Hillegas, updated Mar 03 2014
Attachments: [SecureLucene.java](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-5471/SecureLucene.java) (versions: 2)
Linked issues:
- [DERBY-590](https://issues.apache.org/jira/browse/DERBY-590)

Contributor guide

Open the contributing guide

Research direction

Start with the attached SecureLucene.java program and reproduce the failure under a Java SecurityManager, comparing it with runs where no manager is installed or one is installed later. Trace the Lucene45 SPI lookup from the stack trace and determine why the classpath appears empty; done means the failing scenario is resolved and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.