AnsweredAssumed Answered

not able to run SampleExample.java

Question asked by meetmrharish on Apr 30, 2009
Hi

Iam getting error while running the SimpleExample.java (the sample program given in SDK). I have included the jars as per the instructions. Even then Iam not able to run the program.

/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception.  You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.sample.jcr;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;



/**
* Simple Example that demonstrate login and retrieval of top-level Spaces
* under Company Home.
*
* @author David Caruana
*/
public class SimpleExample
{

    public static void main(String[] args)
        throws Exception
    {
        // Setup Spring and Transaction Service
        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()));

        try
        {
            // Retrieve Company Home
            Node root = session.getRootNode();
            Node companyHome = root.getNode("app:company_home");
           
            // Iterator through children of Company Home
            NodeIterator iterator = companyHome.getNodes();
            while(iterator.hasNext())
            {
                Node child = iterator.nextNode();
                System.out.println(child.getName());

                PropertyIterator propIterator = child.getProperties();
                while(propIterator.hasNext())
                {
                    Property prop = propIterator.nextProperty();
                    if (!prop.getDefinition().isMultiple())
                    {
                        System.out.println(" " + prop.getName() + " = " + prop.getString());
                    }
                }
            }
        }
        finally
        {
            session.logout();
            System.exit(0);
        }
       
    }
   
}

Iam getting the error like this

12:20:29,173  ERROR [transform.magick.AbstractImageMagickContentTransformer] ImageMagickContentTransformer not available: Failed to perform ImageMagick transformation: 
Execution result:
   os:         Windows Server 2003
   command:    [./ImageMagick/bin/convert, C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Alfresco\ImageMagickContentTransformer_init_source_27432.gif, C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Alfresco\ImageMagickContentTransformer_init_target_27433.png]
   succeeded:  false
   exit code:  2
   out:       
   err:        CreateProcess: .\ImageMagick\bin\convert C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Alfresco\ImageMagickContentTransformer_init_source_27432.gif C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Alfresco\ImageMagickContentTransformer_init_target_27433.png error=2
12:20:30,111  INFO  [config.xml.XMLConfigService$PropertyConfigurer] Loading properties file from class path resource [alfresco/file-servers.properties]
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cifsServer' defined in class path resource [alfresco/bootstrap-context.xml]: Cannot resolve reference to bean 'fileServerConfiguration' while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.alfresco.filesys.ServerConfigurationBean] for bean with name 'fileServerConfiguration' defined in class path resource [alfresco/bootstrap-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.alfresco.jlan.server.config.ServerConfiguration
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.alfresco.filesys.ServerConfigurationBean] for bean with name 'fileServerConfiguration' defined in class path resource [alfresco/bootstrap-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.alfresco.jlan.server.config.ServerConfiguration
Caused by: java.lang.NoClassDefFoundError: org.alfresco.jlan.server.config.ServerConfiguration
   at java.lang.ClassLoader.defineClassImpl(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:256)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:589)
   at java.net.URLClassLoader.access$400(URLClassLoader.java:123)
   at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1034)
   at java.security.AccessController.doPrivileged(AccessController.java:279)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:491)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:629)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:328)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:595)
   at org.springframework.util.ClassUtils.forName(ClassUtils.java:201)
   at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:327)
   at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1075)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:346)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
   at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
   at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
   at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:389)
   at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:120)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:799)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:717)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:384)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:247)
   at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:796)
   at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:592)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
   at org.alfresco.sample.jcr.SimpleExample.main(SimpleExample.java:53)

Outcomes