Why i am getting ClassNotFoundException DuplicateKeyException
Here is what i did..
1. created 3 xml files. db-context.xml, env-context.xml, infrastructure-context.xml
2. created 1 xml file webapp-config.xml ( it imports the beans from above 3 files and later set in contextParam)
3. created a properties file containing db details
there contents are as follows
Code:
db-context.xml
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}"></property>
<property name="url" value="${db.url}"></property>
<property name="username" value="${db.username}"></property>
<property name="password" value="${db.password}"></property>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
Code:
env-context.xml
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/bootstrap/db-mysql.properties</value>
</list>
</property>
</bean>
Code:
infrastructure-context.xml
<batch:job-repository id="jobRepository" data-source="dataSource" transaction-manager="transactionManager" isolation-level-for-create="SERIALIZABLE" />
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"></property>
<property name="taskExecutor" ref="jobLauncherTaskExecutor"></property>
</bean>
<task:executor id="jobLauncherTaskExecutor" pool-size="20"/>
Code:
db-mysql.properties
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://10.2.10.15/:3306/jobrepository
db.username=dev
db.password=password
Code:
webapp-config.xml
<import resource="classpath*:/bootstrap/*.xml"/>
Code:
HomeController.java
@RequestMapping(value = "/",method = RequestMethod.GET)
public String home(Locale locale, Model model) {
ApplicationContext ctx=new ClassPathXmlApplicationContext("/webapp-config.xml");
Job job=new SimpleJob("myjob1");
JobLauncher launcher=ctx.getBean(JobLauncher.class);
try {
launcher.run(job, new JobParametersBuilder().toJobParameters());
} catch (JobExecutionAlreadyRunningException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JobRestartException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JobInstanceAlreadyCompleteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JobParametersInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "home";
}
When i run this, I get ClassNotFoundExxception: org.springframework.dao.DuplicateKeyException
First Question why so?
Secondly i am using maven so added the dependency for spring-dao
but there is no such class in that jar.
Where am i wrong?
Please help.
Thanks.