camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francis Carlo Gavino" <fgav...@sgi.sk.ca>
Subject Re: JBoss/HornetQ JMS JNDI Spring config - getting connectionFactory must be specified error
Date Sun, 20 Aug 2017 16:48:53 GMT
Thanks for the reply Zoran.  I think what's happening is that my Spring
context is not loading in JBoss.  I tried to test it by changing my JMS
component id and uri to something else and Camel wasn't able to
recognize it.  Also, when I pass the connectionFactory as a parameter in
the URI the error changes to "org.apache.camel.NoSuchBeanException: No
bean could be found in the registry for: jmsQueueConnectionFactory of
type: javax.jms.ConnectionFactory at
org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:159)".
So it seems like it's running all on default values, which explains why
it is looking for the connectionFactory as it didn't find it in my bean
definition.  What's surprising is that it was able to find my
RouteBuilder even if it didn't load the camelContext config from
camel-context.xml... anyways, here's my web.xml: 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	version="3.0">
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/camel-context.xml</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
</web-app>

This is working on Tomcat but not on JBoss.  Is there something I need
to add? 

Thanks.
Francis

end
eom


>>> Zoran Regvart <zoran@regvart.com> 8/19/2017 4:26 PM >>>
Hi Francis,
I see that the example in the Wildfly Camel component[1] uses
`java:jboss/DefaultJMSConnectionFactory` JNDI syntax, did you try with
something like that?

zoran

[1]
https://github.com/wildfly-extras/wildfly-camel-examples/tree/master/camel-jms/src/main/java/org/wildfly/camel/examples/jms


