SEVERE: Context initialization failed - spring

ERROR [2015-06-23 10:12:50,826] localhost-startStop-1 org.springframework.web.context.ContextLoader - Context initialization failed
java.lang.NoClassDefFoundError: org/springframework/beans/factory/config/BeanExpressionResolver
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:78)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:249)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.config.BeanExpressionResolver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
... 17 more
This is my applicationcontext.xml file...
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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="punit"/>
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="databasePlatform"><ref bean="dialect"/></property>
</bean>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/comp/env/jdbc/iclassifieddb"/>
</bean>
<bean id="dialect" class="org.springframework.jndi.JndiObjectFactoryBean" autowire-candidate="false">
<property name="jndiName" value="java:/comp/env/dialect"/>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<!-- Startup bean -->
<bean id="databaseSetup" class="com.Yasna.iclassified.util.DatabaseSetup">
<property name="mutableAclService" ref="aclService"/>
<property name="configurationDao"><ref bean="configurationItemDAO"/></property>
</bean>
<!-- DAOs -->
<bean id="categoryDAO"
class="com.Yasna.iclassified.category.CategoryDAOJPA">
</bean>
<bean id="configurationItemDAO"
class="com.Yasna.iclassified.configuration.ConfigurationItemDAOJPA">
</bean>
<bean id="dataElementDAO"
class="com.Yasna.iclassified.dataelement.DataElementDAOJPA">
</bean>
<bean id="postingDAO"
class="com.Yasna.iclassified.posting.PostingDAOJPA">
<property name="propertyHelperFactory"><ref bean="propertyHelperFactory"/></property>
<property name="luceneIndexer"><ref bean="luceneIndexer"/></property>
</bean>
<bean id="propertyDAO"
class="com.Yasna.iclassified.property.PropertyDAOJPA">
</bean>
<bean id="imagePropertyDAO"
class="com.Yasna.iclassified.property.ImagePropertyDAOJPA">
<property name="configurationDAO"><ref bean="configurationItemDAO"/></property>
</bean>
<bean id="userDAO"
class="com.Yasna.iclassified.user.UserDAOJPA">
</bean>
<!-- Controllers. Remember to specify the appropriate DAO as the dao parameter -->
<bean id="categoryController" scope="prototype" class="com.Yasna.iclassified.category.CategoryController">
<property name="dao"><ref bean="categoryDAO"/></property>
<property name="postingDAO"><ref bean="postingDAO"/></property>
<property name="securityHelper"><ref bean="securityHelper"/></property>
</bean>
<bean id="configurationController" scope="prototype" class="com.Yasna.iclassified.configuration.ConfigurationController">
<property name="dao"><ref bean="configurationItemDAO"/></property>
</bean>
<bean id="dataelementController" scope="prototype" class="com.Yasna.iclassified.dataelement.DataElementController">
<property name="dao"><ref bean="dataElementDAO"/></property>
<property name="categoryDAO"><ref bean="categoryDAO"/></property>
<property name="securityHelper"><ref bean="securityHelper"/></property>
</bean>
<bean id="postingController" scope="prototype" class="com.Yasna.iclassified.posting.PostingController">
<property name="dao"><ref bean="postingDAO"/></property>
<property name="categoryDAO"><ref bean="categoryDAO"/></property>
<property name="propertyDAO"><ref bean="propertyDAO"/></property>
<property name="dataElementDAO"><ref bean="dataElementDAO"/></property>
<property name="configurationDAO"><ref bean="configurationItemDAO"/></property>
<property name="mutableAclService"><ref bean="aclService"/></property>
<property name="propertyHelperFactory"><ref bean="propertyHelperFactory"/></property>
<property name="securityHelper"><ref bean="securityHelper"/></property>
</bean>
<bean id="postingListController" scope="prototype" class="com.Yasna.iclassified.posting.PostingListController">
<property name="postingDAO"><ref bean="postingDAO"/></property>
<property name="categoryDAO"><ref bean="categoryDAO"/></property>
</bean>
<bean id="userController" scope="prototype" class="com.Yasna.iclassified.user.UserController">
<property name="dao"><ref bean="userDAO"/></property>
<property name="securityHelper"><ref bean="securityHelper"/></property>
<property name="userHelper"><ref bean="userHelper"/></property>
</bean>
<!-- Property Helpers -->
<bean id="propertyHelperFactory" class="com.Yasna.iclassified.property.PropertyHelperFactory">
<property name="helperMap">
<map>
<entry>
<key>
<value>SHORT_TEXT</value>
</key>
<ref bean="textHelper"/>
</entry>
<entry>
<key>
<value>LONG_TEXT</value>
</key>
<ref bean="textHelper"/>
</entry>
<entry>
<key>
<value>IMAGE</value>
</key>
<ref bean="imageHelper"/>
</entry>
<entry>
<key>
<value>CURRENCY</value>
</key>
<ref bean="currencyHelper"/>
</entry>
<entry>
<key>
<value>DEFAULT_CURRENCY</value>
</key>
<ref bean="defaultCurrencyHelper"/>
</entry>
</map>
</property>
</bean>
<bean id="textHelper" class="com.Yasna.iclassified.property.TextPropertyHelper">
<property name="propertyDAO"><ref bean="propertyDAO"/></property>
</bean>
<bean id="imageHelper" class="com.Yasna.iclassified.property.ImagePropertyHelper">
<property name="propertyDAO"><ref bean="imagePropertyDAO"/></property>
</bean>
<bean id="currencyHelper" class="com.Yasna.iclassified.property.CurrencyPropertyHelper">
<property name="propertyDAO"><ref bean="propertyDAO"/></property>
</bean>
<bean id="defaultCurrencyHelper" class="com.Yasna.iclassified.property.DefaultCurrencyPropertyHelper">
<property name="propertyDAO"><ref bean="propertyDAO"/></property>
</bean>
<!-- Miscellaneous actions -->
<bean id="homeController" scope="prototype" class="com.Yasna.iclassified.util.HomeController">
<property name="configurationDAO"><ref bean="configurationItemDAO"/></property>
<property name="userDAO"><ref bean="userDAO"/></property>
<property name="securityHelper"><ref bean="securityHelper"/></property>
<property name="userHelper"><ref bean="userHelper"/></property>
</bean>
<bean id="profileController" scope="prototype" class="com.Yasna.iclassified.user.ProfileController">
<property name="userDAO"><ref bean="userDAO"/></property>
<property name="postingDAO"><ref bean="postingDAO"/></property>
<property name="securityHelper"><ref bean="securityHelper"/></property>
</bean>
<bean id="getFile" class="com.Yasna.iclassified.util.GetFileAction">
<property name="propertyDAO"><ref bean="imagePropertyDAO"/></property>
</bean>
<bean id="postingSearchController" class="com.Yasna.iclassified.posting.PostingSearchController">
<property name="postingDAO"><ref bean="postingDAO"/></property>
<property name="luceneSearcher"><ref bean="luceneSearcher"/></property>
</bean>
<bean id="configurationCacheAction" scope="prototype" class="com.Yasna.iclassified.configuration.ConfigurationCacheAction">
<property name="configurationItemDAO"><ref bean="configurationItemDAO"/></property>
</bean>
<!-- Interceptors -->
<bean id="propertiesInterceptor" scope="prototype" class="com.Yasna.iclassified.struts.PropertiesInterceptor">
<property name="userDAO"><ref bean="userDAO"/></property>
<property name="postingDAO"><ref bean="postingDAO"/></property>
</bean>
<!-- Scheduled Jobs -->
<bean id="expiryJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="postingDAO" />
<property name="targetMethod" value="expirePostings" />
</bean>
<bean id="expiryTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="expiryJob" />
<!-- run every hour -->
<property name="cronExpression" value="0 0 * * * ?" />
</bean>
<bean id="versionCheck" class="com.Yasna.iclassified.util.VersionChecker">
<property name="configurationDAO" ref="configurationItemDAO"/>
</bean>
<bean id="versionCheckJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="versionCheck" />
<property name="targetMethod" value="checkVersion" />
</bean>
<bean id="versionTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="versionCheckJob" />
<!-- run every day at midday -->
<property name="cronExpression" value="0 0 12 * * ?" />
</bean>
<!--
<bean id="extraTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="expiryJob" />
<property name="cronExpression" value="0 * * * * ?" />
</bean>
-->
<!-- A list of Triggers to be scheduled and executed by Quartz -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="expiryTrigger"/>
<ref bean="versionTrigger"/>
<!-- <ref bean="extraTrigger"/> -->
</list>
</property>
</bean>
<!-- Email configuration -->
<bean id="mailProperties" scope="prototype" class="com.Yasna.iclassified.util.MailProperties">
<property name="configurationDAO"><ref bean="configurationItemDAO"/></property>
</bean>
<bean id="mailSender" scope="prototype" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host">
<bean factory-bean="mailProperties" factory-method="getHost"/>
</property>
<property name="password">
<bean factory-bean="mailProperties" factory-method="getPassword"/>
</property>
<property name="username">
<bean factory-bean="mailProperties" factory-method="getUser"/>
</property>
</bean>
<bean id="emailController" scope="prototype" class="com.Yasna.iclassified.email.EmailController">
<property name="postingDAO"><ref bean="postingDAO"/></property>
<property name="emailHelper"><ref bean="emailHelper"/></property>
</bean>
<bean id="emailHelper" scope="prototype" class="com.Yasna.iclassified.email.EmailHelper">
<property name="mailSender"><ref bean="mailSender"/></property>
<property name="securityHelper"><ref bean="securityHelper"/></property>
<property name="configurationItemDAO"><ref bean="configurationItemDAO"/></property>
</bean>
<!-- Lucene Indexing -->
<bean id="fsDirectory" class="org.springmodules.lucene.index.support.FSDirectoryFactoryBean">
<property name="location" value="lucene"/>
<property name="create">
<value>true</value>
</property>
</bean>
<bean id="indexFactory" class="org.springmodules.lucene.index.support.SimpleIndexFactoryBean">
<property name="directory" ref="fsDirectory"/>
<property name="create">
<value>true</value>
</property>
<property name="analyzer">
<bean class="org.apache.lucene.analysis.SimpleAnalyzer">
</bean>
</property>
</bean>
<bean id="luceneIndexer" class="com.Yasna.iclassified.lucene.LuceneIndexer">
<property name="indexFactory"><ref bean="indexFactory"/></property>
<property name="propertyHelperFactory"><ref bean="propertyHelperFactory"/></property>
</bean>
<bean id="searcherFactory"
class="org.springmodules.lucene.search.factory.SimpleSearcherFactory">
<property name="directory" ref="fsDirectory"/>
</bean>
<bean id="luceneSearcher" class="com.Yasna.iclassified.lucene.LuceneSearcher">
<property name="searcherFactory"><ref bean="searcherFactory"/></property>
<property name="analyzer"><bean class="org.apache.lucene.analysis.SimpleAnalyzer" /></property>
<property name="postingDAO"><ref bean="postingDAO"/></property>
<property name="dataElementDAO"><ref bean="dataElementDAO"/></property>
</bean>
<!-- Miscellaneous Beans -->
<bean id="securityHelper" class="com.Yasna.iclassified.security.SecurityHelper" />
<bean id="userHelper" scope="prototype" class="com.Yasna.iclassified.user.UserHelper">
<property name="emailHelper"><ref bean="emailHelper"/></property>
</bean>
</beans>
This is security for the above context file.
securityApplicationContext.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="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.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<http auto-config='true'>
<intercept-url pattern="/category/Category/create*" access="ROLE_ADMIN" />
<intercept-url pattern="/configuration**" access="ROLE_ADMIN" />
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<form-login login-page="/common/login.jsp" />
</http>
<authentication-provider user-service-ref='userDAO'>
<password-encoder hash="sha">
<salt-source user-property="username"/>
</password-encoder>
</authentication-provider>
<global-method-security secured-annotations="enabled" jsr250-annotations="enabled" access-decision-manager-ref="accessDecisionManager"/>
<!-- ACL permission masks used by this application -->
<beans:bean id="org.springframework.security.acls.domain.BasePermission.READ"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.READ"/>
</beans:bean>
<beans:bean id="org.springframework.security.acls.domain.BasePermission.WRITE"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.WRITE"/>
</beans:bean>
<beans:bean id="org.springframework.security.acls.domain.BasePermission.CREATE"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.CREATE"/>
</beans:bean>
<beans:bean id="org.springframework.security.acls.domain.BasePermission.DELETE"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.DELETE"/>
</beans:bean>
<beans:bean id="org.springframework.security.acls.domain.BasePermission.ADMINISTRATION"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<beans:property name="staticField" value="org.springframework.security.acls.domain.BasePermission.ADMINISTRATION"/>
</beans:bean>
<!-- An access decision voter that reads ROLE_* configuration settings -->
<beans:bean id="roleVoter" class="org.springframework.security.vote.RoleVoter"/>
<!-- An access decision voter that reads ACL_POSTING_WRITE configuration settings -->
<beans:bean id="aclPostingWriteVoter" class="com.Yasna.iclassified.security.GenericsAclEntryVoter">
<beans:constructor-arg ref="aclService"/>
<beans:constructor-arg value="ACL_POSTING_WRITE"/>
<beans:constructor-arg>
<beans:list>
<beans:ref local="org.springframework.security.acls.domain.BasePermission.WRITE"/>
</beans:list>
</beans:constructor-arg>
<beans:property name="processDomainObjectClass" value="com.Yasna.iclassified.posting.Posting"/>
</beans:bean>
<!-- An access decision voter that reads ACL_POSTING_DELETE configuration settings -->
<beans:bean id="aclPostingDeleteVoter" class="com.Yasna.iclassified.security.GenericsAclEntryVoter">
<beans:constructor-arg ref="aclService"/>
<beans:constructor-arg value="ACL_POSTING_DELETE"/>
<beans:constructor-arg>
<beans:list>
<beans:ref local="org.springframework.security.acls.domain.BasePermission.DELETE"/>
</beans:list>
</beans:constructor-arg>
<beans:property name="processDomainObjectClass" value="com.Yasna.iclassified.posting.Posting"/>
</beans:bean>
<!-- An access decision voter that determines if there is an existing authentication -->
<beans:bean id="authenticatedVoter" class="org.springframework.security.vote.AuthenticatedVoter"/>
<!-- An access decision voter that reads JSR 250 annotations -->
<beans:bean id="jsr250Voter" class="org.springframework.security.annotation.Jsr250Voter"/>
<beans:bean id="accessDecisionManager"
class="org.springframework.security.vote.AffirmativeBased">
<beans:property name="decisionVoters">
<beans:list>
<beans:ref bean="roleVoter"/>
<beans:ref bean="jsr250Voter"/>
<beans:ref bean="authenticatedVoter"/>
<beans:ref bean="aclPostingWriteVoter"/>
<beans:ref bean="aclPostingDeleteVoter"/>
</beans:list>
</beans:property>
</beans:bean>
<!-- ========= ACCESS CONTROL LIST LOOKUP MANAGER DEFINITIONS ========= -->
<beans:bean id="aclCache" class="org.springframework.security.acls.jdbc.EhCacheBasedAclCache">
<beans:constructor-arg>
<beans:bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<beans:property name="cacheManager">
<beans:bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
</beans:property>
<beans:property name="cacheName" value="aclCache"/>
</beans:bean>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">
<beans:constructor-arg ref="dataSource"/>
<beans:constructor-arg ref="aclCache"/>
<beans:constructor-arg>
<beans:bean class="org.springframework.security.acls.domain.AclAuthorizationStrategyImpl">
<beans:constructor-arg>
<beans:list>
<beans:bean class="org.springframework.security.GrantedAuthorityImpl">
<beans:constructor-arg value="ROLE_ADMINISTRATOR"/>
</beans:bean>
<beans:bean class="org.springframework.security.GrantedAuthorityImpl">
<beans:constructor-arg value="ROLE_ADMINISTRATOR"/>
</beans:bean>
<beans:bean class="org.springframework.security.GrantedAuthorityImpl">
<beans:constructor-arg value="ROLE_ADMINISTRATOR"/>
</beans:bean>
</beans:list>
</beans:constructor-arg>
</beans:bean>
</beans:constructor-arg>
<beans:constructor-arg>
<beans:bean class="org.springframework.security.acls.domain.ConsoleAuditLogger"/>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="aclService" class="org.springframework.security.acls.jdbc.JdbcMutableAclService">
<beans:constructor-arg ref="dataSource"/>
<beans:constructor-arg ref="lookupStrategy"/>
<beans:constructor-arg ref="aclCache"/>
</beans:bean>
</beans:beans>
This is the web.xml contains the filter mappings...
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="iClassified" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>iClassified</display-name>
<!-- Include this if you are using Hibernate -->
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter- class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<resource-ref>
<description>
iClassified data source.
</description>
<res-ref-name>
jdbc/iclassifieddb
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/*Context.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
This is what i have as code and the above is what i got as error..
Please help and Thanks in advance...

Related

JobRepositoryFactoryBean error spring batch

I started to learn spring batch and I have a problem that when i want to
persist the state of the job in a database using JobRepositoryFactoryBean.
compiler displays :
"Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository' defined in class path resource [springConfig.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/simple/ParameterizedRowMapper"
but not error when i use MapJobRepositoryFactoryBean
I'm using spring 5
springconfig.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:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<context:component-scan base-package="springbatch" />
<context:annotation-config />
<bean id="personneReaderCSV" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="input/personnes.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
<property name="names" value="id,nom,prenom,civilite" />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="targetType" value="springbatch.entities.Personne" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean name="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/spring_test" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>springbatch.entities.Personne</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<job id="importPersonnes" xmlns="http://www.springframework.org/schema/batch">
<step id="readWritePersonne">
<tasklet>
<chunk reader="personneReaderCSV"
processor="personProcessor"
writer="personWriter"
commit-interval="2" />
</tasklet>
</step>
</job>
<bean id="daoPersonne" class="springbatch.dao.PersonneDaoImp">
<property name="factory" ref="sessionFactory"></property>
</bean>
<bean id="personWriter" class="springbatch.batch.PersonneWriter">
<property name="dao" ref="daoPersonne"></property>
</bean>
<bean id="personProcessor" class="springbatch.batch.PersonneProcess">
</bean>
<bean id="batchLauncher" class="springbatch.MyBean">
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="Mysql" />
</bean>
<task:scheduled-tasks>
<task:scheduled ref="batchLauncher" method="message"
cron=" 59 * * * * * " />
</task:scheduled-tasks>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="org/springframework/batch/core/schema-drop-mysql.sql" />
<jdbc:script location="org/springframework/batch/core/schema-mysql.sql" />
</jdbc:initialize-database>
</beans>
but not error when i use :
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
You are using Spring Batch v2.2 with Spring Framework 5. That's not going to work properly as ParameterizedRowMapper has been removed in Spring Framework 4.2+ (hence the exception).
I recommend that you use Spring Batch v4.1 (since v2.x is not maintained anymore) and your issue should be fixed.
The best way to manage Spring dependencies is to let Spring Boot do it for you either by generating a project from start.spring.io or by using the Spring Boot BOM. With both ways, you will have the correct Spring projects dependencies that are known to work well together.

How to create apache camel XA connection using JNDI in Atomikos

Hi i am trying to create a XA transaction for camel and jdbc using atomikos but i have JNDI to set up a XA jdbc transaction i am having issues configuring it.
Below is my code and i am getting cannot write to the class exception
<!-- Atomikos and Spring transaction configuration -->
<!-- JMS config; with XAConnectionFactory -->
<bean id="xa.amqConnectionFactory" class="org.apache.activemq.spring.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
<!-- nothing transactional here, this connection factory will be used from the test harness -->
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
<!-- Atomikos JTA configuration, nothing specific to Spring here -->
<bean id="atomikos.connectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean"
init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="My_MQSeries_XA_RMI"/>
<property name="xaConnectionFactory" ref="xa.amqConnectionFactory"/>
<!-- XAConnectionFactory -->
<property name="maxPoolSize" value="10"/>
<property name="ignoreSessionTransactedFlag" value="false"/>
</bean>
<!-- database config; the XADataSource bean is both a DataSource and an XADataSource-->
<!-- <import resource="xa-embedded-db-context.xml"/> -->
<bean id="db2jndi" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value = "jndi NAMe"/>
</bean>
<!-- <bean id="XADataSource" class="MyDAOclass">
<property name="MyDAOmethod" ref="db2jndi"/>
</bean> -->
<bean id="atomikos.dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean">
<property name="xaDataSource" ref="XADataSource"/>
<!-- XADataSource -->
</bean>
<!-- javax.transaction.TransactionManager -->
<bean id="atomikos.transactionManager"
class="com.atomikos.icatch.jta.UserTransactionManager"
init-method="init"
destroy-method="close"
depends-on="atomikos.connectionFactory,atomikos.dataSource">
<property name="forceShutdown" value="false"/>
</bean>
<!-- javax.transaction.UserTransaction -->
<bean id="atomikos.userTransaction"
class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="300"/>
</bean>
<!-- This is the Spring wrapper over the JTA configuration -->
<!-- org.springframework.transaction.PlatformTransactionManager -->
<bean id="jta.transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikos.transactionManager"/>
<property name="userTransaction" ref="atomikos.userTransaction"/>
</bean>
<!-- Camel components -->
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="atomikos.connectionFactory"/>
<property name="transactionManager" ref="jta.transactionManager"/>
</bean>
<!-- this component is used only from the test harness -->
<bean id="nonTxJms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="connectionFactory"/>
</bean>
<bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="atomikos.dataSource"/>
</bean>
<!-- Policy -->
<bean id="PROPAGATION_REQUIRED" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jta.transactionManager"/>
<!-- Atomikos TX Manager -->
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
</bean>
If anyone has worked on apache camel using XA transactions can you guys provide me your sample config file so that i can use and modify it.
This works for me. It looks like you've missed the ActiveMQResourceManager. Also ensure you use a XAPooledConnectionFactory otherwise your MDBs will disconnect after every bind to check for a message (and CPU on the broker will go through the roof).
<?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-3.2.xsd">
<bean id="env" class="java.lang.String">
<constructor-arg value="test-junit"/>
</bean>
<!-- JMS configuration -->
<bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager"
init-method="recoverResource">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="connectionFactory" ref="pooledJmsXaConnectionFactory" />
<property name="resourceName" value="activemq.default" />
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="userTransaction" ref="userTransaction" />
</bean>
<bean id="pooledJmsXaConnectionFactory" class="org.apache.activemq.pool.XaPooledConnectionFactory"
init-method="start" destroy-method="stop">
<property name="maxConnections" value="8" />
<property name="connectionFactory" ref="jmsXaConnectionFactory" />
<property name="transactionManager" ref="atomikosTransactionManager" />
</bean>
<!-- <bean id="pooledJmsXaConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean"
init-method="init" destroy-method="close"> <property name="poolSize" value="8"
/> <property name="uniqueResourceName" value="activemq" /> <property name="xaConnectionFactory"
ref="jmsXaConnectionFactory" /> </bean> -->
<bean id="jmsXaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="0" />
</bean>
</property>
</bean>
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="pooledJmsXaConnectionFactory" />
<property name="transacted" value="false" />
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- JMS configuration for test enqueue/dequeue without transactions -->
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
<bean id="myEmf"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="persistenceXmlLocation" value="classpath:META-INF/test-persistence.xml"/>
</bean>
<!-- JDBC configuration -->
<bean id="dataSource" class="org.apache.commons.dbcp2.managed.BasicManagedDataSource">
<property name="transactionManager" ref="atomikosTransactionManager" />
<!-- <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedXADataSource40" /> -->
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="url" value="jdbc:derby:target/testdb;create=true" />
<property name="defaultAutoCommit" value="false" />
</bean>
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
init-method="init" destroy-method="close">
<property name="forceShutdown" value="false" />
</bean>
<bean id="userTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="120" />
</bean>
<!-- -->
<bean id="springContext" class="org.example.testutils.SpringContext"/>
</beans>

Spring Entity Manager Factory using JNDI

I am getting confused on how to get the entity Manager Factory in spring spring-datasource.xml using
I did the following :
spring-datasource.xml file:
<tx:jta-transaction-manager id="transactionManager" />
<tx:annotation-driven mode="proxy"
transaction-manager="transactionManager" />
<jee:jndi-lookup id="entityManagerFactory" jndi-name="jdbc/mysqldatasource" />
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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">
<persistence-unit name="ebankingUnit"
transaction-type="JTA">
<jta-data-source>jdbc/mysqldatasource</jta-data-source>
<class>com.datamodel.Product</class>
<properties>
<property name="eclipselink.logging.level" value="INFO" />
<property name="eclipselink.query-results-cache.expiry"
value="5000" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="hibernate.hbm2ddl.auto" value="none" />
</properties>
</persistence-unit>
but I am getting thid
which version of Spring are you using? You don't even need persistence.xml in the latest versions.
Here is the configuration using Spring 3.x, for oracle.
<tx:annotation-driven/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- FactoryBean that creates the EntityManagerFactory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="ORACLE" />
<property name="showSql" value="false" />
</bean>
</property>
<property name="packagesToScan" value="blah.com..domain" />
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/myoracledb}" />
</bean>
Now define myoracledb jndi resource in your web.xml
<Resource name="myoracledb" auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
maxActive="50"
url="your db url"
username="dbuser" password="dbpwd" />
Regards

Spring applicationContext.xml: "The markup in the document following the root element must be well-formed"

I searched through the same questions but unfortunately I couldn't find the solution.
I face with the following exception:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 32 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 32; columnNumber: 2; The markup in the document following the root element must be well-formed.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:530)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:444)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at Main.main(Main.java:18)
Caused by: org.xml.sax.SAXParseException; lineNumber: 32; columnNumber: 2; The markup in the document following the root element must be well-formed.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1388)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDriver.next(XMLDocumentScannerImpl.java:1382)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:237)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 14 more
and this is my applicationContext.xml:
<context:component-scan base-package="com.springHibernate" />
<context:annotation-config />
<bean id="DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/myapp" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
<!-- Beans Declaration -->
<bean id="User" class="com.mycompany.myapp.core.model.User"/>
<bean id="Institute" class="com.mycompany.myapp.core.model.Institute"/>
<!-- User Service Declaration -->
<bean id="UserBoImpl" class="com.mycompany.myapp.core.bo.impl.UserBoImpl">
<property name="userDao" ref="UserDaoImpl" />
</bean>
<bean id="InstituteBoImpl" class="com.mycompany.myapp.core.bo.impl.InstituteBoImpl">
<property name="instituteDao" ref="InstituteDaoImpl" />
</bean>
<!-- User DAO Declaration -->
<bean id="UserDaoImpl" class="com.mycompany.myapp.core.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
<bean id="InstituteDaoImpl" class="com.mycompany.myapp.core.dao.impl.InstituteDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
</beans>
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="DataSource" />
<property name="annotatedClasses">
<list>
<value>com.mycompany.myapp.core.model.User</value>
<value>com.mycompany.myapp.core.model.Institute</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
I don't know what the reason of exception is ...
I appreciate your comments.
The <beans> tag is closed and then more bean definitions are added. Move the closing beans tag so it nests the bean definitions. Another related thing that can burn you with XML config files is using the format tool within your IDE. Never format the XML config with a tool, it can add additional whitespace to your xml which gets interpreted breaking your configuration.
In a nutshell your doing this:
<beans>
<bean id="1"/>
</beans>
<bean id="2"/>
<bean id="3"/>
When it should be like:
<beans>
<bean id="1"/>
<bean id="2"/>
<bean id="3"/>
</beans>
Full Configuration With Changes
<?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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.springHibernate" />
<context:annotation-config />
<bean id="DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/mydb" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
<!-- Beans Declaration -->
<bean id="User" class="com.mycompany.myapp.core.model.User"/>
<bean id="Institute" class="com.mycompany.myapp.core.model.Institute"/>
<!-- User Service Declaration -->
<bean id="UserBoImpl" class="com.mycompany.myapp.core.bo.impl.UserBoImpl">
<property name="userDao" ref="UserDaoImpl" />
</bean>
<bean id="InstituteBoImpl" class="com.mycompany.myapp.core.bo.impl.InstituteBoImpl">
<property name="instituteDao" ref="InstituteDaoImpl" />
</bean>
<!-- User DAO Declaration -->
<bean id="UserDaoImpl" class="com.mycompany.myapp.core.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
<bean id="InstituteDaoImpl" class="com.mycompany.myapp.core.dao.impl.InstituteDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="DataSource" />
<property name="annotatedClasses">
<list>
<value>com.mycompany.myapp.core.model.User</value>
<value>com.mycompany.myapp.core.model.Institute</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
</beans>

weblogic security realm with spring security filters

I am using spring security 3.1.1 for authentication.Application is deployed in weblogic server with security realm enabled for accessing datasource. for servlets I can give
<run-as>
<role-name>testrole</role-name>
</run-as>
how do i do the same for spring security filters. I am getting this error while accessing datasource from filters
: User "" does not have permission to perform operation "reserve" on resource "jdbc/DataSource"
securityContext.xml
<context:annotation-config/>
<sec:http use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint" >
<sec:intercept-url pattern="/**" access="permitAll"/>
<sec:custom-filter position="LOGOUT_FILTER" ref="LogoutFilter" />
<sec:custom-filter position="BASIC_AUTH_FILTER" ref="AuthenticationFilter"/>
</sec:http>
<bean id="LogoutFilter" class="com.xxx.LogoutFilter">
<constructor-arg>
<bean class="com.xxx.LogoutSuccessHandler"></bean>
</constructor-arg>
<constructor-arg>
<list>
<bean class="com.xxx.LogoutHandler"></bean>
</list>
</constructor-arg>
</bean>
<bean id="AuthenticationFilter" class="com.xxx.AuthenticationFilter" >
<constructor-arg type="java.lang.String">
<value>/login.do</value>
</constructor-arg>
<property name="authenticationManager" ref="authenticationManager" />
<property name="authenticationSuccessHandler" ref="successHandler" />
<property name="authenticationFailureHandler" ref="failureHandler" />
</bean>
<bean id="loginUrlAuthenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/common/dologin.jsp" />
</bean>
<bean id="successHandler" class="com.xxx.AuthSuccessHandler"/>
<bean id="failureHandler" class="com.xxx.AuthFailureHandler"/>
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider ref="jaasAuthenticationProvider" />
</sec:authentication-manager>
<bean id="jaasAuthenticationProvider"
class="com.xxx.JaasAuthenticationProvider">
<property name="callbackHandlers">
<list>
<bean class="com.xxx.security.callback.SecurityInfoProvider">
</bean>
</list>
</property>
<property name="authorityGranters">
<list>
<bean class="com.xxx.security.action.RoleUserAuthorityGranter" />
</list>
</property>
</bean>
</beans>
May you could consider a solution as the following.
<bean id="securedJndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.provider.url">t3://myServerA:8001,myServerB:8002</prop>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.security.principal">weblogic</prop>
<prop key="java.naming.security.credentials">weblogic</prop>
</props>
</property>
</bean>
<bean id="targetDatasource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref local="securedJndiTemplate"/>
</property>
<property name="jndiName">
<value>myWeblogicJNDI</value>
</property>
</bean>
In your java code try to lookup the targetDatasource.
I hope this solves your issue.

Resources