0

i am new to JackRabbit and i am trying to run FirstHop.java but iam getting following error.

code

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)

i am using following jars.

  1. commons-dbcp-1.2.jar
  2. commons-pool-1.5.jar
  3. jackrabbit-api-2.3.5.jar
  4. jackrabbit-core-2.4.2.jar
  5. jackrabbit-jcr-commons-2.3.5.jar
  6. jackrabbit-spi-2.1.3-.jar
  7. jackrabbit-spi-2.3.5.jar
  8. jackrabbit-spi-commons-2.3.5.jar
  9. jackrabbit-standalone-1.5.0.jar 10.jcr-2.0.jar 11.org.apache.sling.jcr.jackrabbit.api-2.0.2-incubator.jar

Thanks.

4

1 回答 1

0

为此,您只需要 Jackrabbit-Standalone jar。由于多个 jar 中存在相同的类定义,因此会发生多次冲突。此外,在使用 Jackrabbit 时,版本不匹配是不可取的,因为许多功能已从 1.5 更改为 2.4。

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

于 2012-10-23T12:53:13.183 回答