On Sat, Aug 19, 2017 at 12:16 AM, Francis Carlo Gavino
<fgavino@sgi.sk.ca> wrote:
> Hi all,
>
> Camel newbie here.  I'm trying to get a route to send a message to a
> JBoss queue (HornetQ), but I can't get passed this error:
>
> Caused by: java.lang.IllegalArgumentException: connectionFactory
must
> be specified
>         at
> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:308)
>         at
>
org.apache.camel.component.jms.JmsConfiguration.createConnectionFactory(JmsConfiguration.java:1546)
>         at
>
org.apache.camel.component.jms.JmsConfiguration.getConnectionFactory(JmsConfiguration.java:708)
>         at
>
org.apache.camel.component.jms.JmsConfiguration.createTemplateConnectionFactory(JmsConfiguration.java:1563)
>         at
>
org.apache.camel.component.jms.JmsConfiguration.getTemplateConnectionFactory(JmsConfiguration.java:739)
>         at
>
org.apache.camel.component.jms.JmsConfiguration.createInOnlyTemplate(JmsConfiguration.java:609)
>         at
>
org.apache.camel.component.jms.JmsEndpoint.createInOnlyTemplate(JmsEndpoint.java:303)
>         at
>
org.apache.camel.component.jms.JmsProducer.getInOnlyTemplate(JmsProducer.java:470)
>         at
>
org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:390)
>         at
>
org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:368)
>         at
>
org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:154)
>         at
>
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
>         at
>
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
>         at
>
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>         at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
>         at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>         at
>
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>         at
>
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
>         at
>
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>         at
>
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
>         at
>
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
>         at
>
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
>         at
>
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
>         at
>
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
>         at
>
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
>         at
> org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
>         at
>
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
>         at
>
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
>         ... 31 more
>
> Camel version: 2.17.7
> JBoss version: JBoss EAP 6.2 (local - Windows)
>
> I have tried several approaches from examples/tutorials in
specifying
> the connectionFactory:
>         <bean id="jms"
> class="org.apache.camel.component.jms.JmsComponent">
>                 <property name="connectionFactory"
> ref="jmsQueueConnectionFactory" />
>         </bean>
>
> I tried using the following options but to no avail:
>
> 1) Using jee:jndi-lookup:
> <jee:jndi-lookup id="jmsQueueConnectionFactory"
> jndi-name="java:/ConnectionFactory" />
>
> 2) Using Spring JndiTemplate:
>
>         <bean id="jndiTemplate"
> class="org.springframework.jndi.JndiTemplate">
>                 <property name="environment">
>                         <props>
>                                 <prop
>
key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
>                                 <prop
> key="java.naming.provider.url">remote://localhost:4447</prop>
>                                 <prop
> key="java.naming.security.principal">***</prop>
>                                 <prop
> key="java.naming.security.credentials">***</prop>
>                         </props>
>                 </property>
>         </bean>
>         <bean id="jmsQueueConnectionFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>                 <property name="jndiTemplate">
>                         <ref bean="jndiTemplate" />
>                 </property>
>                 <property name="jndiName">
>                         <value>java:/ConnectionFactory</value>
>                 </property>
>         </bean>
>
> 3) Using Spring JndiTemplate and passing credentials:
>         <bean id="authenticatedConnectionFactory"
>                
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
>                 <property name="targetConnectionFactory"
> ref="jmsQueueConnectionFactory" />
>                 <property name="username" value="***" />
>                 <property name="password" value="***" />
>         </bean>
>         <bean id="jms"
> class="org.apache.camel.component.jms.JmsComponent">
>                 <property name="connectionFactory"
> ref="authenticatedConnectionFactory" />
>         </bean>
>
> 4) Using jee-jndi-lookup with environment properties:
>         <bean id="jms"
> class="org.apache.camel.component.jms.JmsComponent">
>                 <property name="configuration" ref="HQConfig" />
>         </bean>
>
>         <bean id="HQConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>                 <property name="connectionFactory" ref="CF-Wrapper"
/>
>                 <property name="transacted" value="false" />
>                 <property name="maxConcurrentConsumers" value="1" />
>                 <property name="cacheLevelName"
value="CACHE_CONNECTION"
> />
>         </bean>
>
>         <bean id="CF-Wrapper"
>                
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
>                 <property name="targetConnectionFactory"
> ref="HornetQ-CF" />
>                 <property name="username" value="***" />
>                 <property name="password" value="***" />
>         </bean>
>
>         <jee:jndi-lookup id="HornetQ-CF"
> jndi-name="jms/ConnectionFactory">
>                 <jee:environment>
>                
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
>                 java.naming.provider.url=remote://localhost:4447
>                 java.naming.security.principal=***
>                 java.naming.security.credentials=***
>                 </jee:environment>
>         </jee:jndi-lookup>
>
> 5) Tried different variations of the jndi name:
> - ConnectionFactory
> - java:jms/RemoteConnectionFactory
> - java:/ConnectionFactory
> - java:jboss/exported/jms/RemoteConnectionFactory
> - jms/ConnectionFactory
> - jms/RemoteConnectionFactory
> - java:/ConnectionFactory
>
> JBoss config looks like this:
>         <subsystem xmlns="urn:jboss:domain:messaging:1.4">
>                 <hornetq-server>
>                        
<persistence-enabled>false</persistence-enabled>
>                         <journal-type>NIO</journal-type>
>                         <journal-min-files>2</journal-min-files>
>                         <connectors>
>                                 <netty-connector name="netty"
> socket-binding="messaging"/>
>                                 <netty-connector
name="netty-throughput"
> socket-binding="messaging-throughput">
>                                         <param key="batch-delay"
> value="50"/>
>                                 </netty-connector>
>                                 <in-vm-connector name="in-vm"
> server-id="0"/>
>                         </connectors>
>                         <acceptors>
>                                 <netty-acceptor name="netty"
> socket-binding="messaging"/>
>                                 <netty-acceptor
name="netty-throughput"
> socket-binding="messaging-throughput">
>                                         <param key="batch-delay"
> value="50"/>
>                                         <param key="direct-deliver"
> value="false"/>
>                                 </netty-acceptor>
>                                 <in-vm-acceptor name="in-vm"
> server-id="0"/>
>                         </acceptors>
>                         <security-settings>
>                                 <security-setting match="#">
>                                         <permission type="send"
> roles="guest"/>
>                                         <permission type="consume"
> roles="guest"/>
>                                         <permission
> type="createNonDurableQueue" roles="guest"/>
>                                         <permission
> type="deleteNonDurableQueue" roles="guest"/>
>                                 </security-setting>
>                         </security-settings>
>                         <address-settings>
>                                 <!--default for catch all-->
>                                 <address-setting match="#">
>                                        
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
>                                        
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
>                                        
<redelivery-delay>0</redelivery-delay>
>                                        
<max-size-bytes>10485760</max-size-bytes>
>                                        
<address-full-policy>PAGE</address-full-policy>
>                                        
<page-size-bytes>2097152</page-size-bytes>
>                                        
<message-counter-history-day-limit>10</message-counter-history-day-limit>
>                                 </address-setting>
>                         </address-settings>
>                         <jms-connection-factories>
>                                 <connection-factory
> name="InVmConnectionFactory">
>                                         <connectors>
>                                                 <connector-ref
> connector-name="in-vm"/>
>                                         </connectors>
>                                         <entries>
>                                                 <entry
> name="java:/ConnectionFactory"/>
>                                         </entries>
>                                 </connection-factory>
>                                 <connection-factory
> name="RemoteConnectionFactory">
>                                         <connectors>
>                                                 <connector-ref
> connector-name="netty"/>
>                                         </connectors>
>                                         <entries>
>                                                 <entry
> name="java:jboss/exported/jms/RemoteConnectionFactory"/>
>                                         </entries>
>                                 </connection-factory>
>                                 <pooled-connection-factory
> name="hornetq-ra">
>                                         <transaction mode="xa"/>
>                                         <connectors>
>                                                 <connector-ref
> connector-name="in-vm"/>
>                                         </connectors>
>                                         <entries>
>                                                 <entry
> name="java:/JmsXA"/>
>                                         </entries>
>                                 </pooled-connection-factory>
>                         </jms-connection-factories>
>                         <jms-destinations>
>                                 <jms-queue name="testQueue">
>                                         <entry
name="queue/testQueue"/>
>                                         <entry
> name="java:jboss/exported/jms/queue/testQueue"/>
>                                 </jms-queue>
>                         </jms-destinations>
>                 </hornetq-server>
>         </subsystem>
>
> And my route looks like this:
>         public void configure() throws Exception {
>                 from("direct:start")
>                         .to(("jms:queue:testQueue"))
>         }
>
> I also created a JBoss application user and added it to a "guest"
> role.
>
> On my test class, I send a message to "direct:start", and then I get
> the exception above (cause).
>
> Any help will be much appreciated... thank you!
>
> -Francis-
>
>
> SGI (Corporate Head Office) ● 2260 11th Avenue ● Regina, SK ●
S4P0J9 ●
> www.sgi.sk.ca ● 1-844-TLK-2SGI (1-844-855-2744)
>
> This e-mail and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
are
> addressed. If you are not the named addressee, please notify the
sender
> immediately by e-mail if you have received this e-mail by mistake
and
> delete this e-mail from your system. If you are not the intended
> recipient you are notified that using, disclosing, copying or
> distributing the contents of this information is strictly
prohibited.
>
> You are receiving this message because you are a customer of SGI. 
If
> you do not wish to receive promotional messages via email, go to
>
https://mysgi.sgi.sk.ca/afOnlineServices/onlineservices/public/customerUnsubscribe.do

> to unsubscribe (but you'll be missing out!)
>
>
>



-- 
Zoran Regvart

SGI (Corporate Head Office) • 2260 11th Avenue • Regina, SK • S4P0J9 •
www.sgi.sk.ca • 1-844-TLK-2SGI (1-844-855-2744)

This e-mail and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you are not the named addressee, please notify the sender
immediately by e-mail if you have received this e-mail by mistake and
delete this e-mail from your system. If you are not the intended
recipient you are notified that using, disclosing, copying or
distributing the contents of this information is strictly prohibited. 

You are receiving this message because you are a customer of SGI.  If
you do not wish to receive promotional messages via email, go to
https://mysgi.sgi.sk.ca/afOnlineServices/onlineservices/public/customerUnsubscribe.do
to unsubscribe (but you'll be missing out!)




Mime
View raw message