Results 1 to 9 of 9

Thread: Trying to learn, keep getting the same problem.

  1. #1
    Join Date
    Apr 2008
    Posts
    4

    Default Trying to learn, keep getting the same problem.

    I've recently started learning Spring. I've looked at the online MVC tutorial and have used "Spring, A Developer's Notebook". I keep running into the same problem. I define a bean in the *servlet.xml file that has a property with a value. After deploying the code to tomcat (6.0.16) and starting up, I keep getting initialization of bean failed. It seems to not be reading or interpreting the value. Here is part of my servlet.xml file.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>

    <bean id="rentaBike" class="com.springbook.ArrayListRentABike">
    <property name="storeName"><value>Bruce's Bikes</value></property>
    </bean>


    And here is the error I receive from tomcat:

    SEVERE: StandardWrapper.Throwable
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'rentaBike' defined in ServletContext resource [/WEB-INF/RentABikeApp-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.String] for property 'storeName'; nested exception is java.lang.IllegalArgumentException: Original must not be null
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:470)


    Any help would be appreciated.

  2. #2
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    I don't have a copy of this book, but have you checked the errata?
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  3. #3
    Join Date
    Apr 2008
    Posts
    4

    Default Yes repeatedly

    yes, many times. I've reread the chapters. By the way. It is also happening with the tutorial that is on the springframework.org web site.

  4. #4
    Join Date
    Mar 2008
    Location
    Taylors, SC USA
    Posts
    8

    Default

    In the class com.springbook.ArrayListRentABike, of what type is storeName?

  5. #5
    Join Date
    Oct 2007
    Location
    Indianapolis, IN
    Posts
    62

    Default

    Quote Originally Posted by boblaw View Post
    Code:
    <bean id="rentaBike" class="com.springbook.ArrayListRentABike">
    		<property name="storeName"><value>Bruce's Bikes</value></property>
    	</bean>
    Try using this instead.

    Code:
    <bean id="rentaBike" class="com.springbook.ArrayListRentABike">
    		<property name="storeName"><value>Bruce&apos;s Bikes</value></property>
    	</bean>
    Regards,
    Smruti..
    ------------------------------
    Smruti K Mohapatra

  6. #6
    Join Date
    Apr 2008
    Posts
    4

    Default

    storeName is a String

  7. #7
    Join Date
    Apr 2008
    Posts
    4

    Default

    It doesn't make any difference. I have even tried it without the quote sign. I read somewhere that tomcat creates a bean object and doesn't initialize it. That might be causing the null value. I don't know what the work around is if this is the problem.

  8. #8
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Can you upload a ZIP of your project and someone can perhaps try it out?
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  9. #9
    Join Date
    Oct 2007
    Location
    Indianapolis, IN
    Posts
    62

    Default

    Quote Originally Posted by boblaw View Post
    It doesn't make any difference. I have even tried it without the quote sign. I read somewhere that tomcat creates a bean object and doesn't initialize it. That might be causing the null value. I don't know what the work around is if this is the problem.
    I never had such problems with tomcat. Did u try to do this ?
    <property name="storeName" value="Bruce's Bikes" />
    Regards,
    Smruti..
    ------------------------------
    Smruti K Mohapatra

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •