cancel
Showing results for 
Search instead for 
Did you mean: 

connect to remote alfresco repository

thierensbart
Champ in-the-making
Champ in-the-making
Hi,

I'm new to the whole Alfresco-thing (only worked with Xerox DocuShare and EMC Documentum) and I'm stuck before I have even begun…

Setup:
- Server running Alfresco 3.2
- my pc on which I'm developing a Java app that should get the folderstructure of the Alfresco repo.

I'm stuck trying to connect to the repository using JSR170.

I found alot of websites saying:
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
       
        // Retrieve Repository
        Repository repository = (Repository)context.getBean("JCR.Repository");

        // Login to workspace
        // Note: Default workspace is the one used by Alfresco Web Client which contains all the Spaces
        //       and their documents
        Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
But this code doesn't specify any ip or whatever. 

When I run it, I get
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [alfresco/application-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [alfresco/application-context.xml] cannot be opened because it does not exist
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
   at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
   at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
   at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
   at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
   at com.docbyte.migration.action.Migrate.go(Migrate.java:19)
   at com.docbyte.migration.action.Migrate.main(Migrate.java:15)
Caused by: java.io.FileNotFoundException: class path resource [alfresco/application-context.xml] cannot be opened because it does not exist
   at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
   … 14 more

I looked around these forums but didn't really find a solution. 
Anyone that can clarify how to connect to a remote repository and can specify what libraries/paths I need to add to the buildpath of my application?

Cheers,
Bart
8 REPLIES 8

mrogers
Star Contributor
Star Contributor
As you have probably guessed you need to use one of the remote APIs to do what you want.   

The recommended ways to access an alfresco repository are Web Scripts or failing that Web Services or one of the many file system projections.

thierensbart
Champ in-the-making
Champ in-the-making
Thanks for that info.

I'm just wondering if it's gonna be performant enough.

I'm doing a migration of the folder-structure + acl's to a Documentum environment.
And we're talking lotsa data here!

ajkalbente
Champ in-the-making
Champ in-the-making
Maybe you could try using Talend for your migration.

Talend Open Studio is an open source ETL tool for data integration and migration experts. It's easy to learn for a non-technical user. What distinguishes Talend, when it comes to business users, is the tMap component. It allows the user to get a graphical and functional view of integration processes. For more information: http://www.talend.com/

ssaravanan
Champ in-the-making
Champ in-the-making
I have setup a single instance of Alfresco 3.2.0 (r2 2440), which will be accessed by remote Share apps running in 12 of the clients regional offices. I have used the amazon's cloud  AMI ID: ami-77c5ee03 alfresco instance , which I will be using as my remote alfresco repository for the test case. Now I have a local instance of Share configured to talk with the public DNS - http://ec2-79-125-30-107.eu-west-1.compute.amazonaws.com. I am able to create a site, etc,, but when I access the document library an exception is thrown.
my webscript-framework-custom-config.xml is

<alfresco-config>

  

   <!– Overriding endpoints to reference a remote Alfresco server –>

   <config evaluator="string-compare" condition="Remote">

      <remote>

           <endpoint>

         <id>alfresco-noauth</id>

         <name>Alfresco - unauthenticated access</name>

         <description>Access to Alfresco Repository WebScripts that do not require authentication</description>

         <connector-id>alfresco</connector-id>

         <endpoint-url>http://ec2-79-125-30-107.eu-west-1.compute.amazonaws.com/alfresco/s</endpoint-url>

         <identity>none</identity>

      </endpoint>



      <endpoint>

         <id>alfresco</id>

         <name>Alfresco - user access</name>

         <description>Access to Alfresco Repository WebScripts that require user authentication</description>

         <connector-id>alfresco</connector-id>

         <endpoint-url>http://ec2-79-125-30-107.eu-west-1.compute.amazonaws.com/alfresco/s</endpoint-url>

         <identity>user</identity>

      </endpoint>



      <endpoint>

         <id>alfresco-feed</id>

         <name>Alfresco Feed</name>

         <description>Alfresco Feed - supports basic HTTP authentication</description>

         <connector-id>http</connector-id>

         <endpoint-url>http://ec2-79-125-30-107.eu-west-1.compute.amazonaws.com/alfresco/s</endpoint-url>

         <basic-auth>true</basic-auth>

         <identity>user</identity>

      </endpoint>

   </remote>

   </config>

</alfresco-config>

Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "XML" is not defined. (file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/documentlist.get.js#41)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
14:15:03,925  ERROR [web.scripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 01220047 Failed to load script '/org/alfresco/components/documentlibrary/filter.get.js (in classpath store file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts)': 01220046 ReferenceError: "XML" is not defined. (file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/filter.get.js#9)
org.alfresco.web.scripts.WebScriptException: 01220047 Failed to load script '/org/alfresco/components/documentlibrary/filter.get.js (in classpath store file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts)': 01220046 ReferenceError: "XML" is not defined. (file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/filter.get.js#9)
        at org.alfresco.web.scripts.PresentationScriptProcessor.executeScript(PresentationScriptProcessor.java:193)

14:15:03,810  ERROR [web.scripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 01220043 Failed to load script '/org/alfresco/components/documentlibrary/toolbar.get.js (in classpath store file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts)': 01220042 ReferenceError: "XML" is not defined. (file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/toolbar.get.js#34)
org.alfresco.web.scripts.WebScriptException: 01220043 Failed to load script '/org/alfresco/components/documentlibrary/toolbar.get.js (in classpath store file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts)': 01220042 ReferenceError: "XML" is not defined. (file:/opt/alfresco32/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrary/toolbar.get.js#34)
        at org.alfresco.web.scripts.PresentationScriptProcessor.executeScript(PresentationScriptProcessor.java:193)

ssaravanan
Champ in-the-making
Champ in-the-making
Has anyone tried this approach of having one instance of Alfresco running in a data center and many surf apps talking to the repository, if so is there any performance implication. At the moment I am designing this approach but found the above error in the Share webscripts, when accessing a remote repository. Any help is appreciated.thanks

rogerp
Champ in-the-making
Champ in-the-making
ssaravanan, with respect I think your issue is different from the thread starter's. Correct me if I'm wrong (anyone) but your bug might be related to the rhino bug, e.g.: here. i.e. it's failing to recognise new XML(config.script)

EDIT: Indeed, I suspect this is the case. As I had this bug with rhino; uninstalled rhino, installed spidermonkey, works fine.

ssaravanan
Champ in-the-making
Champ in-the-making
I resolved the issue by starting the Alfresco server as root , rather than a normal user

lino
Champ in-the-making
Champ in-the-making
Hi all i am developing a struts based portlet. i want to connect to JCR.Repository to create nodes and upload contents. but i am getting an error
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'JCR.Repository' is defined .
i already searched in this forum but didnt get any sutable solution.
Here is the code which i used to get the JCR.Repository
 ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:alfresco/jcr-context.xml");
Repository repository = (Repository) context.getBean("JCR.Repository");
I tested the same code using java console program. there it is working fine. I am using netbeans for the development. please help me for getting a good solution….