I'm new to springframework and I'm trying to follow the sample program from "Spring: A Developer's Notebook".
I get an error in my spring configuration file that says it cannot find the "id" field to create the sessionFactory bean. I don't understand what this means.
The spring configuration file is as follows:Code:Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [RentABike-context.xml]: Initialization of bean failed; nested exception is org.hibernate.PropertyNotFoundException: field not found: id org.hibernate.PropertyNotFoundException: field not found: id at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:97) at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:104) at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:112) at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:89) at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77) at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276) at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:403) at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:336) at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:275) at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:146) at org.hibernate.cfg.Configuration.add(Configuration.java:385) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:426) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:654) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1059) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:63) at spring.RentABikeAssembler.main(RentABikeAssembler.java:10)
Note that I only want to output the results to the console. I haven't integrated it yet with tomcat or other web UI. What do I need to change in the spring config file to fix this.Code:<beans> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>org.hsqldb.jdbcDriver</value> </property> <property name="url"> <value>jdbc:hsqldb:hsql://localhost</value> </property> <property name="username"> <value>sa</value> </property> </bean> <bean id="rentaBike" class="spring.HibRentABike"> <property name="storeName"> <value>"Bruce's Bikes"</value> </property> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="mappingResources"> <list> <value>spring/Bike.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.HSQLDialect </prop> </props> </property> </bean> <bean id="commandLineView" class="spring.CommandLineView"> <property name="rentaBike"> <ref bean="rentaBike" /> </property> </bean> </beans>
Thanks!


Reply With Quote
