Error while setting Up Ehcahe 3 with spring boot 1.5 - caching

I have recently upgraded to spring boot 1.5.7 from 1.4 and found that Ehcache has been upgraded to 3.x from 2.x. The configurations have all changed. Now I am unable to set up the caching config.
I tried following the steps on the official blog at Ehcache but no success.
Here is my ehcache-dev.xml
<config
xmlns='http://www.ehcache.org/v3'
xmlns:jcache='http://www.ehcache.org/v3/jsr107'>
<service>
<jcache:defaults>
<jcache:cache name="categoryCache" template="catalog-cache"/>
<jcache:cache name="cfCategoryCache" template="catalog-cache"/>
<jcache:cache name="ebooks" template="other-cache"/>
<jcache:cache name="userNameToken" template="other-cache"/>
</jcache:defaults>
</service>
<cache-template name="catalog-cache">
<heap unit="entries">200</heap>
<expiry>
<ttl unit="minutes">10</ttl>
</expiry>
</cache-template>
<cache-template name="other-cache">
<!--<listeners>-->
<!--<listener>-->
<!--<class>org.terracotta.ehcache.EventLogger</class>-->
<!--<event-firing-mode>ASYNCHRONOUS</event-firing-mode>-->
<!--<event-ordering-mode>UNORDERED</event-ordering-mode>-->
<!--<events-to-fire-on>CREATED</events-to-fire-on>-->
<!--<events-to-fire-on>UPDATED</events-to-fire-on>-->
<!--<events-to-fire-on>EXPIRED</events-to-fire-on>-->
<!--<events-to-fire-on>REMOVED</events-to-fire-on>-->
<!--<events-to-fire-on>EVICTED</events-to-fire-on>-->
<!--</listener>-->
<!--</listeners>-->
<heap unit="entries">1000</heap>
<expiry>
<ttl unit="minutes">15</ttl>
</expiry>
</cache-template>
</config>
My application-dev.properties file contains the line:
spring.cache.jcache.config=classpath:ehcache-dev.xml
While running on dev profile, It generates the error:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'jCacheCacheManager' threw exception; nested exception is javax.cache.CacheException: org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/**********/target/********/WEB-INF/classes/ehcache-dev.xml
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 135 more
Caused by: javax.cache.CacheException: org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/**********/target/********/WEB-INF/classes/ehcache-dev.xml
at org.ehcache.jsr107.EhcacheCachingProvider$ConfigSupplier.getConfiguration(EhcacheCachingProvider.java:327)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:128)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:79)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.createCacheManager(JCacheCacheConfiguration.java:115)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.jCacheCacheManager(JCacheCacheConfiguration.java:97)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$46f8ca07.CGLIB$jCacheCacheManager$1(<generated>)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$46f8ca07$$FastClassBySpringCGLIB$$fee1b5ae.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$46f8ca07.jCacheCacheManager(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 136 more
Caused by: org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/**********/target/********/WEB-INF/classes/ehcache-dev.xml
at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:167)
at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:131)
at org.ehcache.jsr107.EhcacheCachingProvider$ConfigSupplier.getConfiguration(EhcacheCachingProvider.java:324)
... 150 more
Caused by: org.xml.sax.SAXParseException; systemId: file:/**********/target/********/WEB-INF/classes/ehcache-dev.xml; lineNumber: 20; columnNumber: 17; cvc-complex-type.2.4.a: Invalid content was found starting with element 'expiry'. One of '{"http://www.ehcache.org/v3":heap-store-settings, "http://www.ehcache.org/v3":disk-store-settings, "http://www.ehcache.org/v3":service-configuration}' is expected.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:177)
at org.ehcache.xml.ConfigurationParser.<init>(ConfigurationParser.java:165)
at org.ehcache.xml.XmlConfiguration.parseConfiguration(XmlConfiguration.java:175)
at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:163)
... 152 more
Now, If I am not wrong, it has problem with accepting expiry element inside the cache-template element. But this should not be the case as it is clearly mentioned here that A <cache-template> element may contain all the same child elements as a <cache> element. and cache element does have an expiry element.
I am unable to understand what am I missing here. Any help appreciated. TIA

Apparently, the problem is in the order of elements.
The heap element needs to be after the expiry element.
The below configuration works alright:
<cache-template name="catalog-cache">
<expiry>
<ttl unit="minutes">10</ttl>
</expiry>
<heap unit="entries">200</heap>
</cache-template>
This makes no sense as order should not matter. Have filed a bug-report with EhCache

