hibernate ehcache timeToLiveSeconds not working - spring

I am using query cache in Spring Data, Hibernate, ehcache environment. The ehcache dependency is compile 'org.hibernate:hibernate-ehcache:3.3.1.GA'
The ehcache dependency tree is
+--- org.hibernate:hibernate-ehcache:3.3.1.GA
| +--- org.hibernate:hibernate-core:3.3.1.GA -> 3.6.6.Final (*)
| +--- net.sf.ehcache:ehcache:1.2.3
| | \--- commons-collections:commons-collections:2.1 -> 3.2.1
| \--- org.slf4j:slf4j-api:1.5.2 -> 1.6.5
I have a resources/ehcache.xml with timeToLiveSeconds configured to 5 minutes.
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<diskStore path="/home/prayag/cache_"/>
<defaultCache
eternal="false"
maxElementsInMemory="1000"
overflowToDisk="true"
diskPersistent="true"
timeToLiveSeconds="300"
diskExpiryThreadIntervalSeconds="300"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
Caching works but after 5 minutes, cache doesn't get auto-flushed and no new changes are shown.
Not even following code to remove cache works.
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
CacheManager cacheManager = CacheManager.getInstance();
String[] names = cacheManager.getCacheNames();
for (String name : names) {
if (name.equals("merchantServices")) {
Cache cache = cacheManager.getCache(name);
cache.removeAll();
}
}
My Caching configuration(jpa-context.xml) with cacheName merchantServices is
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:p="http://www.springframework.org/schema/p"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-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.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd"
default-autowire="byName">
<tx:annotation-driven />
<cache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="merchantServices"/>
</set>
</property>
</bean>
</beans>
Caching files at diskStore are as below,
prayag#prayag:~/cache_$ ls -l
total 4
-rw-rw-r-- 1 prayag prayag 0 Sep 20 13:31 org.hibernate.cache.StandardQueryCache.data
-rw-rw-r-- 1 prayag prayag 0 Sep 20 15:26 org.hibernate.cache.StandardQueryCache.index
-rw-rw-r-- 1 prayag prayag 2268 Sep 20 15:24 org.hibernate.cache.UpdateTimestampsCache.data
-rw-rw-r-- 1 prayag prayag 0 Sep 20 15:26 org.hibernate.cache.UpdateTimestampsCache.index
org.hibernate.cache.UpdateTimestampsCache.data has following content.
prayag#prayag:~/cache_$ vi org.hibernate.cache.UpdateTimestampsCache.data
¬í^#^Esr^#^Vnet.sf.ehcache.Element.e^H<90>Iî-<9d>^B^#^LJ^#^LcreationTimeZ^#^GeternalJ^#^HhitCountJ^#^NlastAccessTimeJ^#^NlastUpdateTimeZ^#^KlifespanSetJ^#^TnextToLastAccessTimeI^#
timeToIdleI^#
timeToLiveJ^#^GversionL^#^Ckeyt^#^RLjava/lang/Object;L^#^Evalueq^#~^#^Axp^#^#^AA:°<84>Ä^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^AA:°<84>Ä^A^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A,^#^#^AA:°<84>Ät^#^GServicesr^#^Njava.lang.Long;<8b>ä<90>Ì<8f>#ß^B^#^AJ^#^Evaluexr^#^Pjava.lang.Number<86>¬<95>^]^K<94>à<8b>^B^#^#xp^#^T^S«^HL0^#^#°^#¬í^#^Esr^#^Vnet.sf.ehcache.Element.e^H<90>Iî-<9d>^B^#^LJ^#^LcreationTimeZ^#^GeternalJ^#^HhitCountJ^#^NlastAccessTimeJ^#^NlastUpdateTimeZ^#^KlifespanSetJ^#^TnextToLastAccessTimeI^#
timeToIdleI^#
timeToLiveJ^#^GversionL^#^Ckeyt^#^RLjava/lang/Object;L^#^Evalueq^#~^#^Axp^#^#^AA:°<84>Ä^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^AA:°<84>Ä^A^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A,^#^#^AA:°<84>Ät^#^Lservice_tagssr^#^Njava.lang.Long;<8b>ä<90>Ì<8f>#ß^B^#^AJ^#^Evaluexr^#^Pjava.lang.Number<86>¬<95>^]^K<94>à<8b>^B^#^#xp^#^T^S«^HL0^#^T^S¥[\°^#¬í^#^Esr^#^Vnet.sf.ehcache.Element.e^H<90>Iî-<9d>^B^#^LJ^#^LcreationTimeZ^#^GeternalJ^#^HhitCountJ^#^NlastAccessTimeJ^#^NlastUpdateTimeZ^#^KlifespanSetJ^#^TnextToLastAccessTimeI^#
timeToIdleI^#
timeToLiveJ^#^GversionL^#^Ckeyt^#^RLjava/lang/Object;L^#^Evalueq^#~^#^Axp^#^#^AA:±%^Q^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^AA:±%^Q^A^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A,^#^#^AA:±%^Qt^#
SessionLogsr^#^Njava.lang.Long;<8b>ä<90>Ì<8f>#ß^B^#^AJ^#^Evaluexr^#^Pjava.lang.Number<86>¬<95>^]^K<94>à<8b>^B^#^#xp^#^T^S«^RQ^#^#^#¬í^#^Esr^#^Vnet.sf.ehcache.Element.e^H<90>Iî-<9d>^B^#^LJ^#^LcreationTimeZ^#^GeternalJ^#^HhitCountJ^#^NlastAccessTimeJ^#^NlastUpdateTimeZ^#^KlifespanSetJ^#^TnextToLastAccessTimeI^#
timeToIdleI^#
timeToLiveJ^#^GversionL^#^Ckeyt^#^RLjava/lang/Object;L^#^Evalueq^#~^#^Axp^#^#^AA:°<84>Ä^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^AA:°<84>Ä^A^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A,^#^#^AA:°<84>Ät^#^SServiceAccessStatussr^#^Njava.lang.Long;<8b>ä<90>Ì<8f>#ß^B^#^AJ^#^Evaluexr^#^Pjava.lang.Number<86>¬<95>^]^K<94>à<8b>^B^#^#xp^#^T^S«^HL0^#¬í^#^Esr^#^Vnet.sf.ehcache.Element.e^H<90>Iî-<9d>^B^#^LJ^#^LcreationTimeZ^#^GeternalJ^#^HhitCountJ^#^NlastAccessTimeJ^#^NlastUpdateTimeZ^#^KlifespanSetJ^#^TnextToLastAccessTimeI^#
timeToIdleI^#
timeToLiveJ^#^GversionL^#^Ckeyt^#^RLjava/lang/Object;L^#^Evalueq^#~^#^Axp^#^#^AA:°<84>Ä^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^AA:°<84>Ä^A^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A,^#^#^AA:°<84>Ät^#^HBankInfosr^#^Njava.lang.Long;<8b>ä<90>Ì<8f>#ß^B^#^AJ^#^Evaluexr^#^Pjava.lang.Number<86>¬<95>^]^K<94>à<8b>^B^#^#xp^#^T^S«^HL0^#¬í^#^Esr^#^Vnet.sf.ehcache.Element.e^H<90>Iî-<9d>^B^#^LJ^#^LcreationTimeZ^#^GeternalJ^#^HhitCountJ^#^NlastAccessTimeJ^#^NlastUpdateTimeZ^#^KlifespanSetJ^#^TnextToLastAccessTimeI^#
timeToIdleI^#
timeToLiveJ^#^GversionL^#^Ckeyt^#^RLjava/lang/Object;L^#^Evalueq^#~^#^Axp^#^#^AA:¼ó1^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^AA:¼ó1^A^#^#^#^#^#^#^#^#^#^#^#^#^#^#^A,^#^#^AA:¼ó1t^#^KUserSessionsr^#^Njava.lang.Long;<8b>ä<90>Ì<8f>#ß^B^#^AJ^#^Evaluexr^#^Pjava.lang.Number<86>¬<95>^]^K<94>à<8b>^B^#^#xp^#^T^S«Ï3^#^#
More of my configuration is here in earlier post Spring Data + Hibernate Query Caching not working
References
refresh/reset EHCache regions

