Fórum

Connection to a repository

thumbnail
Narmada V, modificado 11 Anos atrás.

Connection to a repository

Junior Member Postagens: 37 Data de Entrada: 14/05/12 Postagens Recentes
Hi,

i want to establish connection to the repository and retreive the content of the repository using a java class in the custom portlet project created from eclipse.

Can anyone give me the sample code on how the connection can be established from the portlet java class.

Thanks,
Narmada
thumbnail
Apoorva Prakash, modificado 11 Anos atrás.

RE: Connection to a repository

Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens Recentes
Hi Narmada,

Better if you use Service Builder concept rather than making normal DB connection.

Thanks and Regards,
Apoorva Prakash
thumbnail
Narmada V, modificado 11 Anos atrás.

RE: Connection to a repository

Junior Member Postagens: 37 Data de Entrada: 14/05/12 Postagens Recentes
hi prakash,

As per my understanding, servilce builder deals with the tables in db. But my repository of CQ5, doesnot contain any tables. It uses nodes to store the data.

I am using the below code snippet to connect to repository.

Repository repository = JcrUtils.getRepository( "http://localhost:4502/crx/server/");
renderRequest.setAttribute("repository",repository );
Session session = repository.login(new SimpleCredentials("admin", "******".toCharArray()));

But i am getting the below exception :

javax.jcr.RepositoryException: Unable to access a repository with the following settings:
org.apache.jackrabbit.repository.uri: http://localhost:4502/crx/server/
The following RepositoryFactory classes were consulted:
org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory: failed
because of RepositoryException: Failed to read the resource at URL http://localhost:4502/crx/server/
because of ConnectException: Connection refused: connect

Should i configure any xml files to establish the connection??

Can anyone help me to establlish the connection to the repository.