You can take a look to the XML example for version 3 (jsr107 extension) given in the ehcache documentation, see link. See if your XML format follows the tags given there.

Related

Getting error in xml file can anyone tell me what to do?

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: **Line 10 in XML document from class path resource [Collection.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 72; cvc-complex-type.3.2.2: Attribute 'scpoe' is not allowed to appear in element 'bean'.**
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:400)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:305)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:224)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:195)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:257)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:128)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:637)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:522)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
at com.SpringDI.Util.Test.main(Test.java:15)
Caused by: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 72; cvc-complex-type.3.2.2: Attribute 'scpoe' is not allowed to appear in element 'bean'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:77)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:430)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 14 more
From the error:
Open you xml file at line 10 (column 72).
There is an invalid bean definition there - looks like a simple typo:
Change scpoe with scope
In future its better to paste relevant parts of the code / configurations here.

JndiLookupFailureException when spring.batch.initializer.enabled=false

Please see my other question where I added data source information in JNDI of embedded tomcat.
Now I wish to suppress database metadata initialization sql scripts so I add property , spring.batch.initializer.enabled=false in application.properties, please see this.
When I add this property, I start getting below exception. If I remove this property, all works well.
Not sure what I am missing.
ERROR - 2016-09-05 09:44:46.358; org.springframework.batch.core.step.AbstractStep; Encountered an error executing step step1 in job RCMatcher
org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: Name [java:comp/env/jdbc/RCMatcherDS] is not bound in this Context. Unable to find [java:comp].
at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:142)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
at com.sun.proxy.$Proxy37.getConnection(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy37.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:394)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:474)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:484)
at org.springframework.batch.item.database.JdbcPagingItemReader.doReadPage(JdbcPagingItemReader.java:208)
at org.springframework.batch.item.database.AbstractPagingItemReader.doRead(AbstractPagingItemReader.java:108)
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read(AbstractItemCountingItemStreamItemReader.java:88)
at org.springframework.batch.item.support.SynchronizedItemStreamReader.read(SynchronizedItemStreamReader.java:55)
at org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:91)
at org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:157)
at org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:116)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:110)
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:69)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
at org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate$ExecutingRunnable.run(TaskExecutorRepeatTemplate.java:262)
at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:268)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.naming.NameNotFoundException: Name [java:comp/env/jdbc/RCMatcherDS] is not bound in this Context. Unable to find [java:comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:817)
at org.apache.naming.NamingContext.lookup(NamingContext.java:174)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:135)
... 34 more

Mavenized Mule project but Munit test run is failing

