wood burning stoves 2.0*
The moose likes Spring and the fly likes The Spring JMS Input and Output Adapters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "The Spring JMS Input and Output Adapters" Watch "The Spring JMS Input and Output Adapters" New topic
Author

The Spring JMS Input and Output Adapters

sokha Ei
Greenhorn

Joined: Apr 04, 2012
Posts: 1
Dear

I am new user of Spring JMS input and output Adapter , i have problem with Engine Configuration on Esper Enterprise Edition using with JMS


As bellowed is Spring Configuration

<!-- Spring Application Context -->
<beans default-destroy-method="destroy">

<!-- JMS ActiveMQ Connection Factory -->
<bean id="jmsActiveMQFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
</property>
</bean>

<!-- ActiveMQ destination to use by default -->
<bean id="defaultDestination"
class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="ESPER.QUEUE"/>
</bean>

<!-- Spring JMS Template for ActiveMQ -->
<bean id="jmsActiveMQTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="jmsActiveMQFactory"/>
</property>
<property name="defaultDestination">
<ref bean="defaultDestination"/>
</property>
</bean>

<!-- Provides listener threads -->
<bean id="listenerContainer"
class="org.springframework.jms.listener.SimpleMessageListenerContainer">
<property name="connectionFactory" ref="jmsActiveMQFactory"/>
<property name="destination" ref="defaultDestination"/>
<property name="messageListener" ref="jmsInputAdapter"/>
</bean>

<!-- Default unmarshaller -->
<bean id="jmsMessageUnmarshaller"
class="com.espertech.esperio.jms.JMSDefaultAnyMessageUnmarshaller"/>

<!-- Input adapter -->
<bean id="jmsInputAdapter" class="com.espertech.esperio.jms.SpringJMSTemplateInputAdapter">
<property name="jmsTemplate">
<ref bean="jmsActiveMQTemplate"/>
</property>
<property name="jmsMessageUnmarshaller">
<ref bean="jmsMessageUnmarshaller"/>
</property>
</bean>

</beans>

As bellowed is the esper configuration

<plugin-loader name="SpringContextLoader" class-name="com.espertech.esperio.SpringContextLoader">
<!-- SpringApplicationContext translates into Spring ClassPathXmlApplicationContext
or FileSystemXmlApplicationContext. Only one app-context of a sort can be used.
When both attributes are used classpath and file, classpath prevails -->
<init-arg name="classpath-app-context" value="jms-spring.xml" />
<init-arg name="file-app-context" value="jms-spring.xml" />

</plugin-loader>


and when i run esper enterprise edition for using JSM . it will show error as bellow :


org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 2 in XML document from class path resource [jms-spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 41; cvc-elt.1: Cannot find the declaration of element 'beans'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.espertech.esperio.SpringContextLoader.createSpringApplicationContext(SpringContextLoader.java:110)
at com.espertech.esperio.SpringContextLoader.init(SpringContextLoader.java:76)
at com.espertech.esper.core.service.EPServiceProviderImpl.loadAdapters(EPServiceProviderImpl.java:693)
at com.espertech.esper.core.service.EPServiceProviderImpl.doInitialize(EPServiceProviderImpl.java:620)
at com.espertech.esper.core.service.EPServiceProviderImpl.<init>(EPServiceProviderImpl.java:86)
at com.espertech.esper.client.EPServiceProviderManager.getProviderInternal(EPServiceProviderManager.java:117)
at com.espertech.esper.client.EPServiceProviderManager.getProvider(EPServiceProviderManager.java:88)
at com.espertech.esper.server.Bootstrap.main(Bootstrap.java:287)
Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 41; cvc-elt.1: Cannot find the declaration of element 'beans'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1897)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:737)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3063)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:881)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:240)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 21 more



Please help an advance to solve this problem ,


thanks an advance

from new user spring for JMS on Esper enterprise Edition

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Where is your header in your xml config file.

Like


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

So that you point to the Spring xml Schema files.

Mark

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The Spring JMS Input and Output Adapters
 
Similar Threads
cvc-complex-type.2.3:Element 'beans' cannot have character [children] type's content type is element
The matching wildcard is strict, but no declaration can be found for element 'context:annotation'
[beans.xml] cannot be opened because it does not exist
Error registering bean And Classnotfound Exception
Configuration problem: