我使用jackrabbit 2.12.4作为JCA(通过RAR包)和旁边的 默认的JCR操作我想使用usermanager 添加/删除/编辑用户:
Session s = repo.login(...); UserManager umngr =((JackrabbitSession)s).getUserManager();
*抛出以下异常* java.lang.ClassCastException:org.apache.jackrabbit.jca.JCASessionHandle 无法转换为org.apache.jackrabbit.api.JackrabbitSession
只有在嵌入时才能进行用户管理吗?使用长耳大野兔 我可以使用或构建任何解决方法吗?
祝你好运
答案 0 :(得分:0)
要从Jackrabbit JCA登录存储库,您可以看到this topic,会话类是:
import java.io.Serializable;
import java.net.MalformedURLException;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jcr.LoginException;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@Stateless
public class OcmRepository implements Serializable {
public Repository repository;
public Session session;
public OcmRepository() {
}
public Session getSession(String log, String mdp) throws LoginException, RepositoryException, NamingException, MalformedURLException {
InitialContext initalContext = new InitialContext();
repository = (Repository) initalContext.lookup("jndi/jca");
session = repository.login(new SimpleCredentials(log, mdp.toCharArray()), null);
return session;
}
}