I have an existing Mule project (which has MUnit's also) and now we are trying to mavenize this project. I have used Anypoint studio only to mavenize and project building is success and I am able to get target/test-classes and target/classes folder but when I am trying to run Munit test (tried to run specific test case also) that time it is failing with below error.
[WARNING] Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 49; columnNumber: 73; schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mu
le/ee/tracking/current/mule-tracking-ee.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the do
cument is not <xsd:schema>.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.warning(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.processAttributes(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.mule.munit.runner.spring.config.document.MunitDocumentLoader.loadDocument(MunitDocumentLoader.java:52)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.
java:229)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:186)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:171
)
at org.mule.config.spring.MuleBeanDefinitionDocumentReader.parseBeanDefinitions(MuleBeanDefinitionDocumentReader.java:56)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.jav
a:144)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:
100)
at org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate.handleSpringElements(MuleHierarchicalBeanDefinitionParserDelegate.java:
180)
at org.mule.munit.runner.spring.config.reader.MunitBeanDefinitionParserDelegate.parseCustomElement(MunitBeanDefinitionParserDelegate.java:41)
at org.mule.munit.runner.spring.config.reader.MunitBeanDefinitionParserDelegate.parseCustomElement(MunitBeanDefinitionParserDelegate.java:82)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:180
)
at org.mule.config.spring.MuleBeanDefinitionDocumentReader.parseBeanDefinitions(MuleBeanDefinitionDocumentReader.java:56)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.jav
a:144)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:
100)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.mule.munit.runner.spring.config.MunitApplicationContext.communicateMuleContextToParsers(MunitApplicationContext.java:123)
at org.mule.munit.runner.spring.config.MunitApplicationContext.loadBeanDefinitions(MunitApplicationContext.java:96)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129
)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:108)
at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:104)
at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:172)
at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:95)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:43)
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69)
at org.mule.context.DefaultMuleContextFactory$1.configure(DefaultMuleContextFactory.java:89)
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:222)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81)
at org.mule.munit.runner.MunitMuleContextFactory.createMuleContext(MunitMuleContextFactory.java:85)
at org.mule.munit.runner.MuleContextManager.createMule(MuleContextManager.java:97)
at org.mule.munit.runner.MuleContextManager.startMule(MuleContextManager.java:56)
at org.mule.munit.runner.mule.MunitSuiteRunner.<init>(MunitSuiteRunner.java:42)
at org.mule.MUnitMojo.buildRunnerFor(MUnitMojo.java:311)
at org.mule.MUnitMojo.doExecute(MUnitMojo.java:173)
at org.mule.MUnitMojo.execute(MUnitMojo.java:122)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Munit test run works perfectly when executing in Anypoint studio but fails when executing using maven command.
[ERROR] Failed to execute goal com.mulesoft.munit.tools:munit-maven-plugin:1.1.0:test (test) on project MuleFlowProject: Execution test of goal com.mulesoft.
nit.tools:munit-maven-plugin:1.1.0:test failed: org.mule.api.config.ConfigurationException: Configuration problem: Failed to import bean definitions
rom URL location [classpath:processFile.xml]
[ERROR] Offending resource: URL [file:/C:/Learning/CodeBase/MuleFlowProject/target/test-classes/processFile-test-suite.xml]; nested exception is org.spr
gframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 107 in XML document from class path resource [processFile.xml] is invalid; n
ted exception is org.xml.sax.SAXParseException; lineNumber: 107; columnNumber: 89; cvc-complex-type.2.4.a: Invalid content was found starting with e
ment 'db:select'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":abstract-message-proce
or, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message
rocessor}' is expected. (org.mule.api.lifecycle.InitialisationException)
I googled it and found related issue logged in Mule Jira which is stating that it has been solved in version 3.5
Reference : https://www.mulesoft.org/jira/browse/MULE-7338
I am using Mule server 3.7.3 EE and Maven version is 3.3.9
Any help is most welcome.
I resolved this problem after modifying schemaLocation in mule configuration xml from http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd to http://www.mulesoft.org/schema/mule/db/3.7/mule-db.xsd
Thanks to #anupambhusari for giving me hint that issue with namespace.
Try using this Dependency
<dependency>
<groupId>com.mulesoft.muleesb.modules</groupId>
<artifactId>mule-module-tracking-ee</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>

AutoReconfigurationServletContainerInitializer could not be instantiated

I am deploying a Java EE app to Bluemix, and when first request arrives I got this error:
2015-05-20T23:11:58.51+0200 [App/0] OUT [INFO ] FFDC1015I: An
FFDC Incident has been created: "java.util.ServiceConfigurationError:
javax.servlet.ServletContainerInitializer: Provider
org.cloudfoundry.reconfiguration.spring.AutoReconfigurationServletContainerInitializer
could not be instantiated
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost startWebApp" at
ffdc_15.05.20_21.11.58.0.log
It is a piece of code from Liberty Buildpack I think.
Here it is the content file ffdc_15.05.20_21.11.58.0.log (it seems a ClassNotFoundException but as it is not part of my app I don't know what to do):
Exception = java.util.ServiceConfigurationError Source =
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost probeid = startWebApp
Stack Dump = java.util.ServiceConfigurationError:
javax.servlet.ServletContainerInitializer: Provider
org.cloudfoundry.reconfiguration.spring.AutoReconfigurationServletContainerInitializer
could not be instantiated at java.util.ServiceLoader.fail(Unknown
Source) at java.util.ServiceLoader.access$100(Unknown Source) at
java.util.ServiceLoader$LazyIterator.next(Unknown Source) at
java.util.ServiceLoader$1.next(Unknown Source) at
com.ibm.ws.webcontainer.webapp.WebApp.initializeServletContainerInitializers(WebApp.java:2454)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1038)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6396)
at
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:446)
at
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:248)
at
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:313)
at
com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:251)
at
com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:306)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:449)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:383)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:283)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:254)
at
com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
at
com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:929)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1018)
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.NoClassDefFoundError:
org.springframework.context.ApplicationContextInitializer at
java.lang.ClassLoader.defineClassImpl(Native Method) at
java.lang.ClassLoader.defineClass(Unknown Source) at
com.ibm.ws.classloading.internal.AppClassLoader.definePackageAndClass(AppClassLoader.java:297)
at
com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:241)
at java.lang.ClassLoader.loadClassHelper(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
com.ibm.ws.classloading.internal.AppClassLoader.findOrDelegateLoadClass(AppClassLoader.java:390)
at
com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:362)
at java.lang.ClassLoader.loadClass(Unknown Source) at
org.cloudfoundry.reconfiguration.spring.AutoReconfigurationServletContainerInitializer.(AutoReconfigurationServletContainerInitializer.java:33)
at java.lang.J9VMInternals.newInstanceImpl(Native Method) at
java.lang.Class.newInstance(Unknown Source) ... 23 more Caused by:
java.lang.ClassNotFoundException:
org.springframework.context.ApplicationContextInitializer at
com.ibm.ws.classloading.internal.AppClassLoader.findClassCommonLibraryClassLoaders(AppClassLoader.java:412)
at
com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:246)
at java.lang.ClassLoader.loadClassHelper(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
com.ibm.ws.classloading.internal.AppClassLoader.findOrDelegateLoadClass(AppClassLoader.java:390)
at
com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:362)
at java.lang.ClassLoader.loadClass(Unknown Source) ... 35 more
Thanks!
I suppose your application is using Spring Framework, and this triggers the Spring Auto-Reconfiguration. If you don't need this auto-reconfiguration support, you can disable it by setting the below environment variable for your application and do a restage:
cf set-env <app-name> JBP_CONFIG_SPRINGAUTORECONFIGURATION "enabled: false"
cf restage <app-name>

