I am trying to create two Camel servlet based APIs (two OSGi bundles). I am using blueprint XML as in this example.
These are the two blueprint XMLs,
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<reference id="httpService" interface="org.osgi.service.http.HttpService"/>
<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="/digital"/>
<property name="httpService" ref="httpService"/>
<property name="servlet" ref="teamCamelServlet"/>
</bean>
<bean id="teamCamelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
<bean id="teamService" class="com.test.TeamService"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="servlet" bindingMode="json" contextPath="/digital"
port="8181">
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
<rest path="/team" consumes="application/json" produces="application/json">
..content omitted
</rest>
</camelContext>
</blueprint>
other blueprint.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<reference id="httpService" interface="org.osgi.service.http.HttpService"/>
<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="/api"/>
<property name="httpService" ref="httpService"/>
<property name="servlet" ref="camelServlet"/>
</bean>
<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
<bean id="helloService" class="com.test.HelloService"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="servlet" bindingMode="json" contextPath="/api"
port="8181">
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
<!-- defines the rest services using the context-path /user -->
<rest path="/hello" consumes="application/json" produces="application/json">
..content omitted
</rest>
</camelContext>
</blueprint>
But I get this error message:
javax.servlet.ServletException: Duplicate ServletName detected: CamelServlet. Existing: CamelHttpTransportServlet[name=CamelServlet] This: CamelHttpTransportServlet[name=CamelServlet]. Its advised to use unique ServletName per Camel application.
What I am doing wrong here? I'm trying to run these two OSGi bundles in Apache ServiceMix. If one of them deployed, then it is working fine. If both deployed, only first one is working. I am new to Apache Camel and any help would be great. I've tried restarting ServiceMix, but no luck. Also tried out with clear the bundle cache.
When CamelHttpTransportServlet founds two servlets registering with the same name, it throws an exception "Duplicate ServletName detected...".
In the example the property "servletName" for OsgiServletRegisterer is not set up, therefore a registerer class uses the default value, which is "CamelServlet".
Still, there is something more. In the camel rest configuration should be declared additional endpoint property to provide camel an information about the servlet to use (by default it uses "CamelServlet").
So, to start two separate servlets your coufiguration should be like:
Registerer bean configuration:
<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="/digital"/>
<property name="httpService" ref="httpService"/>
<property name="servlet" ref="teamCamelServlet"/>
<property name="servletName" value="teamCamelServlet"/>
</bean>
Camel rest configuration:
<restConfiguration component="servlet" bindingMode="json" contextPath="/digital" port="8181">
<endpointProperty key="servletName" value="teamCamelServlet"/>
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
This solution should work for camel 2.14.1 and above
Version 2.14.0 contains a bug, because of which the solution does not works
https://issues.apache.org/jira/browse/CAMEL-7971
The OsgiServletRegisterer uses "CamelServlet" as as default servlet-name while registering the CamelHttpTransportServlet.
In both the bundles it is trying to register with the default name. That is the reason you are getting said error.
Try setting different servletName in OsgiServletRegisterer bean as follows
<property name="servletName" value="helloCamelServlet"/>
EDIT : try some thing like this
<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="/digital"/>
<property name="httpService" ref="httpService"/>
<property name="servlet" ref="teamCamelServlet"/>
<property name="servletName" value="teamCamelServlet"/>
</bean>
Related
I'm trying to use JPA to save an Entity to a database using Camel.
I have my persistence.xml as this:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="my-pu">
<description>My Persistence Unit</description>
<class>org.bencompany.camel.JabberMessage</class>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<properties>
<property name="openjpa.ConnectionURL" value="mysql://localhost/jabber"/>
<property name="openjpa.ConnectionDriverName" value="org.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
</properties>
</persistence-unit>
</persistence>
and my camel / beans .xml is this:
<?xml version="1.0"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="my-pu" />
</bean>
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="myProcessor" class="org.bencompany.camel.JabberProcessor" />
<camelContext xmlns="http://camel.apache.org/schema/blueprint"
xmlns:order="http://fusesource.com/examples/order/v7" id="cbr-example-context">
<route id="sendMessage">
<from uri="file:work/cbr/input" />
<log message="Sending Message: ${body}" />
<to uri="xmpp://benco#xxx.com/?room=benco#conference.xxx.com&password=xx&nickname=bencamelbot" />
</route>
<route id="recieveMessage">
<from uri="xmpp://benco#xxx.com/?room=benco#conference.xxx.com&password=xx&nickname=bencamelbot" />
<to uri="myProcessor" />
<to uri="jpa://" />
</route>
</camelContext>
</blueprint>
I'm using Blueprint as I'm trying to deploy this onto JBoss Fuse. I've been using the following link as a reference, and I have followed it to the tee: https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/EIP_Component_Reference/files/_IDU_JPA.html
But when I try to deploy my application, I get this error.
org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor <name: entityManagerFactory, getter: class org.apache.camel.component.jpa.JpaComponent.getEntityManagerFactory(), setter: [class org.apache.camel.component.jpa.JpaComponent.setEntityManagerF
actory(interface javax.persistence.EntityManagerFactory)]
Caused by: java.lang.Exception: Unable to convert value org.springframework.orm.jpa.LocalEntityManagerFactoryBean#3ce0f4c8 to type javax.persistence.EntityManagerFactory
The LocalEntityManagerFactoryBean is supposed to create an EntityManagerFactory, and I'm doing exactly what the JBoss / Camel documentation says, but this error is coming up.
Any ideas?
I am not familiar with Apache Camel + Blueprint.
Springs LocalEntityManagerFactoryBean does not implement the javax.persistence.EntityManager by itself, but provides methods to get it.
http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-orm/4.1.1.RELEASE/org/springframework/orm/jpa/LocalEntityManagerFactoryBean.java#LocalEntityManagerFactoryBean
Due to my research i found this stackoverflow question which could be a duplicate: ServiceMix / JPA Integration - LocalContainerEntityManagerFactoryBean to type EntityManagerFactory
It seems there should be mechanism (JPA and JTA Feature) insideyour OSGi container which should do the work for you.
According to the camel JPA documentation:
In Camel 2.3 the JpaComponent will auto lookup the EntityManagerFactory from the Registry which means you do not need to configure this on the JpaComponent
So you don't need the <bean id="jpa"... tag.
Also, you've used <to uri="jpa://" /> as the endpoint. According to the camel JPA documentation, the fully-qualified class name is optional. However I have found that it is a good idea to specify it.
I am trying to configure JMS connection caching and consumer concurrency with Spring to perform some load tests. The application context xml is below.
<?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:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<context:annotation-config />
<bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://172.18.2.100:8080"/>
</bean>
<bean id="clientCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="amqConnectionFactory"/>
<property name="sessionCacheSize" value="20"/>
<property name="cacheProducers" value="true"/>
</bean>
<bean id="clientContainerListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="clientCachingConnectionFactory" />
<property name="destinationName" value="test.load.outside.multispeak.ch.queue" />
</bean>
<jaxws:client
id="load-test-multispeak-ch-client"
xmlns:ns="http://www.multispeak.org/Version_4.1_Release"
serviceClass="org.multispeak.version_4_1_6.CH.CHServerSoap"
serviceName="ns:CH_Server"
endpointName="ns:CH_ServerSoap"
address="jms://"
wsdlLocation="classpath:CH_Server.wsdl">
<jaxws:features>
<bean class="org.apache.cxf.transport.jms.ConnectionFactoryFeature">
<constructor-arg index="0" ref="clientCachingConnectionFactory"/>
</bean>
</jaxws:features>
</jaxws:client>
<bean id="serverCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="amqConnectionFactory"/>
<property name="sessionCacheSize" value="20"/>
<property name="cacheConsumers" value="true"/>
</bean>
<bean id="serverContainerListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="serverCachingConnectionFactory" />
<property name="destinationName" value="test.load.outside.multispeak.ch.queue" />
<property name="cacheLevel" value="3" />
<property name="concurrentConsumers" value="10" />
<property name="maxConcurrentConsumers" value="50" />
</bean>
<jaxws:endpoint
id="load-test-multispeak-ch-server"
xmlns:tns="http://www.multispeak.org/Version_4.1_Release"
implementor="pt.fraunhofer.outside.multispeak.ch.server.CHServerSoapImpl"
serviceName="tns:CH_Server"
endpointName="tns:CH_ServerSoap"
publish="false"
address="jms://"
wsdlLocation="classpath:CH_Server.wsdl">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature"/>
<bean class="org.apache.cxf.transport.jms.ConnectionFactoryFeature">
<constructor-arg index="0" ref="serverCachingConnectionFactory"/>
</bean>
</jaxws:features>
</jaxws:endpoint>
According to CXF documentation, from 3.0, a ConnectionFactoryFeature should be used instead of a JMSConfigFeature, which is deprecated (http://cxf.apache.org/docs/jms-transport.html). I was following the examples provided at http://cxf.apache.org/scalable-cxf-applications-using-jms-transport.html, but the documentation there seems to refer to CXF versions earlier than 3.0, because JMSConfiguration class in 3.0 does not have caching or concurrency capabilites (no setters/getters). So, I was trying to use Spring to achieve the same result, but without success. The very same documentation refers to Spring DefaultMessageListenerContainer as a container for caching and concurrency configuration, but I was not able to find examples of this with CXF integration, only for pure JMS. Also, DefaultMessageListenerContainer has a setter to register a JMS MessageListener. In case of CXF, I found that that listener is created and managed by CXF runtime and is not provided provided by the application.
Any advice?
Thanks!
Currently you can not set concurrent consumers for CXF 3. I did some performance tests with ActiveMQ and found the performance with CXF 3 is equal to CXF 2 or even better.
The reason is that we now use a MessageListener approach instead of the polling that spring did.
See my website for the performance tests.
We need to be able to tune concurrent and maximum consumers so we can handle our message load. The constraint is in speed of message processing by our applications; CXF is not the bottleneck. Are there plans to re-introduce these parameters in CXF? Can we configure CXF to use a configured DefaultMessageListenerContainer?
I'm trying to integrate SWF in Spring mvc application for the first time, but I'm getting this error :
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException
in XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: XX; columnNumber: XX; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'webflow:flow-builder-services'
this is my mvc-dispatcher-servlet.xml file (referenced by contextConfigLocation in web.xml)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
<bean name="/welcome.htm" class="com.test.app.controller.MainController" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- ================================================================== -->
<!-- Spring Web Flow stuff -->
<!-- ================================================================== -->
<bean id="viewFactoryCreator"
class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers" ref="viewResolver" />
</bean>
<webflow:flow-builder-services id="flowBuilderServices"/>
<webflow:flow-registry id="flowRegistry"
flow-builder-services="flowBuilderServices">
<webflow:flow-location path="/WEB-INF/flows/helloworldflow.xml" />
</webflow:flow-registry>
<webflow:flow-executor id="flowExecutor"
flow-registry="flowRegistry">
</webflow:flow-executor>
<!-- Enables FlowHandler URL mapping -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<!-- Maps request paths to flows in the flowRegistry; e.g. a path of /hotels/booking
looks for a flow with id "hotels/booking" -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
<property name="order" value="0" />
</bean>
I'm using spring 3.0.3.RELEASE and spring webflow 2.1.1.RELEASE
Do you have an explanation about this issue ?
Thanks in advance
Change your spring beans schema version. You're using 2.5, but it should be 3.0.
You are right guys !
It was a version mismatch. I also changed my spring webflow schema version to http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd as I'm using SWF 2.1.1.RELEASE
PS: It's also important to verify spring jars downloaded by maven, and compare their versions to the ones declared in schema location. (If spring-webflow 2.1.1 is used, the schema location must declare spring-webflow-config-2.0 not spring-webflow-config-2.3, same thing for the other spring jars/schema declarations)
I want to create my wsdl by spring-ws automatically and I inserted the code below to my app context file, but I got the error;
"Cannot locate BeanDefinitionParser for element [dynamic-wsdl]"
what does that mean and what can I do? tnx
<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:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org /schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="payloadMapping"
class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="defaultEndpoint" ref="inferenceEndPoint" />
<property name="interceptors">
<list>
<ref local="validatingInterceptor" />
<ref local="payLoadInterceptor" />
</list>
</property>
</bean>
<bean id="payLoadInterceptor"
class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
<bean id="validatingInterceptor"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<description>
This interceptor validates the incoming
message contents
according to the 'Request.xsd' XML
Schema file.
</description>
<property name="schema" value="/WEB-INF/schemas/Request.xsd" />
<property name="validateRequest" value="true" />
<property name="validateResponse" value="false" />
</bean>
<bean id="inferenceEndPoint" class="com.mywebsite.ws.web.InferenceEndPoint">
<property name="messageService" ref="messageService" />
</bean>
<bean id="messageService" class="com.mywebsite.ws.service.MessageService">
<property name="inferenceService" ref="inferenceService" />
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/schemas/Request.xsd" />
</bean>
<sws:dynamic-wsdl id="mtwsdl"
portTypeName="mtWS"
locationUri="http://localhost:8080/mws/">
<sws:xsd location="/WEB-INF/schemas/Request.xsd" />
</sws:dynamic-wsdl>
<bean id="inferenceService" class="com.mywebsite.ws.im.InferenceService">
<property name="webServiceConfiguration" ref="playerConfiguration" />
</bean>
<!-- <bean id="inferenceConfig" class="com.mywebsite.ws.im.InferenceService">
<constructor-arg ref="playerConfiguration"/> </bean> -->
<!-- ~~~~~~~ Application beans ~~~~~~~ -->
<bean id="playerConfiguration"
class="com.mywebsite.ws.configuration.WebServiceConfiguration"
init-method="init">
<property name="playerConfigXml" value="/WEB-INF/config/webserviceconfiguration.xml" />
<property name="executingPathResource" value="/WEB-INF" />
<property name="developmentMode" value="true" />
</bean>
Replace the first section of your appcontext where you define namespaces:
<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:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
I highly suggest to use Maven. The error you are getting is due to a missing library. In Maven you should have an entry like the following.
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
I suggest you look at the class path and also server run time path, I think you may have both (spring-ws 1.5.x and spring-ws 2.x) version's of jar files either in the compile/run time path. If that is not the case clean up the both class and run time path and add only spring-ws 2.x jar files.
As for the differences, when spring framework name space handler (WebServicesNamespaceHandler) encounters (dynamic-wsdl tag in spring context file), It will register a (DynamicWsdlBeanDefinitionParser) bean with all the properties specified in the dynamic wsdl tag. It is essentially same as you registering (DefaultWsdl11Definition) bean in spring context.
I am trying to evaluate HornetQ and the possibility of embedding it in a spring application. To start with a simple setup I am just trying to initialize it as follows. I didn't find much documentation about how to do this, apart from the fact that 'you can'.
I am using Spring 3 and HornetQ 2.1.1GA
My Spring configuration looks like this, however if theres a simpler cleaner configuration it would be better. I want the minimalistic approach first and then build on it.:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="mbeanServer" class="java.lang.management.ManagementFactory" factory-method="getPlatformMBeanServer" />
<bean name="fileConfiguration" class="org.hornetq.core.config.impl.FileConfiguration" init-method="start" destroy-method="stop" />
<bean name="hornetQSecurityManagerImpl" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl" />
<!-- The core server -->
<bean name="hornetQServerImpl" class="org.hornetq.core.server.impl.HornetQServerImpl">
<constructor-arg ref="fileConfiguration" />
<constructor-arg ref="mbeanServer" />
<constructor-arg ref="hornetQSecurityManagerImpl" />
</bean>
<!-- The JMS server -->
<bean name="jmsServerManagerImpl" class="org.hornetq.jms.server.impl.JMSServerManagerImpl" init-method="start" destroy-method="stop" >
<constructor-arg ref="hornetQServerImpl" />
</bean>
<bean name="connectionFactory" class="org.hornetq.jms.client.HornetQConnectionFactory" >
<constructor-arg>
<bean class="org.hornetq.api.core.TransportConfiguration">
<constructor-arg value="org.hornetq.integration.transports.netty.NettyConnectorFactory" />
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="port" value="5445"></entry>
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean name="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory"></property>
</bean>
</beans>
With this config I am getting the error:
SEVERE: Unable to deploy node [queue: null] DLQ
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
...
29-Dec-2010 18:16:34 org.hornetq.core.logging.impl.JULLogDelegate error
SEVERE: Unable to deploy node [queue: null] ExpiryQueue
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
...
9-Dec-2010 18:16:34 org.hornetq.core.logging.impl.JULLogDelegate error
SEVERE: Unable to deploy node [queue: null] ExampleQueue
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
Its must be something obvious related to JNDI, but I would appreciate the proper minimalistic configuration to start with and then expand on it afterwards. The HornetQ configuration files are the default ones that come with the distribution (default queues, default users etc.)
You need to define the JMS queues you want to add to the server, and specify an empty list of JNDI bindings for each queue. To do this, add a JMSConfigurationImpl to your JMSServerManagerImpl bean definition. For example, if you need to define a queue called "testqueue":
<bean id="hornetQJmsConfig" class="org.hornetq.jms.server.config.impl.JMSConfigurationImpl">
<constructor-arg index="0">
<list/>
</constructor-arg>
<!-- Queue configurations -->
<constructor-arg index="1">
<list>
<bean class="org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl">
<!-- Name -->
<constructor-arg index="0" value="testqueue"/>
<!-- Selector -->
<constructor-arg index="1"><null/></constructor-arg>
<!-- Durable queue -->
<constructor-arg index="2" value="true"/>
<!-- JNDI bindings, empty list for none -->
<constructor-arg index="3"><list/></constructor-arg>
</bean>
</list>
</constructor-arg>
<!-- Topic configurations -->
<constructor-arg index="2">
<list/>
</constructor-arg>
</bean>
Since the second and third constructor args take a list of queue and topic configurations, you can add as many queues and topics as you like. For more than one or two, it's probably best to create a Spring template object.