Fórumok

Connection to a repository

thumbnail
Narmada V, módosítva 11 év-val korábban

Connection to a repository

Junior Member Bejegyzések: 37 Csatlakozás dátuma: 2012.05.14. Legújabb bejegyzések
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, módosítva 11 év-val korábban

RE: Connection to a repository

Liferay Master Bejegyzések: 658 Csatlakozás dátuma: 2010.06.15. Legújabb bejegyzések
Hi Narmada,

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

Thanks and Regards,
Apoorva Prakash
thumbnail
Narmada V, módosítva 11 év-val korábban

RE: Connection to a repository

Junior Member Bejegyzések: 37 Csatlakozás dátuma: 2012.05.14. Legújabb bejegyzések
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.