2014-03-04 59 views
2

我想部署這個示例改編自https://jackrabbit.apache.org/兔崽子忽略憑證

import javax.jcr.Repository; 
import javax.jcr.Session; 
import javax.jcr.SimpleCredentials; 
import javax.jcr.Node; 
import org.apache.jackrabbit.core.TransientRepository; 

/** 
* Second hop example. Stores, retrieves, and removes example content. 
*/ 
public class Fish { 

static Repository repository; 

public static void main(String[] args) { 

    Session session = null; 
    try { 
     repository = getRepositoryHandle(); 
     SimpleCredentials simpleCredentials = new SimpleCredentials(
       "username", "password".toCharArray()); 

     session = repository.login(simpleCredentials); 

     Node root = session.getRootNode(); 
     Node hello = root.addNode("Olá"); 
     Node world = hello.addNode("Mundo"); 
     world.setProperty("Message", "olá mundo"); 
     session.save(); 

     Node node = root.getNode("Olá/Mundo"); 
     System.out.println(node.getPath()); 
     System.out.println(node.getProperty("Message").toString()); 

     root.getNode("Olá").remove(); 
     session.save(); 
    } catch (Exception e) { 
     throw new RuntimeException(e); 
    } finally { 
     if (session != null) 
      session.logout(); 
    } 
} 

private static Repository getRepositoryHandle() { 
    if (repository == null) 
     repository = new TransientRepository(); 
    // "classpath:repository.xml", "target/repository"); 
    return repository; 
} 

} 

當我在日食部署它,我獲得以下錯誤和異常:

Exception in thread "main" java.lang.RuntimeException: javax.jcr.LoginException: LoginModule ignored Credentials 
    at recipe.Fish.main(Fish.java:38) 
Caused by: javax.jcr.LoginException: LoginModule ignored Credentials 
    at org.apache.jackrabbit.core.RepositoryImpl.login(RepositoryImpl.java:1526) 
    at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:381) 
    at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:144) 
    at recipe.Fish.main(Fish.java:22) 
Caused by: javax.security.auth.login.FailedLoginException: LoginModule ignored Credentials 
    at org.apache.jackrabbit.core.security.authentication.LocalAuthContext.login(LocalAuthContext.java:87) 
    at org.apache.jackrabbit.core.RepositoryImpl.login(RepositoryImpl.java:1498) 
    ... 3 more 

燦有人幫我解決這個問題嗎?

在此先感謝。

回答

3

似乎有人在通過Jackrabbit的例子工作時已經遇到過你的問題。見answer on another SO question

嘗試用「admin」和「admin」替換「用戶名」和「密碼」。

+0

感謝芽,它的工作原理! – user3381124