can you please help me figure out what is wrong with the DB_VENDOR in MyBatis? I'm using mybatis 3.4.2, mybatis-spring 1.3.1, spring 4.3.6.RELEASE.
Everything, but the vendor dependent queries, works fine. The example query is not vendor dependent, this is only for the sake of this example. If I remove the databaseId attribute from it and remove the duplicated one, this query works.
I need to support Oracle and PostgreSQL and have already checked the metadata getDatabaseProductName() directly within my test scope, getting "Oracle" and "PostgreSQL". So if I got the documentation right, it should work, shouldn't it?
All I get with the databaseId in place is:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): mappers.ConfigurationMapper.containsKey
test-mybatis-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "Http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<databaseIdProvider type="DB_VENDOR">
<property name="PostgreSQL" value="postgres"/>
<property name="Oracle" value="oracle"/>
</databaseIdProvider>
<mappers>
<mapper resource="mybatis/ConfigurationMapper.xml"/>
</mappers>
</configuration>
test-context.xml (having another one with PostgreSQL datasource)
<mybatis:scan base-package="mappers" annotation="org.apache.ibatis.annotations.Mapper" factory-ref="sqlSessionFactory"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:#localhost:1521:XE"/>
<property name="username" value="test"/>
<property name="password" value="test"/>
</bean>
<bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:test-mybatis-config.xml"/>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
ConfigurationMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mappers.ConfigurationMapper">
<select id="containsKey" resultType="string" parameterType="string" databaseId="oracle">
SELECT '1' AS test FROM config_keys WHERE key = #{configKey}
</select>
<select id="containsKey" resultType="string" parameterType="string" databaseId="postgres">
SELECT '1' AS test FROM config_keys WHERE key = #{configKey}
</select>
</mapper>
mapper interface:
#Mapper
public interface ConfigurationMapper {
String containsKey(#Param("configKey") String configKey);
}
Found it. The answer is in the XMLConfigBuilder:
Environment environment = configuration.getEnvironment();
if (environment != null && databaseIdProvider != null) {
String databaseId = databaseIdProvider.getDatabaseId(environment.getDataSource());
configuration.setDatabaseId(databaseId);
}
The environment must be configured in order to make the databaseId work.
Here is how to use multi-db support in spring environment: http://www.mybatis.org/spring/factorybean.html
<bean id="vendorProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="SQL Server">sqlserver</prop>
<prop key="DB2">db2</prop>
<prop key="Oracle">oracle</prop>
<prop key="MySQL">mysql</prop>
</props>
</property>
</bean>
<bean id="databaseIdProvider" class="org.apache.ibatis.mapping.VendorDatabaseIdProvider">
<property name="properties" ref="vendorProperties"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath*:sample/config/mappers/**/*.xml" />
<property name="databaseIdProvider" ref="databaseIdProvider"/>
</bean>
Related
My Requirement is I need to have two datasource connected to Spring Batch Application.
1) One for Spring Batch Jobs and Executions storing
2) One for Business Data Stroing, Processing and Retreiving.
I know that there are lot of solutions for achieving this. But I have achieved by setting the second datasource as primary. The problem is the second datasource is not coming under transaction scope instead it is committing for each sql statement executing expecially through jdbctemplate.
As I can't able to edit my question. I am writing another Post in detail
My Requirement is I need to have two datasource connected to Spring Batch Application.
1) One for Spring Batch Jobs and Executions storing
2) One for Business Data Stroing, Processing and Retreiving.
In env-context.xml I have following configuration
<!-- Enable annotations-->
<context:annotation-config/>
<bean primary="true" id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/DB2XADS"/>
</bean>
<!-- Creating TransactionManager Bean, since JDBC we are creating of type
DataSourceTransactionManager -->
<bean id="transactionManager" primary="true"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- jdbcTemplate uses dataSource -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="batchTransactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
<bean id="transactionTemplate"
class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="transactionManager" />
</bean>
In override-context.xml I have the following code
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- jdbcTemplate uses dataSource -->
<bean id="batchDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/MySqlDS"/>
</bean>
<bean class="com.honda.pddabulk.utility.MyBatchConfigurer">
<property name="dataSource" ref="batchDataSource" />
</bean>
<!-- Use this to set additional properties on beans at run time -->
<bean id="placeholderProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/org/springframework/batch/admin/bootstrap/batch.properties
</value>
<value>classpath:/batch/batch-mysql.properties</value>
<value>classpath:log4j.properties</value>
</list>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="ignoreResourceNotFound" value="true"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="order" value="1"/>
</bean>
<!-- Overrider job repository -->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="databaseType" value="mysql"/>
<property name="dataSource" ref="batchDataSource"/>
<property name="tablePrefix" value="${batch.table.prefix}"/>
<property name="maxVarCharLength" value="2000"/>
<property name="isolationLevelForCreate" value="ISOLATION_SERIALIZABLE"/>
<property name="transactionManager" ref="batchTransactionManager"/>
</bean>
<!-- Override job service -->
<bean id="jobService" class="org.springframework.batch.admin.service.SimpleJobServiceFactoryBean">
<property name="tablePrefix" value="${batch.table.prefix}"/>
<property name="jobRepository" ref="jobRepository"/>
<property name="jobLauncher" ref="jobLauncher"/>
<property name="jobLocator" ref="jobRegistry"/>
<property name="dataSource" ref="batchDataSource"/>
</bean>
<!-- Override job launcher -->
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
<property name="taskExecutor" ref="jobLauncherTaskExecutor" />
</bean>
<task:executor id="jobLauncherTaskExecutor" pool-size="21" rejection-policy="ABORT" />
<!-- Override job explorer -->
<bean id="jobExplorer"
class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean">
<property name="tablePrefix" value="${batch.table.prefix}"/>
<property name="dataSource" ref="batchDataSource"/>
</bean>
In job-config.xml I have the following code
<context:component-scan base-package="com.honda.*">
<context:exclude-filter type="regex"
expression="com.honda.pddabulk.utility.MyBatch*" />
</context:component-scan>
I have the custom Batch configurer set. Now the problem is when I try to execute queries with jdbctemplate for update and insert it is not under transaction which means #Transactional is not working.
Rather commit is happening for each method call. The example is
#Transactional
public void checkInsertion() throws Exception{
try{
jdbcTemplate.update("INSERT INTO TABLE_NAME(COLUMN1, COLUMN2) VALUES( 'A','AF' );
throw new PddaException("custom error");
}catch(Exception ex){
int count=jdbcTemplate.update("ROLLBACK");
log.info("DATA HAS BEEN ROLLBACKED SUCCESSFULLY... "+count);
throw ex;
}
}
In the above code I am trying to insert data and immediately I am also throwing a exception which means the insert should happen but commit will not. So we will not be able to see any data but unfortunately the commit is happening. Please some one help
I am trying to #Autowire multiple Hibernate SessionFactory inside my application through Spring 4 SessionFactory DI. Only one Datasource(epi) is getting injected properly but the other two Datasources SessionFactory values are always null.
Two of them are oracle database and the other one is DB2. I am not sure what I am doing wrong.
Here is my spring-Datasource.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="epiStageDS"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver"/>
<property name="url" value="" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
<bean id="epi"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
<bean id="eveDS"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
<!-- Session factory for EPI db -->
<bean id="episessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="epi" />
<property name="packagesToScan">
<list>
<value>edu.eve.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql:false}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql:false}</prop>
</props>
</property>
</bean>
<!-- EVE DS SESSION FACTORY -->
<bean id="eveSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="eveDS" />
<property name="packagesToScan">
<list>
<value>edu.eve.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql:false}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql:false}</prop>
</props>
</property>
</bean>
<!-- Session factory for Stage DS db -->
<bean id="stageDsSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="epiStageDS" />
<property name="packagesToScan">
<list>
<value>edu.eve.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
<prop key="hibernate.show_sql">${hibernate.db2.show_sql:false}</prop>
<prop key="hibernate.format_sql">${hibernate.db2.format_sql:false}</prop>
</props>
</property>
</bean>
<bean id="epiTransactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="episessionFactory" />
</bean>
<bean id="eveTransactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="eveSessionFactory" />
</bean>
<bean id="stageDsTransactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="stageDsSessionFactory" />
</bean>
<bean id="persistenceExceptionTranslationPostProcessor"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
Here are the classes in which I am autowiring SessionFactory.
Below sessionFactory is getting injected perfectly.
#Transactional("epiTransactionManager")
public class EpiBaseService {
#Autowired
#Qualifier("episessionFactory")
private SessionFactory sessionFactory;
Autowired sessionFactory value are always null for below DS.
#Transactional("stageDsTransactionManager")
public class StageDsBaseService {
#Autowired
#Qualifier("stageDsSessionFactory")
private SessionFactory sessionFactory;
#Transactional("eveTransactionManager")
public class EveBaseService {
#Autowired
#Qualifier("eveSessionFactory")
private SessionFactory sessionFactory;
Please tell me what i am missing here.
I know what I was doing wrong. I was creating a new object of service class rather than #Autowiring inside the spring controller. I was doing this in order to make sure that my sessionfactory is not null but looks like that's not the correct way to do it. You have to use the Spring IOC container to inject the service class in your controller. Now all the sessionFactories are properly connected to specified datasources.
hi my project is Hsql embedded with spring+hibernate
my diectory like
project name
..src
....domain
....dao
....service
....main
..applicationContext.xml
..db/database
my database name is database
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">
<!-- Component scan to find all Spring components -->
<context:component-scan base-package="com.habitz.librarymanagement" />
<!-- Data Source -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value=" jdbc:hsqldb:db/database" />
<property name="username" value="sa" />
<property name="password" value="" />
<property name="initialSize" value="1" />
<property name="maxActive" value="5" />
<property name="poolPreparedStatements" value="true" />
<property name="maxOpenPreparedStatements" value="10" />
</bean>
<!-- Hibernate Session Factory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- Hibernate configuration -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
</props>
</property>
<!-- The packages that contain our Hibernate model classes -->
<property name="packagesToScan">
<list>
<value>com.habitz.librarymanagement.domain</value>
</list>
</property>
<!--
<property name="cacheRegionFactory">
<bean id="cacheRegionFactory" class="org.hibernate.cache.impl.NoCachingRegionFactory" />
</property>
<property name="eventListeners">
<map></map>
</property>
-->
</bean>
<!-- Hibernate transaction management -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>
when i run through main class it gives me
Cannot create JDBC driver of class 'org.hsqldb.jdbcDriver' for connect URL ' jdbc:hsqldb:db/database'
canot find suitable drivers...
but hsqldb.jar in claspath..!!
someone know please help..!!
Regarding the previous answer to clarify confusion.
Both driver classnames are valid.
If you look at org.hsqldb.jdbcDriver it's a very simple class
/* Copyright (c) 2001-2011, The HSQL Development Group
package org.hsqldb;
import org.hsqldb.jdbc.JDBCDriver;
public class jdbcDriver extends JDBCDriver {}
All it does is extend org.hsqldb.jdbc.JDBCDriver and is therefore just an alias to it.
I'm not an expert of XML but it seems to me the name of the driver class is wrong.
Using plain Java code, I pass "org.hsqldb.jdbc.JDBCDriver" as the driver's classname.
I'm having issues properly setting up my Hibernate configuration. After trying to extend the HibernateDaoSupport into a GenericDao and extending those to class-specific daos, but when I call findByNamedQuery in my dao, getSession() throws an NPE.
When I tried switching to extending HibernateTemplate, the hibernateTemplate doesn't get instantiated properly, and is still null:
java.lang.NullPointerException
at org.springframework.orm.hibernate3.support.HibernateDaoSupport.getSession(HibernateDaoSupport.java:143)
at com.jmt.hibernate.dao.GenericDaoImpl.findByNamedQuery(GenericDaoImpl.java)
What am I missing??
I used maven2 to build the project,
1. added the hibernate plugin into my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>3.0</version>
<configuration>
<components>
<component>
<name>hb2ddl</name>
<implementation>jpaconfiguration</implementation>
</component>
</components>
<componentProperties>
<drop>true</drop>
<outputfilename>output.sql</outputfilename>
<format>false</format>
<persistenceunit>MyEntityManager</persistenceunit>
<ejb3>true</ejb3>
</componentProperties>
</configuration>
</plugin>
2. defined my entity manager in persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="MyEntityManager" transaction-type="RESOURCE_LOCAL"> <!-- "JTA"> -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/DefaultDS</jta-data-source>
<class>com.jmt.model.UserEntity</class>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<validation-mode>CALLBACK</validation-mode>
<properties>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/><!-- org.hibernate.dialect.HSQLDialect" -->
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.connection.url" value="${jdbc.url}"/>
<property name="hibernate.connection.username" value="${jdbc.username}"/>
<property name="hibernate.connection.password" value="${jdbc.password}"/>
</properties>
</persistence-unit>
</persistence>
3. wired up my daos in applicationContext.xml:
<bean id="hibernateDaoSupport" abstract="true"
class="org.springframework.orm.hibernate3.support.HibernateDaoSupport">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="hibernateHelper" class="org.springframework.orm.hibernate3.HibernateTemplate" >
<constructor-arg ref="sessionFactory"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="hibernateManagedSession" value="true"/>
</bean>
<bean class="com.jmt.model.UserEntity"/>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="1" />
</bean>
<bean
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<property name="order" value="2" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="poolPreparedStatements" value="true"/>
<property name="defaultAutoCommit" value="true"/>
<property name="maxActive" value="100"/>
<property name="maxIdle" value="30"/>
<property name="maxWait" value="1000"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="60"/>
<property name="logAbandoned" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="10000"/>
<property name="minEvictableIdleTimeMillis" value="60000"/>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
<prop key="hibernate.jdbc.batch_size">15</prop>
<prop key="hibernate.connection.isolation">2</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.jmt.model</value>
<value>com.jmt.hibernate.dao</value>
</list>
</property>
</bean>
<bean id="userDao" class="com.jmt.hibernate.dao.UserDaoImpl">
<constructor-arg value="com.jmt.hibernate.dao.UserDaoImpl"/>
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
4. even added a filter into my web.xml hoping that would inject the session properly:
<filter>
<filter-name>sessionLoadingFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
I didn't add in a manager yet, hoping that fewer layers would make SOMETHING work...
Any help/ideas would be much appreciated!
I think you should try to do openSession() rather doing getSession(). Because at that point there might be the case that your session is not opened and you are trying to get it and hence it will result in a NPE.
Hope this helps you. Cheers.
Yuck, I did not think about where the call to the dao was being made, and yes, that's why there wasn't an open session. Someone had used spring dwr to call the dao directly from a jsp file. Once I got rid of that and made the call from my Controller, the session was finally being instantiated properly. Thanks for the help, Japs!
I am learning Spring and building a sample app.
I am getting the error:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Bean name '/list_cars.html' is already used in this file
Offending resource: ServletContext resource [/WEB-INF/springmvc-servlet.xml]
I previously got a similar error for a project which had a springmvc-servlet.xml file for which this error was true.But when I replaced it with the file below (and deleted the previous project and restarted Tomcat) I continue to the get the error, any help would be much appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- beans -->
<bean id="carManager" class="springmvc.service.CarManager">
<property name="carList">
<list>
<ref bean="car1"/>
<ref bean="car2"/>
</list>
</property>
</bean>
<bean id="brandManager" class="springmvc.service.BrandManager">
<property name="brandList">
<list>
<ref bean="brand1"/>
<ref bean="brand2"/>
</list>
</property>
</bean>
<bean id="brand1" class="springmvc.model.Brand">
<property name="id" value="1"/>
<property name="name" value="Mercedes"/>
<property name="country" value="Germany"/>
</bean>
<bean id="brand2" class="springmvc.model.Brand">
<property name="id" value="2"/>
<property name="name" value="Peugeot"/>
<property name="country" value="France"/>
</bean>
<bean id="car1" class="springmvc.model.Car">
<property name="id" value="1"/>
<property name="brand" ref="brand1"/>
<property name="model" value="SL 500"/>
<property name="price" value="40000"/>
</bean>
<bean id="car2" class="springmvc.model.Car">
<property name="id" value="2"/>
<property name="brand" ref="brand2"/>
<property name="model" value="607"/>
<property name="price" value="35000"/>
</bean>
<!-- urls -->
<bean name="/hello_world.html" class="springmvc.web.HelloWorldController"/>
<bean name="/list_cars.html" class="springmvc.web.CarListController">
<property name="carManager" ref="carManager"/>
</bean>
<bean name="/new_car.html" class="springmvc.web.CarNewController">
<property name="commandClass" value="springmvc.model.Car"/>
<property name="formView" value="carNew"/>
<property name="successView" value="list_cars.html"/>
<property name="validator">
<bean class="springmvc.validator.CarValidator"/>
</property>
<property name="carManager" ref="carManager"/>
<property name="brandManager" ref="brandManager"/>
</bean>
<!-- misc -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
Just to make things more readable, use proper bean name when defining a bean and put url name in the urlMapping properties like below to make a url map to a controller.
<bean name="carListController" class="springmvc.web.CarListController">
<property name="carManager" ref="carManager"/>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/list_cars.html">carListController</prop>
</props>
</property>
</bean>