java.lang.NoClassDefFoundError: Could not initialize class org.springframework.core.io.support.VfsPatternUtils - spring

As am working on WildFly 8, am getting an error like
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.core.io.support.VfsPatternUtils
Log:
{"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./Sample" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./Sample: Failed to start service
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.core.io.support.VfsPatternUtils
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.core.io.support.VfsPatternUtils
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.core.io.support.VfsPatternUtils"}}
This is applicationContext.xml file Code:
<?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:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:flow="http://www.springframework.org/schema/webflow-config"`
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.0.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.rss.master" use-default-filters="false">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
<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="RSS"/>
<property name="password" value="12345"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>hbm/ExRateMaster.hbm.xml</value>
</list>
</property>
</bean>
<bean id="exRateMasterDao" class="com.rss.master.dao.impl.ExRateMasterDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="exRateMasterBo" class="com.rss.master.bo.impl.ExRateMasterBoImpl">
<property name="exRateMasterDao" ref="exRateMasterDao"/>
</bean>
</beans>

Related

HTTP Status 404 Apache Tomcat 7

I'm learning Spring. I created a spring mvc project. If i write these lines in root-context.xml:
<context:component-scan base-package="com.jaive.test.dao" />
<context:component-scan base-package="com.jaive.test.service" />
<import resource="data.xml" />
then i get HTTP Status 404. If not, everything works fine. I want to know about these lines and why this happenning. I use Apache Tomcat 7.
data.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:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
</props>
</property>
</bean>
did you config the controller,because 404 is always happend to not found the controller, and I noticed that you just not config your controller.

NoSuchMethodException when using Spring ThreadPoolTaskExecutor

I am using ThreadPoolTaskExecutor executor. It is defined in a spring bean. As guided in the documentation, the class has only 1 constructor which gets the TaskExecutor as a parameter.
When I am running the project as a standalone jar using ClassPathXmlApplicationContext, everything works correctly. The TaskExecutor is created and executed.
Now I wanted to connect the Jar project to my web application (war). I added the required dependency in my web application POM file and used some of the jar project code.
There are no compilation errors, and mvn package also passes. But when I start the server, I get the following error (full trace below):
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [me.somesome.task.SyncTaskPool]: No default constructor found; nested exception is java.lang.NoSuchMethodException: me. somesome.task.SyncTaskPool.()
The constructor that I have in the SyncTaskPool class is initiating the TaskExecutor. If I add a constructor with no arguments, the server starts and the empty constructor is executed (and not the parameterized constructor)
I am using Spring 4.0.5.RELEASE
In the jar application context the task executor is defined as:
<bean id="syncTaskPool" class="me.somesome.task.SyncTaskPool">
<constructor-arg ref="myTaskExecutor" />
</bean>
The SyncTaskPool constructor:
package me.somesome.task;
import me.somesome.taskServiceFacade.ServiceFacade;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Component;
#Component
public class SyncTaskPool {
private static Logger logger = LogManager.getLogger(SyncTaskPool .class);
// this field is being set by Spring. It is defined as a bean in the application context
private TaskExecutor adTaskExecutor;
#Autowired
private ServiceFacade serviceFacade;
public SyncTaskPool (TaskExecutor adTaskExecutor) {
this.adTaskExecutor = adTaskExecutor;
}
}
The full error:
2015-01-11T11:52:31,300 [localhost-startStop-1] _[1;31mERROR_[m org.springframework.web.context.ContextLoader.initWebApplicationContext - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adSyncTaskPool' defined in URL [jar:file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ad-mgmt/WEB-INF/lib/component-stats-sync-impl2-0.0.1-SNAPSHOT.jar!/me/somesome/task/SyncTaskPool.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [me.somesome.task.SyncTaskPool]: No default constructor found; nested exception is java.lang.NoSuchMethodException: me.somesome.task.SyncTaskPool.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1076) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1021) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992) [catalina.jar:7.0.55]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490) [catalina.jar:7.0.55]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.55]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) [catalina.jar:7.0.55]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) [catalina.jar:7.0.55]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_20]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_20]
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [me.somesome.task.SyncTaskPool]: No default constructor found; nested exception is java.lang.NoSuchMethodException: me.somesome.task.SyncTaskPool.<init>()
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1069) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
... 22 more
Caused by: java.lang.NoSuchMethodException: me.somesome.task.SyncTaskPool.<init>()
at java.lang.Class.getConstructor0(Class.java:3069) ~[?:1.8.0_20]
at java.lang.Class.getDeclaredConstructor(Class.java:2165) ~[?:1.8.0_20]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1069) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
... 22 more
The jar application context:
<?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:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task" xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd" >
<context:annotation-config />
<context:component-scan base-package="me.somesome" />
<context:component-scan base-package="com.somesome" />
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="myTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="5" />
<property name="maxPoolSize" value="10" />
<property name="queueCapacity" value="25" />
</bean>
<bean id="syncTaskPool" class="me.somesome.task.SyncTaskPool">
<constructor-arg ref="myTaskExecutor" />
</bean>
<task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
<task:executor id="myExecutor" pool-size="5"/>
<task:scheduler id="myScheduler" pool-size="10"/>
<bean id="catalogFacade" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl" value="http://127.0.0.1:6080/ad-mgmt/remoting/catalog" />
<property name="serviceInterface" value="com.somesome.mgmt.facade.ICatalogFacade" />
<property name="overloadEnabled" value="true" />
</bean>
<bean id="trackingAggregationService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl" value="http://127.0.0.1:5080/tracking-manager2/remoting/trkmgr" />
<property name="serviceInterface" value="me.somesome.track.trackingmanager.facade.TrackingManagerFacade" />
<property name="overloadEnabled" value="true" />
</bean>
</beans>
The War application context:
<?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:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring- context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:annotation-config />
<context:component-scan base-package="com.somesome" />
<context:component-scan base-package="me.somesome" />
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
The problem was that the SyncTaskPool bean was defined twice. The first was Component annotation definition:
#Component
SyncTaskPool
The second was an xml definition:
<bean id="syncTaskPool" class="me.somesome.task.SyncTaskPool">
<constructor-arg ref="myTaskExecutor" />
</bean>
I removed the Component annotation and I removed the autowired annotation from the SyncTaskPool definitions.

Spring ACL issue with disk store ehcache

I'm trying to implement Spring ACL, but I encountered an issue to which i have no clue of how to solve.
We have a running configuration of echache which is loaded from the following spring context.
<?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:context="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="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.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- Support annotation configuration -->
<context:annotation-config />
<context:property-placeholder location="META-INF/test.properties" ignore-unresolvable="true" ignore-resource-not-found="true" />
<!-- Database access -->
<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${db.iwh.driver}" />
<property name="url" value="${db.iwh.url}" />
<property name="username" value="${db.iwh.username}" />
<property name="password" value="${db.iwh.password}" />
<property name="initialSize" value="${db.iwh.initialConnections}" />
<property name="maxActive" value="${db.iwh.maxConnections}" />
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="datasource"/>
</bean>
<!-- JPA with Hibernate -->
<util:list id="productEntityPackages"/> <!-- Placeholder -->
<util:list id="projectEntityPackages"/> <!-- Placeholder -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="datasource"/>
<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence"/>
<property name="jpaVendorAdapter">
<bean class="dk.intelligentsystems.platform.util.spring.ISHibernateJpaVendorAdapter">
<property name="databasePlatform" value="${db.iwh.dialect}"/>
<property name="showSql" value="${db.iwh.show_sql}"/>
<property name="hbm2ddl" value=""/>
<!-- <property name="hbm2ddlImportFiles" value="''"/> -->
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.generate_statistics">false</prop>
<prop key="hibernate.cache.default_cache_concurrency_strategy">read-write</prop>
<prop key="net.sf.ehcache.configurationResourceName">/META-INF/ehcache.xml</prop>
<prop key="hibernate.enable_lazy_load_no_trans">true</prop>
<!--prop key="javax.persistence.sharedCache.mode">DISABLE_SELECTIVE</prop-->
</props>
</property>
<!--property name="packagesToScan" ref="entityManagerPackages"/-->
<!-- Managing transactions explicitly -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean id="txInterceptor" class="dk.intelligentsystems.platform.tx.ISTransactionInterceptor" />
<aop:config>
<!-- Add custom transaction interceptor to all #Transactional methods -->
<aop:pointcut id="transactionalMethod" expression="#annotation(org.springframework.transaction.annotation.Transactional) || within(#org.springframework.transaction.annotation.Transactional *)"/>
<aop:advisor pointcut-ref="transactionalMethod" advice-ref="txInterceptor" order="1"/>
</aop:config>
<!-- Task scheduling -->
<task:scheduler id="taskScheduler" pool-size="8"/>
</beans>
The ehcache looks as:
<?xml version="1.0" encoding="UTF-8"?>
<!-- See http://ehcache.org/documentation/user-guide/hibernate -->
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
maxElementsOnDisk="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
diskExpiryThreadIntervalSeconds="120"
statistics="true"
memoryStoreEvictionPolicy="LRU"/>
<cache name="dk.platform.model.Alarm"
maxElementsInMemory="2000"
eternal="false"
timeToIdleSeconds="360"
timeToLiveSeconds="360">
</cache>
...
The ACL is loaded in this application context (Bottom part stolen from spring security contacts sample):
<?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:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<import resource="spring-test-base.xml"/>
<sec:global-method-security pre-post-annotations="enabled" secured-annotations="disabled" jsr250-annotations="disabled" proxy-target-class="true">
<sec:expression-handler ref="expressionHandler" />
</sec:global-method-security>
<bean id="expressionHandler"
class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
<property name="permissionEvaluator">
<bean id="permissionevaluator" class="dk.company.util.AuthorizationProvider">
</bean>
</property>
</bean>
<!-- ========= ACL SERVICE DEFINITIONS ========= -->
<bean id="aclCache" class="org.springframework.security.acls.domain.EhCacheBasedAclCache">
<constructor-arg>
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
</property>
<property name="cacheName" value="aclCache"/>
</bean>
</constructor-arg>
</bean>
<bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">
<constructor-arg ref="datasource"/>
<constructor-arg ref="aclCache"/>
<constructor-arg>
<bean class="org.springframework.security.acls.domain.AclAuthorizationStrategyImpl">
<constructor-arg>
<bean class="org.springframework.security.core.authority.SimpleGrantedAuthority">
<constructor-arg value="ROLE_ADMINISTRATOR"/>
</bean>
</constructor-arg>
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.security.acls.domain.ConsoleAuditLogger"/>
</constructor-arg>
</bean>
<bean id="aclService" class="org.springframework.security.acls.jdbc.JdbcMutableAclService">
<constructor-arg ref="datasource"/>
<constructor-arg ref="lookupStrategy"/>
<constructor-arg ref="aclCache"/>
</bean>
</beans>
When I try to run the application I get the following exception:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:312)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
// Some thousand stack frames...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.ehcache.EhCacheFactoryBean#51e88ff6' defined in class path resource [META-INF/spring-authorization-test.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: aclCache Cache: Could not create disk store. This CacheManager configuration does not allow creation of DiskStores. If you wish to create DiskStores, please configure a diskStore path.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
... 45 more
Caused by: net.sf.ehcache.CacheException: aclCache Cache: Could not create disk store. This CacheManager configuration does not allow creation of DiskStores. If you wish to create DiskStores, please configure a diskStore path.
at net.sf.ehcache.store.compound.factories.DiskOverflowStorageFactory.getDataFile(DiskOverflowStorageFactory.java:79)
at net.sf.ehcache.store.compound.factories.DiskOverflowStorageFactory.<init>(DiskOverflowStorageFactory.java:71)
at net.sf.ehcache.store.compound.impl.OverflowToDiskStore.create(OverflowToDiskStore.java:63)
at net.sf.ehcache.Cache.initialise(Cache.java:1113)
at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:1081)
at net.sf.ehcache.CacheManager.addCache(CacheManager.java:987)
at org.springframework.cache.ehcache.EhCacheFactoryBean.afterPropertiesSet(EhCacheFactoryBean.java:333)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
... 48 more
I tried removing the <diskStore path="java.io.tmpdir"/> line in the ehcache, but to no avail.
EDIT
Spring version: 3.2.4.RELEASE
Ehcache version: 4.1.9.Final
According to EhCache documentation, you can turn off usage of disk for a cache by setting the overflowToDisk attribute to false. So you could try :
<defaultCache
maxElementsInMemory="10000"
overflowToDisk="false"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
diskExpiryThreadIntervalSeconds="120"
statistics="true"
memoryStoreEvictionPolicy="LRU"/>

TransactionManager Spring 4 hibernate 4 NoSuchMethodError

I'm trying to use annotation based transaction management in spring, this is my spring configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
depends-on="propertyPlaceholderConfigurer"
p:driverClassName="org.postgresql.Driver"
p:url="${db.url}"
p:username="${db.username}"
p:password="${db.password}" />
<context:spring-configured />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
depends-on="flywayAutomaticMigrationBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.example" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.default_schema">restProj</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/example/db/hbm/user/User.hbm.xml</value>
<value>com/example/db/hbm/user/Role.hbm.xml</value>
<value>com/example/db/hbm/user/Feature.hbm.xml</value>
</list>
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
When I run my project I get this error:
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Ljava/lang/Object;)V
at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser.parseInternal(AnnotationDrivenBeanDefinitionParser.java:54)
at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:60)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
... 28 more
I read this answer but I don't want to downgrade my spring version.
Thank you for any help.
____UPDATE____
this is my jars list:
antlr-2.7.7.jar
aopalliance-repackaged-2.2.0.jar
asm-all-repackaged-2.2.0.jar
aspectjtools-1.7.4.jar
c3p0-0.9.1.2.jar
cas-client-core-3.2.1.jar
cas-client-integration-tomcat-common-3.2.1.jar
cas-client-integration-tomcat-v6-3.2.1.jar
cas-client-support-distributed-ehcache-3.2.1.jar
cas-client-support-distributed-memcached-3.2.1.jar
cglib-2.1.88.jar
commons-codec-1.6.jar
commons-collections.jar
commons-collections4-4.0.jar
commons-dbcp-1.4.jar
commons-exec-1.1.jar
commons-fileupload.jar
commons-io.jar
commons-lang-2.5.jar
commons-logging-1.1.3.jar
commons-pool-1.5.4.jar
dbunit-2.4.9.jar
dom4j-1.6.jar
ehcache-core-2.2.0.jar
flyway-core-3.0.jar
hamcrest-core-1.3.jar
hibernate-commons-annotations-4.0.4.Final.jar
hibernate-core-4.3.5.Final.jar
hibernate-entitymanager-4.3.5.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
HibernatePagedList-2.0.jar
hk2-api-2.2.0.jar
hk2-locator-2.2.0.jar
hk2-utils-2.2.0.jar
jackson-annotations-2.2.3.jar
jackson-core-2.2.3.jar
jackson-databind-2.2.3.jar
jackson-jaxrs-base-2.2.3.jar
jackson-jaxrs-json-provider-2.2.3.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
javax.annotation-api-1.2.jar
javax.inject-2.2.0.jar
javax.servlet-api-3.0.1.jar
javax.ws.rs-api-2.0.jar
jaxb-api-2.2.7.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
jersey-client.jar
jersey-common.jar
jersey-container-servlet-core.jar
jersey-container-servlet.jar
jersey-guava-2.6.jar
jersey-server.jar
jersey-spring3-2.6.jar
jta-1.0.1B.jar
juli-6.0.29.jar
junit-4.11.jar
log4j-1.2.15.jar
odmg-3.0.jar
org.osgi.core-4.2.0.jar
osgi-resource-locator-1.0.1.jar
PagedListApi-2.0.jar
persistence-api-1.0.jar
postgresql-8.4-703.jdbc4.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
spring-aop-4.0.2.RELEASE.jar
spring-aspects-4.0.2.RELEASE.jar
spring-beans-4.0.2.RELEASE.jar
spring-bridge-2.2.0-b14.jar
spring-context-4.0.2.RELEASE.jar
spring-context-support-4.0.2.RELEASE.jar
spring-core-4.0.2.RELEASE.jar
spring-dao-2.0.8.jar
spring-expression-4.0.2.RELEASE.jar
spring-instrument-4.0.2.RELEASE.jar
spring-instrument-tomcat-4.0.2.RELEASE.jar
spring-jdbc-4.0.2.RELEASE.jar
spring-orm-4.0.2.RELEASE.jar
spring-security-acl-3.2.1.RELEASE.jar
spring-security-cas-3.2.1.RELEASE.jar
spring-security-config-3.2.1.RELEASE.jar
spring-security-core-3.2.1.RELEASE.jar
spring-security-ldap-3.2.1.RELEASE.jar
spring-security-openid-3.2.1.RELEASE.jar
spring-security-taglibs-3.2.1.RELEASE.jar
spring-security-web-3.2.1.RELEASE.jar
spring-tx-4.0.2.RELEASE.jar
spring-web-4.0.2.RELEASE.jar
validation-api-1.1.0.Final.jar
xml-apis-1.4.01.jar
xmlsec-1.3.0.jar
You need to use the same versions of the Spring framework.
You have most of the dependencies at version 4 of Spring but you also have
spring-dao-2.0.8.jar and spring-bridge-2.2.0-b14.jar.
Remove those dependencies and it should work
Check jars in lib if you are running in webserver. check this example it may help you
http://www.codejava.net/frameworks/spring/spring-4-and-hibernate-4-integration-tutorial-part-1-xml-configuration

Exception using spring3

I have developed an application using Spring 3 and Hibernate. For Testing my DAO I use Junit and when I run the test I get an exception.
This is part of my application context.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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/register"/>
<property name="username" value="root"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="annotatedClasses">
<list>
<value>com.model.Register</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
When I run my test I get the following exception:
org.springframework.beans.factory.BeanDefinitionStoreException: Line 10 in XML document from class path resource [application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: L'élément racine de document "beans" doit correspondre à la racine DOCTYPE "null". org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 105; L'élément racine de document "beans" doit correspondre à la racine DOCTYPE "null". at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
xsi:schemalocation for Spring beans is wrong. Change the first line of xsi:schemalocation to
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
You missed the -3.0.xsd
Add </beans> at the end of your context file

Resources