JMS - Sending object message

I want to send object message in jms and getting run time exception.
Please suggest me possible solutions.
JMS Code:
ObjectMessage objMessage = session.createObjectMessage();
MessageData data = new MessageData();
objMessage.setObject(data);
sender.send(objMessage);
Exception found on console:
log4j:WARN No appenders could be found for logger org.jboss.remoting.transport.socket.MicroSocketClientInvoker).
log4j:WARN Please initialize the log4j system properly.
java.lang.RuntimeException: com.test.SendJMSMessage
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at org.jboss.messaging.util.StreamUtils.writeObject(StreamUtils.java:249)
at org.jboss.jms.message.JBossObjectMessage.doWriteObject(JBossObjectMessage.java:141)
at org.jboss.messaging.core.impl.message.MessageSupport.getPayloadAsByteArray(MessageSupport.java:216)
at org.jboss.jms.message.JBossObjectMessage.setObject(JBossObjectMessage.java:118)
at org.jboss.jms.message.ObjectMessageProxy.setObject(ObjectMessageProxy.java:59)
at com.test.SendJMSMessage.example(SendJMSMessage.java:36)
at com.test.SendJMSMessage.main(SendJMSMessage.java:130)
After creating new MessageData class in place of creating subclass MessageData, when I run the code I got exceptions as below:
18:26:08,297 ERROR [JmsGatewayListener] Problems invoking method <process>
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.soa.esb.listeners.gateway.JmsGatewayListener.doRun(JmsGatewayListener.java:161)
at org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle.run(AbstractThreadedManagedLifecycle.java:115)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: No ClassLoaders found for: com.test.MessageData
at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at org.jboss.messaging.util.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:78)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.jboss.messaging.util.StreamUtils.readObject(StreamUtils.java:154)
at org.jboss.messaging.core.impl.message.MessageSupport.readPayload(MessageSupport.java:405)
at org.jboss.jms.message.JBossObjectMessage.getObject(JBossObjectMessage.java:126)
at org.jboss.jms.message.ObjectMessageProxy.getObject(ObjectMessageProxy.java:68)
at org.jboss.soa.esb.listeners.gateway.PackageJmsMessageContents.setESBMessageBody(PackageJmsMessageContents.java:165)
at org.jboss.soa.esb.listeners.gateway.PackageJmsMessageContents.process(PackageJmsMessageContents.java:89)
... 7 more
Here I am trying to send an object message to esb server code.
Any suggestions on console window as above please?
The exception is at "the other side":
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at org.jboss.messaging.util.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:78)
So you did send the message, but you are unable to deserialize it at the other end. Why? Because the "other side" does not have the class definition of MessageData in its classpath. If it's a different application, you need to extract MessageData to a common jar and have it included in both applications.
Serialization is no magic; both serializing and deserializing party must have access to the same class definition (.class file) and their versions must be the same, or at least compatible.
Your class MessageData needs to implement java.io.Serializable. Could that be the issue? There should be an additional "cause" exception stack trace.

Resources