Basically you are facing ehcache autoflush problem which is discussed over here.
Problem with auto flush in ehcache
There is a solution to your problem which has been discussed over here. hope it helps you coz I aint an ehcache pro.. :P
How Configuration Affects Element Flushing and Eviction

Related

Publish JavaScript Client over Apache cxf with Spring configuration

We are publishing a REST-API in our Server-Application. The Rest-API is configured with Spring and uses Apache cxf. The whole configuration is defined in xml and via Annotaions.
Now we have a JavaScript client that uses the rest-api and we want to publish the client (index.html,bundle.js,... ) with the webserver from apache cxf.
Example: localhost:7564/api/v1/webapp
We want to use the embedded web server from Apache cxf to publish the js client. No additinal Tomcat/Apache/... .
There are many exmaples with static-content but none of these are using Spring/ApacheCxf/embeddedWebserver and xml/Annotation-based configuration.
Any ideas?
xml configuration loaded in our Spring applicationcontext.xml:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<!-- Apache CXF initiale Konfiguration -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<jaxrs:server
id="jaxrsEmbeddedServer"
address="http://0.0.0.0:7564/api/v1" >
<jaxrs:serviceBeans>
<bean class="com.isp.lea.service.web.api.v1.RootApi" />
...
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean
id="cors-filter"
class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter" />
...
</jaxrs:providers>
<jaxrs:features>
<ref bean="swagger2Feature" />
...
</jaxrs:features>
</jaxrs:server>
Rest-api example:
#Path( "/" )
#SuppressWarnings( "javadoc" )
public class RootApi extends RestApi
{
#GET
#ApiOperation( value = "Hello World! ",
notes = "Notes...",
tags = { "apm" } )
public String nichts()
{
return "Hello!";
}
}

