09-28-2009 06:40 PM
package org.alfresco.sample;
import java.io.IOException;
import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.alfresco.web.scripts.AbstractWebScript;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptResponse;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestWebScript extends AbstractWebScript{
    public void execute(WebScriptRequest request, WebScriptResponse response) throws IOException {
        String result = "";
        try {
            ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
            Repository repository = (Repository)context.getBean("JCR.Repository");
            SimpleCredentials credentials = new SimpleCredentials("admin",  "admin".toCharArray());
            Session session = repository.login(credentials);
            Node rootNode = session.getRootNode();
            result = "Root node: path=" + rootNode.getPath() + ", type=" + rootNode.getPrimaryNodeType().getName();
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
        response.getWriter().write(result);
   }
}16:07:43,827  INFO  [alfresco.config.JndiPropertiesFactoryBean] Loading properties file from class path resource [alfresco/repository.properties]
16:07:43,828  INFO  [alfresco.config.JndiPropertiesFactoryBean] Loading properties file from class path resource [alfresco/domain/transaction.properties]
16:07:43,828  INFO  [alfresco.config.JndiPropertiesFactoryBean] Loading properties file from URL [file:/opt/Alfresco/tomcat/shared/classes/alfresco-global.properties]
16:07:43,868  INFO  [alfresco.config.JndiPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/alfresco-shared.properties]
Error: Error creating bean with name 'workflowScheduler' defined in class path resource [alfresco/bootstrap-context.xml]: Cannot resolve reference to bean 'jbpm_template' while setting bean property 'JBPMTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpm_template' defined in class path resource [alfresco/workflow-context.xml]: Cannot resolve reference to bean 'jbpm_configuration' while setting constructor argument with index 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpm_configuration' defined in class path resource [alfresco/workflow-context.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: a beanFactoryReference already exists for key jbpm_configuration            ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");            ApplicationContext context = ApplicationContextHelper.getApplicationContext(); 
					
				
		
10-14-2009 03:27 PM
 
					
				
		
10-14-2009 06:28 PM
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.