Announcement Announcement Module
Collapse
No announcement yet.
Need configuration help! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need configuration help!

    I've just started playing with Spring today, went over the documentation, and am trying to set up a small example as described there. So far, no luck! Would someone please give me a hand?

    Here is the code I'm trying to run:

    Code:
    InputStream res = new FileInputStream("context.xml");
    
    XmlBeanFactory factory = new XmlBeanFactory(res);

    Here is the xml that configures the bean:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
    	
    
    	<bean id="testBean" class="test.TestBean">
    		<property name="name">
    			<value>
    				This is a name
    			</value>
    		</property>
    		
    		<property name="description">
    			<value>
    				Description
    			</value>
    		</property>
    	</bean>
    	
    </beans>

    Here is my test bean:

    Code:
    public class TestBean &#123;
    
      private String name = null;
      private String description = null;
    
      public void setName&#40;String name&#41; &#123;
        this.name = name;
      &#125;
    
      public void setDescription&#40;String description&#41; &#123;
        this.description = description;
      &#125;
    
      public String getName&#40;&#41; &#123;
        return name;
      &#125;
    
      public String getDescription&#40;&#41; &#123;
        return description;
      &#125;
    
      public TestBean&#40;&#41; &#123;
      &#125;
    
      /**
       * TestBean
       *
       * @param name String
       * @param descr String
       */
      public TestBean&#40;String name, String descr&#41; &#123;
    
        this.name= name;
        this.description = descr;
      &#125;
    
    &#125;
    I've added spring.jar to the classpath. Using version 1.1.1

    Here is the error I'm getting:

    C:\Borland\JavaStudio\jdk1.4\bin\javaw -classpath "C:\JBuilderProjects\SpringStarter\classes;C:\jaka rta-log4j-1.2.8\dist\lib\log4j-1.2.8.jar;C:\spring-framework-1.1.1\dist\spring.jar;C:\Borland\JavaStudio\jdk1.4 \demo\jfc\Java2D\Java2Demo.jar;C:\Borland\JavaStud io\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\ Borland\JavaStudio\jdk1.4\jre\javaws\javaws.jar;C: \Borland\JavaStudio\jdk1.4\jre\lib\charsets.jar;C: \Borland\JavaStudio\jdk1.4\jre\lib\ext\dnsns.jar;C :\Borland\JavaStudio\jdk1.4\jre\lib\ext\ldapsec.ja r;C:\Borland\JavaStudio\jdk1.4\jre\lib\ext\localed ata.jar;C:\Borland\JavaStudio\jdk1.4\jre\lib\ext\s unjce_provider.jar;C:\Borland\JavaStudio\jdk1.4\jr e\lib\im\indicim.jar;C:\Borland\JavaStudio\jdk1.4\ jre\lib\im\thaiim.jar;C:\Borland\JavaStudio\jdk1.4 \jre\lib\jce.jar;C:\Borland\JavaStudio\jdk1.4\jre\ lib\jsse.jar;C:\Borland\JavaStudio\jdk1.4\jre\lib\ plugin.jar;C:\Borland\JavaStudio\jdk1.4\jre\lib\rt .jar;C:\Borland\JavaStudio\jdk1.4\jre\lib\sunrsasi gn.jar;C:\Borland\JavaStudio\jdk1.4\lib\dt.jar;C:\ Borland\JavaStudio\jdk1.4\lib\htmlconverter.jar;C: \Borland\JavaStudio\jdk1.4\lib\tools.jar" Controller
    java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.springframework.beans.factory.support.Abstract BeanFactory.<init>(AbstractBeanFactory.java:87)
    at org.springframework.beans.factory.support.Abstract BeanFactory.<init>(AbstractBeanFactory.java:121)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.<init>(AbstractAutowire CapableBeanFactory.java:115)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.<init>(DefaultListableBeanFacto ry.java:72)
    at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:82)
    at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:71)
    at Controller.main(Controller.java:24)
    Exception in thread "main"


    Could someone please help to resolve this?
    Thank you in advance.
    Simeon

  • #2
    You need to have commons-logging.jar in your classpath.

    Comment

    Working...
    X