BeanDefinitionStoreException IOException while accessing the application context file

writing a simple spring program to read the bean from the filepathxmlapplication context, but getting the below exception.
but i am sure in can access the xml bean definition file.
public void testConnection() {
try{
List <LnkConnectionResponse> connResponse = new ArrayList <LnkConnectionResponse> ();
log.info ("before xml resource");
ApplicationContext context = new FileSystemXmlApplicationContext("M:/My Documents/workspace-sts-3.7.0.RELEASE/LDODashBoard/src/main/webapp/WEB-INF/mvc-database.xml");
log.info ("before get bean");
LnkConnectionWrapper linkConnectionArray = (LnkConnectionWrapper)context.getBean("linkConnectionArray");
xml bean file
<?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:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="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/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/lang http://www.springframework.org/schema/lang/spring-lang.xsd">
<util:list id="dbnameList" list-class="java.util.ArrayList">
<value>LDMDB</value>
<value>GCMMDB</value>
<value>CVDBCHECKOUT</value>
<value>CVEMEADBCHECKOUT</value>
<value>LDMDB</value>
<value>OPUSDB</value>
<value>CDRDB</value>
<value>TLMDB</value>
</util:list>
<util:list id="urlList" list-class="java.util.ArrayList">
<value>ldmUnprocessedLink</value>
<value>gcmmLink2</value>
<value>dbCheckout</value>
<value>dbCheckoutEMEA</value>
<value>dbCheckout</value>
<value>dbCheckout</value>
<value>dbCheckout</value>
<value>dbCheckout</value>
</util:list>
<util:list id="QueryList" list-class="java.util.ArrayList">
<value>select count( * ) from futures.EXMAN_STAGING where REGION = 'LONDON' and process_time_stamp is null</value>
<value>select count( * ) from futures.EXMAN_STAGING where REGION = 'LONDON' and process_time_stamp is null</value>
<value>select name from v$database } select market from cv_welcome where rownum < 2</value>
<value>select market from cvision.cv_welcome where rownum < 2</value>
<value>select 'X' from dual</value>
<value>select 'X' from dual } select GET_PREV_BIZ_DATE from dual </value>
<value>select dummy from dual } Select PREV_BUSINESS_DATE From gmirpt.SD_GMI_PROCDATE Where REGION_IND = 'ATL'</value>
<value>select 'X' from dual</value>
</util:list>
<bean id="DBQueryBean" class="com.connection.impl.DBQueryImpl">
<property name="DBName">
<ref bean="dbnameList"/>
</property>
<property name="UrlName">
<ref bean="urlList"/>
</property>
<property name="QueryString">
<ref bean="QueryList"/>
</property>
</bean>
<bean id="LdmDatabaseBean" class="com.connection.impl.LDMConnectionImpl">
<property name="dbQuery" ref="DBQueryBean"/>
</bean>
<bean id="tlmWebConnectlink" class="com.implementation.LnkConnectionCheck">
<property name="urlIDDesc" value="TLMWebConnect" />
<property name="urlIDGroup" value="tlmlink" />
<property name="urlLink" value="https://tlmapp.csintra.net/WebConnect/login/login.jsp" />
<property name="urlDescription" value="TLM Web Connnect" />
</bean>
<bean id="linkConnectionArray" class="com.implementation.LnkConnectionWrapper">
<property name="lnkConnectionCheck">
<list>
<ref bean="tlmWebConnectlink" />
</list>
</property>
</bean>
</beans>
Exception logs
INFO TestLnkConnection - before xml resource INFO
FileSystemXmlApplicationContext - Refreshing
org.springframework.context.support.FileSystemXmlApplicationContext#61d83ac7:
startup date [Thu Dec 17 06:48:07 GMT+08:00 2015]; root of context
hierarchy INFO XmlBeanDefinitionReader - Loading XML bean definitions
from file [M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml]
ERROR TestLnkConnection - Exception Received here!!!
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from file [M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml]; nested exception is java.io.FileNotFoundException: M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml
(The system cannot find the path specified) at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:343)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)
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:129)
at
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
at
org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:84)
at
com.implementation.TestLnkConnection.testConnection(TestLnkConnection.java:47)
at
com.implementation.TestLnkConnection.main(TestLnkConnection.java:73)
Caused by: java.io.FileNotFoundException: M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml
(The system cannot find the path specified) at
java.io.FileInputStream.open(Native Method) at
java.io.FileInputStream.(FileInputStream.java:146) at
org.springframework.core.io.FileSystemResource.getInputStream(FileSystemResource.java:114)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329)
... 14 more
If you look at the log your problem is the FileNotFoundException.
java.io.FileNotFoundException: M:\My Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml (The system cannot find the path specified)
You need to ensure you are properly referencing the file in your web application as well as making sure its is in the correct location.

