Announcement Announcement Module
Collapse
No announcement yet.
Trying to learn, keep getting the same problem. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    I don't have a copy of this book, but have you checked the errata?

    Comment


    • #3
      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.

      Comment


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

        Comment


        • #5
          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>

          Comment


          • #6
            storeName is a String

            Comment


            • #7
              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.

              Comment


              • #8
                Can you upload a ZIP of your project and someone can perhaps try it out?

                Comment


                • #9
                  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" />

                  Comment

                  Working...
                  X