Я сейчас занимаюсь разработкой приложения, которое активно использует крольчиху.Это мой первый опыт с кроликом.Я использую конфигурацию на основе h2 для своих тестов junit.Поиск Lucene был отключен в моем файле repository.xml, и единственной проблемой было следующее исключение в файле журнала:
ERROR org.apache.jackrabbit.core.security.user.MembershipCache - Failed to retrieve membership references of 21232f29-7a57-35a7-8389-4a0e4a801fc3.
javax.jcr.RepositoryException: no search manager configured for this workspace
Все модульные тесты пройдены.Когда я начал тестировать функциональность, использующую UserManager.findAuthorizables , мне пришлось включить SearchIndex в repository.xml.
Теперь все мои тесты не пройдены с разочаровывающим исключением NullPointerException:
java.lang.NullPointerException
at org.apache.jackrabbit.core.query.lucene.MultiScorer.nextDoc(MultiScorer.java:68)
at org.apache.lucene.search.ConjunctionScorer.<init>(ConjunctionScorer.java:42)
at org.apache.lucene.search.ConjunctionScorer.<init>(ConjunctionScorer.java:33)
at org.apache.lucene.search.BooleanScorer2$2.<init>(BooleanScorer2.java:173)
at org.apache.lucene.search.BooleanScorer2.countingConjunctionSumScorer(BooleanScorer2.java:173)
at org.apache.lucene.search.BooleanScorer2.makeCountingSumScorerSomeReq(BooleanScorer2.java:234)
at org.apache.lucene.search.BooleanScorer2.makeCountingSumScorer(BooleanScorer2.java:211)
at org.apache.lucene.search.BooleanScorer2.<init>(BooleanScorer2.java:101)
at org.apache.lucene.search.BooleanQuery$BooleanWeight.scorer(BooleanQuery.java:328)
at org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisWeight.scorer(ChildAxisQuery.java:334)
at org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisWeight.scorer(ChildAxisQuery.java:332)
at org.apache.jackrabbit.core.query.lucene.DescendantSelfAxisQuery$DescendantSelfAxisWeight.scorer(DescendantSelfAxisQuery.java:395)
at org.apache.jackrabbit.core.query.lucene.LuceneQueryHits.<init>(LuceneQueryHits.java:52)
at org.apache.jackrabbit.core.query.lucene.JackrabbitIndexSearcher.evaluate(JackrabbitIndexSearcher.java:107)
at org.apache.jackrabbit.core.query.lucene.JackrabbitIndexSearcher.execute(JackrabbitIndexSearcher.java:85)
at org.apache.jackrabbit.core.query.lucene.SearchIndex.executeQuery(SearchIndex.java:814)
at org.apache.jackrabbit.core.query.lucene.SingleColumnQueryResult.executeQuery(SingleColumnQueryResult.java:74)
at org.apache.jackrabbit.core.query.lucene.QueryResultImpl.getResults(QueryResultImpl.java:275)
at org.apache.jackrabbit.core.query.lucene.SingleColumnQueryResult.<init>(SingleColumnQueryResult.java:66)
at org.apache.jackrabbit.core.query.lucene.QueryImpl.execute(QueryImpl.java:134)
at org.apache.jackrabbit.core.query.QueryImpl$1.perform(QueryImpl.java:132)
at org.apache.jackrabbit.core.query.QueryImpl$1.perform(QueryImpl.java:129)
at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216)
at org.apache.jackrabbit.core.query.QueryImpl.execute(QueryImpl.java:128)
at org.apache.jackrabbit.core.security.user.IndexNodeResolver.findNode(IndexNodeResolver.java:73)
at org.apache.jackrabbit.core.security.user.UserManagerImpl.getAuthorizable(UserManagerImpl.java:465)
at org.apache.jackrabbit.core.security.user.UserManagerImpl.setPrincipal(UserManagerImpl.java:698)
at org.apache.jackrabbit.core.security.user.UserManagerImpl.createUser(UserManagerImpl.java:558)
at org.apache.jackrabbit.core.security.user.UserManagerImpl.createUser(UserManagerImpl.java:541)
at org.apache.jackrabbit.core.security.user.UserManagerImpl.createAdmin(UserManagerImpl.java:948)
at org.apache.jackrabbit.core.security.user.UserManagerImpl.getAuthorizable(UserManagerImpl.java:426)
at org.apache.jackrabbit.core.DefaultSecurityManager.createSystemUsers(DefaultSecurityManager.java:613)
at org.apache.jackrabbit.core.DefaultSecurityManager.init(DefaultSecurityManager.java:204)
at org.apache.jackrabbit.core.RepositoryImpl.initSecurityManager(RepositoryImpl.java:463)
at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:324)
at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:582)
at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:232)
at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:280)
at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:376)
at ru.e.e.s.s.BaseJackrabbitRelatedTests.startRepository(BaseJackrabbitRelatedTests.java:81)
at ru.e.e.s.s.BaseJackrabbitRelatedTests.setUp(BaseJackrabbitRelatedTests.java:64)
at ru.e.e.s.s.i.p.JackrabbitIdentityRepositoryTests.setUp(JackrabbitIdentityRepositoryTests.java:28)
...
Вот мой repository.xml, который использует конфигурацию индекса поиска по умолчанию:
<?xml version="1.0"?>
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 2.0//EN" "http://jackrabbit.apache.org/dtd/repository-2.0.dtd">
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="org.h2.Driver"/>
<param name="url" value="jdbc:h2:memFS:test"/>
</FileSystem>
<DataStore class="org.apache.jackrabbit.core.data.FileDataStore"/>
<Security appName="Jackrabbit">
<SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" workspaceName="security">
<WorkspaceAccessManager class="org.apache.jackrabbit.core.security.simple.SimpleWorkspaceAccessManager"/>
</SecurityManager>
<AccessManager class="org.apache.jackrabbit.core.security.DefaultAccessManager" />
<LoginModule class="org.apache.jackrabbit.core.security.authentication.DefaultLoginModule">
<param name="adminId" value="admin"/>
<param name="anonimousId" value=""/>
</LoginModule>
</Security>
<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
<Workspace name="${wsp.name}">
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="org.h2.Driver"/>
<param name="url" value="jdbc:h2:memFS:testWsp"/>
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager">
<param name="driver" value="org.h2.Driver"/>
<param name="url" value="jdbc:h2:mem:itemState"/>
</PersistenceManager>
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${wsp.home}/index"/>
<param name="extractorPoolSize" value="2"/>
</SearchIndex>
</Workspace>
<Versioning rootPath="${rep.home}/version">
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="org.h2.Driver"/>
<param name="url" value="jdbc:h2:memFS:test/version"/>
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager">
<param name="driver" value="org.h2.Driver"/>
<param name="url" value="jdbc:h2:mem:version;db_close_delay=10"/>
</PersistenceManager>
</Versioning>
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${rep.home}/repository/index"/>
<param name="extractorPoolSize" value="2"/>
</SearchIndex>
</Repository>
Код запуска репозитория:
public abstract class BaseJackrabbitRelatedTests {
protected static Repository testRepository;
protected static Credentials adminCredentials;
private Session keepAliveSession;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
cleanRepository();
testRepository = new TransientRepository(JACKRABBIT_CONFIGURATION_FILE, JACKRABBIT_REPOSITORY_PATH);
adminCredentials = new SimpleCredentials(JACKRABBIT_USERNAME, JACKRABBIT_PASSWORD.toCharArray());
}
private static void cleanRepository() throws Exception {
FileUtils.deleteQuietly(new File(JACKRABBIT_REPOSITORY_PATH));
}
@Before
public void setUp() throws Exception {
startRepository();
...
}
private void startRepository() throws Exception {
if (keepAliveSession == null) {
keepAliveSession = testRepository.login(adminCredentials, JACKRABBIT_DEFAULT_WORKSPACE);
}
}
...
}
Я обнаружил эту проблему на Jackrabbit 2.3+0,4.Я пытался использовать недавно выпущенную версию 2.4.0 - безуспешно.
Похоже, что крольчонку не удается создать пользователей, перечисленных в разделе конфигурации LoginModule.Но почему?Чего мне не хватает?