spring data jpa and commons compatibility

I meet an exception running a project using spring data jpa
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from class path resource [META-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd; lineNumber: 18; columnNumber: 51; src-resolve: Cannot resolve the name 'repository:repositories' to a(n) 'type definition' component.
I read through many docs and blogs and I think this is possibly caused by incompatibility of spring data jpa and spring data commons package versions.
Now I'm using
spring-data-commons-core-1.4.1.Release
spring-data-commons-1.10.0.release
spring-data-jpa-1.8.0.
Any suggestion on the version control to get rid of such error?
Also I would like to ask for suggestions how to make such version control easier(any website, docs or tools). Thanks for advice in advance.
Below is the namespace I use
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:repository="http://www.springframework.org/schema/data/repository"
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/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd">
The repository:repository is not from my applicationContext.xml. I did use jpa:repository as
<jpa:repositories base-package="com.canreef.calendar"/>
I found this roots in spring-repository.xsd
In spring-jpa.xsd there is a line with ref to repository:auditing-attributes:
<xsd:element name="auditing">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.data.jpa.domain.support.AuditingEntityListener" />
<tool:exports type="org.springframework.data.auditing.AuditingHandler" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup ref="repository:auditing-attributes" />
</xsd:complexType>
</xsd:element>
While in spring-repository.xsd there is the bean:
-<xsd:attributeGroup name="auditing-attributes">
-<xsd:attribute name="auditor-aware-ref">
-<xsd:annotation>
-<xsd:documentation>
<![CDATA[ References a bean of type AuditorAware to represent the current principal. ]]>
</xsd:documentation>
-<xsd:appinfo>
-<tool:annotation kind="ref">
<tool:assignable-to type="org.springframework.data.domain.AuditorAware"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
...omitted...
</xsd:attributeGroup>
Therefore this should be caused by not able to fetch the repository.xsd.

Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]

I m using Spring AOP architecture for Logging and Transaction management.we are using WSO2-ESB container for deploying our service.
Here the XML file which we try to read using ClassPathXmlApplicationContext().
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<!-- Complete AOP implementation -->
<aop:aspectj-autoproxy />
<!-- Aspect -->
<bean id="logAspect" class="x.y.z.logging.aspect.LoggingAspect" />
<aop:config>
<aop:aspect id="aspectLoggging" ref="logAspect" >
<!-- #Before -->
<aop:pointcut id="pointCutBefore"
expression="execution(* *(..))" />
<aop:before method="logBefore" pointcut-ref="pointCutBefore" />
<!-- #After -->
<aop:pointcut id="pointCutAfter"
expression="execution(* *(..))" />
<aop:after method="logAfter" pointcut-ref="pointCutAfter" />
<!-- #AfterReturning -->
<aop:pointcut id="pointCutAfterReturning"
expression="execution(* *(..))" />
<aop:after-returning method="logAfterReturning" returning="result"
pointcut-ref="pointCutAfterReturning" />
<!-- #AfterThrowing -->
<aop:pointcut id="pointCutAfterThrowing"
expression="execution(* *(..))" />
<aop:after-throwing method="logAfterThrowing" throwing="error"
pointcut-ref="pointCutAfterThrowing" />
</aop:aspect>
</aop:config>
</beans>
Actual problem occurred when i start my WSO2-ESB server.
Here i have attached Stacktrace :
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]
Offending resource: file [C:\WSO2\Temp\WSO2ES~1.0\.\repository\conf\bundle-config\logger-aspect.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1416)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
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:522)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
at com.mi.logging.core.SpringLoggerUtil.setApplicationContext(SpringLoggerUtil.java:37)
at com.mi.logging.aspect.activator.LogAspectActivator.start(LogAspectActivator.java:16)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 9 more
I m using spring.3.2.5 version and I have reassured that all dependent jar are on classpath.
Please help to resolve this issue. If you have any suggestion or solution then please let me know.
Thnx in advance.
This problem occurred due to it can't find the path/location of spring-aop-3.0.xsd from spring.framework_3.1.0.wso2v1.jar, which is provided by the WSO2-ESB.
It can be resolved by two ways :
1) You can add your latest version of spring and set the priority of that jar files. Reference
2) You have to just simply follow the steps described below.
You have to add some files into META-INF folder of spring.framework_3.1.0.wso2v1.jar file.
Steps are shown below.
i) Create a new file spring.schemas and add the content shown below.
http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd
http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.1.xsd=org/springframework/aop/config/spring-aop-3.1.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.2.xsd=org/springframework/aop/config/spring-aop-3.2.xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.2.xsd
ii) Create a new file spring.handlers and add the content shown below.
http\://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler
iii) Create a new file spring.tooling and add the content shown below.
# Tooling related information for the aop namespace
http\://www.springframework.org/schema/aop#name=aop Namespace
http\://www.springframework.org/schema/aop#prefix=aop
http\://www.springframework.org/schema/aop#icon=org/springframework/aop/config/spring-aop.gif

Spring Integration: Getting XSD Validation Error: cos-all-limited.1.2

I am getting below XSD Valdation error on running Spring Integrtion code:
demo-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cos-all-limited.1.2: An ''all'' model group must appear in a particle with '{'min occurs'}'='{'max occurs'}'=1, and that particle must be part of a pair which constitutes the '{'content type'}' of a complex type definition.
demo-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:int="http://www.springframework.org/schema/integration"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
<import resource="jdbc-context.xml" />
<int:channel id="request" />
<int:channel id="response" />
<int:gateway id="demoService" service-interface="com.integration.DemoService" />
<int-jdbc:outbound-gateway
update="INSERT INTO Demo
SELECT EID, BR from tab1, tab2
WHERE tab1.BR=tab2.BR AND tab1.BR=:payload "
request-channel="requestChannel" reply-channel="responseChannel"
data-source="dataSource" />
<int:logging-channel-adapter id="loggingChannel"
channel="responseChannel" expression="'Inserted successfully'" />
</beans>
It looks as if your schema validator didn't like the schema -- but the schema looks OK to me (and more important, it looks OK Saxon, which is more reliable than I am on some details).
On the other hand, both Xerces and Saxon agree with your unnamed XSD validator that the document you show is invalid; they complain about the expression attribute on the int:logging-channel-adapter element and say that no attribute of that name is allowed.

Resources