我目前正在開發積極使用長耳兔的應用程序。這是我第一次使用長毛兔。我爲我的junit測試使用基於h2的配置。 Lucene搜索是在我的repository.xml禁用,唯一的問題是在日誌文件中的以下異常:當爲Jackrabbit啓用搜索索引時出現NullPointerException
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的功能時,我必須在repository.xml中啓用SearchIndex。
現在我所有的測試都失敗令人沮喪的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);
}
}
...
}
我已經fo在Jackrabbit 2.3.4上這個問題。我試圖用最近發佈的2.4.0 - 沒有成功。
似乎jackrabbit無法創建LoginModule配置部分中列出的用戶。但爲什麼?我錯過了什麼?
正確;請參閱https://svn.apache.org/repos/asf/jackrabbit/tags/2.4.3/jackrabbit-parent/pom.xml – Arjan 2012-12-21 21:33:24