Hi,

I've deployed jackrabbit-webapp-2.6.5.war in tomcat and I'm able to access 
http://localhost:8082/jackrabbit-webapp-2.6.5/server from browser.

But when I try to access repository from java test code
public class Test {

       @SuppressWarnings("nls")
       public static void main(String[] args) {

             Repository repository;
             Session session = null;
             try {
                    repository = JcrUtils
                                 
.getRepository("http://localhost:8082/jackrabbit-webapp-2.6.5/server";);

                    session = repository.login(new SimpleCredentials("admin", 
"admin"
                                 .toCharArray()));

                    Node node = session.getRootNode();

                    System.out.println("name" + node.getName() + " path "
                                 + node.getPath());

             } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
             } finally {
                    if (session != null) {
                           session.logout();
                    }

             }
       }
}

It fails with following error.
.
javax.jcr.RepositoryException: Unable to access a repository with the following 
settings:
    org.apache.jackrabbit.repository.uri: 
http://localhost:8082/jackrabbit-webapp-2.6.5/server
The following RepositoryFactory classes were consulted:
    org.apache.jackrabbit.core.RepositoryFactoryImpl: declined
    org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
    org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory: failed
        because of RemoteRuntimeException: java.rmi.RemoteException: Failed to 
read the resource at URL http://localhost:8082/jackrabbit-webapp-2.6.5/server; 
nested exception is:
               java.io.IOException: Server returned HTTP response code: 401 for 
URL: http://localhost:8082/jackrabbit-webapp-2.6.5/server
        because of RemoteException: Failed to read the resource at URL 
http://localhost:8082/jackrabbit-webapp-2.6.5/server; nested exception is:
               java.io.IOException: Server returned HTTP response code: 401 for 
URL: http://localhost:8082/jackrabbit-webapp-2.6.5/server
        because of IOException: Server returned HTTP response code: 401 for 
URL: http://localhost:8082/jackrabbit-webapp-2.6.5/server
    org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory: declined
Perhaps the repository you are trying to access is not available at the moment.
               at 
org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:219)
               at 
org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:259)
               at jackrabbit.Test.main(Test.java:33)



I've made following changes to Web.xml :

<servlet>
        <servlet-name>Repository</servlet-name>
        <description>
            This servlet provides other servlets and jsps a common way to access
            the repository. The repository can be accessed via JNDI, RMI or 
Webdav.
        </description>
        
<servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</servlet-class>

        <init-param>
            <param-name>bootstrap-config</param-name>
            <param-value>/WEB-INF/repository/bootstrap.properties</param-value>



And bootstrap.properties file looks as follows:

# Repository configuration settings (will be adjusted by installer)
repository.config=/WEB-INF/repository/repository.xml
repository.home=../analyticCatalog
repository.name=analyticCatalog.repository

# RMI Settings
rmi.enabled=true
rmi.port=1234
rmi.host=localhost
# If the URI is not specified, it's composed as follows:
#rmi.uri=//${rmi.host}:${rmi.port}/${repository.name}

# JNDI Settings
# all properties starting with 'java.naming.' will go into the
# environment of the initial context
jndi.enabled=true
# if the name is not specified, it's initialized with the repository.name
#jndi.name=${repository.name}
java.naming.provider.url=http://www.apache.org/jackrabbit
java.naming.factory.initial=org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory



security module in Reposiotry.xml:

<Security appName="Jackrabbit">
        <SecurityManager 
class="org.apache.jackrabbit.core.DefaultSecurityManager" 
workspaceName="security">
        </SecurityManager>
        <AccessManager 
class="org.apache.jackrabbit.core.security.DefaultAccessManager">
        </AccessManager>

        <LoginModule 
class="org.apache.jackrabbit.core.security.authentication.DefaultLoginModule">
           <param name="anonymousId" value="anonymous"/>
           <param name="adminId" value="admin"/>
        </LoginModule>
    </Security>


My questions are :


1.      Am I missing anything here ?

2.      Documentation says webDav should be enabled by default do I need to 
explicitly enable webdav somewhere just like we have rmi.enabled flag in 
bootstrap.properties ?

3.      Since it is a 401 error do I need to make any changes to login module ? 
or pass loging credentials when I call getRepository() ?

Kindly let me know if you need any more details.
Thanks in advance.

Regards,
Gaurang

Reply via email to