cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing an existing Alfresco server using Alfresco JCR API

pavan_kumar
Champ in-the-making
Champ in-the-making
Hi All,

Can anybody suggest me how to access an existing Alfresco server repository using the Alfresco JCR API. I want to do it via a normal Java program.

I tried looking into the SDK samples, but iam always getting an error "Invalid credentials". Am able to know that this is due to failure of authentication using the username/pwd as 'admin/admin' in the sample.

As in the samples, it is trying to run an embedded alfresco server. I am not able to try the same with other username/pwd for testing.

Can anybody suggested me anyways on how to solve this.
Anyhelp will be appriciated.

Thanks,
Pavan Kumar
5 REPLIES 5

davidc
Star Contributor
Star Contributor
Authentication can fail if the database and alf_data directory contents are out-of-sync. This can happen as the default alf_data directory location is relative and so depends on where you start the SDK sample.

I'd suggest for testing purposes, cleaning or setting up a new database schema and changing the value of alf_data in the file:

<sdk_root>\samples\FirstJCRClient\source\alfresco\extension\custom-repository.properties

to an absolute path and re-executing the JCR sample.  Admin/admin is valid for a clean install of the repository.

kishore
Champ in-the-making
Champ in-the-making
Make sure u have entry like,
  dir.root=C:\\alfresco\\alf_data in  custom-repository.properties of sdk     examples.

pavan_kumar
Champ in-the-making
Champ in-the-making
Hi David,

Thanks for the suggestion, that worked for me to run the sample.I have cleared the database and configured the data repository.

Also I was trying to build the same sample independent of the embedded alfresco server, i mean to connect to an already running
alfresco repository and do manipulations like adding,deleting  the content.I am successful to modify the sample to connect to a
running alfresco server and act on the repository.

But I am still not able to make the code completely independent,i mean not to start the embedded server. I have taken all the lib
with dependencies into a seperate project with configured repository properties  and context xml. When I am running the program
it is running the embedded server, but still adding the content to the configured alfresco repository.

Any idea what is the piece of code in the sample that is starting the embedded server.

Thanks in advance

tsx
Champ in-the-making
Champ in-the-making
Hello,

My apologies for digging up the old thread but this was the closest to what I'm trying to achieve and having troubles with. I'm new to both JSR 170 and the Spring Framework.

I'm trying to connect to an already running Alfresco repository from a simple java program. I've got the SDK setup and installed. I'm able to get connect using the FirstWebServiceClient but not using FirstJCRClient.

Alfresco is installed and running from C:\alfresco. I'm trying to execute example from my eclipse workspace. The FirstJCRClient example doesn't work the first time. I changed the 'dir.root' from 'custom-repository.properties' to 'C:\alfresco\alf_data'. After adding alfresco-blog-integration.jar and eventually all the jar files in the /server/ folder to the project's classpath I'm still not able to execute the FirstJCRClient. Here is the exception I get after adding every library to the classpath.


Exception in thread "main" java.lang.NullPointerException
   at org.alfresco.util.RuntimeSystemPropertiesSetter.postProcessBeanFactory(RuntimeSystemPropertiesSetter.java:68)
   at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:414)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:328)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:68)
   at org.alfresco.sample.FirstJCRClient.main(FirstJCRClient.java:61)


Once again, the FirstWebServiceClient does exactly what it's supposed to do. None of the JCR examples are working for me. Debugging didn't help much but it shows that it's not able to get the 'ApplicationContext' object from "classpath:alfresco/application-context.xml".

Any help or insight would be really appreciated.

Thanks in advance.

-tsx

vijayreddy
Champ in-the-making
Champ in-the-making
I have been trying to get this working as well with no luck so far. Any pointers to how I can access an existing server repository using the JCR API.

In the samples provided, only the Web service clients use the Alfresco remote jars; the samples for JCR API are using the embedded server aproach.

Thanks,
Vijay