[rules-users] Help needed - Repository not getting initialised?
Praveen
praveen.sanju at gmail.com
Mon Nov 14 01:35:33 EST 2011
Hi,
Repository is not getting initialised, throws NPE.
Please advise.
TIA.
public static Repository repository;
public static Session getSession() throws Exception {
return getSession(true);
}
public static synchronized Session getSession(boolean erase) {
try {
if (repository == null) {
if (erase) {
File repoDir = new File("repository");
System.out.println("DELETE test repo dir: "
+ repoDir.getAbsolutePath());
RepositorySessionUtil.deleteDir(repoDir);
System.out.println("TEST repo dir deleted.");
}
JCRRepositoryConfigurator config = new
JackrabbitRepositoryConfigurator();
String home = System
.getProperty("guvnor.repository.dir");
repository = config.getJCRRepository(home);
Session testSession = repository
.login(new SimpleCredentials("alan_parsons",
"password".toCharArray()));
RulesRepositoryAdministrator admin = new
RulesRepositoryAdministrator(
testSession);
if (erase && admin.isRepositoryInitialized()) {
admin.clearRulesRepository();
}
config.setupRulesRepository(testSession);
return testSession;
} else {
return repository.login(new SimpleCredentials(
"alan_parsons", "password".toCharArray()));
}
} catch (RepositoryException e) {
throw new IllegalStateException(e);
}
}
public static void main(String [] args) throws Exception{
getSession();
}
Below is the exception..
DELETE test repo dir: D:\drools\TestRepository\repository
TEST repo dir deleted.
Exception in thread "main" java.lang.NullPointerException: dispatcher
at
org.apache.jackrabbit.core.observation.ObservationManagerImpl.<init>(ObservationManagerImpl.java:97)
at
org.apache.jackrabbit.core.WorkspaceImpl.getObservationManager(WorkspaceImpl.java:748)
at
org.apache.jackrabbit.core.SessionImpl.removeRegisteredEventListeners(SessionImpl.java:1193)
at org.apache.jackrabbit.core.SessionImpl.logout(SessionImpl.java:1222)
at
org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.doDispose(RepositoryImpl.java:2194)
at
org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.dispose(RepositoryImpl.java:2149)
at
org.apache.jackrabbit.core.RepositoryImpl.doShutdown(RepositoryImpl.java:1175)
at
org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:1127)
at
org.apache.jackrabbit.core.RepositoryImpl.initStartupWorkspaces(RepositoryImpl.java:544)
at
org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:366)
at
org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:673)
at
org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
at
org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
at
org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
at
org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
at Hello.getSession(Hello.java:50)
at Hello.getSession(Hello.java:27)
at Hello.main(Hello.java:72)
Regards,
Praveen.
--
View this message in context: http://drools.46999.n3.nabble.com/Help-needed-Repository-not-getting-initialised-tp3506064p3506064.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list