需要帮助jackRabbit helloworld示例

时间:2012-10-05 07:01:08

标签: java jackrabbit

我是JackRabbit的新手,我正在尝试运行FirstHop.java但是我遇到了以下错误。

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

public class FirstHop { 

    public static void main(String[] args) throws Exception 
    {

        Repository repository = (Repository) new TransientRepository(); 
        Session session = repository.login(); 
        try 
        { 
            String user = session.getUserID(); 
            String name = repository.getDescriptor(Repository.REP_NAME_DESC); 
            System.out.println( 
            "Logged in as " + user + " to a " + name + " repository."); 
        } 
        finally 
        { 
            session.logout(); 
        } 
    } 
} 

log4j:WARN No appenders could be found for logger (org.apache.jackrabbit.core.TransientRepository).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.jackrabbit.spi.Path.resolve(Lorg/apache/jackrabbit/spi/Path$Element;)Lorg/apache/jackrabbit/spi/Path;
    at org.apache.jackrabbit.core.version.InternalVersionManagerImpl.<clinit>(InternalVersionManagerImpl.java:86)
    at org.apache.jackrabbit.core.RepositoryImpl.createVersionManager(RepositoryImpl.java:492)
    at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:311)
    at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:589)
    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 org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:111)
    at com.ksh.FirstHop.main(FirstHop.java:23)

我正在使用以下罐子。

  1. 公地DBCP-1.2.jar
  2. 公地池-1.5.jar
  3. 兔崽子-API-2.3.5.jar
  4. 兔崽子核-2.4.2.jar
  5. 兔崽子-JCR-公地2.3.5.jar
  6. 兔崽子-SPI-2.1.3-的.jar
  7. 兔崽子-SPI-2.3.5.jar
  8. 兔崽子-SPI-公地2.3.5.jar
  9. 兔崽子-独立-1.5.0.jar 10.jcr-2.0.jar 11.org.apache.sling.jcr.jackrabbit.api-2.0.2-incubator.jar
  10. 感谢。

1 个答案:

答案 0 :(得分:0)

你需要Jackrabbit-Standalone罐子。由于多个罐中存在相同的类定义,因此会发生多个冲突。此外,在使用Jackrabbit时,由于许多功能已从1.5更改为2.4,因此不建议使用版本不匹配。

我只用jackrabbit-Standalone jar运行相同的程序。