Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMS Exception-Could not connect to broker url

I have a condition where I need to read data from queue and process it accordingly. Hence I am using apache-camel for that purpose.

Now my Camel configuration are as follows:

applicationContext.xml

<camel:camelContext id="camel-server">
        <camel:package>com.sorc.processor.route</camel:package>
        <camel:jmxAgent id="agent" createConnector="true" />
</camel:camelContext>

FeedProcessorRoute.java

public class FeedProcessorRoute extends RouteBuilder{
    private @Value("${activemq_feed_observer_queue_name}") String activemqQueueName;
    @Override
    public void configure() throws Exception {
        from("amq:" + activemqQueueName + "?exchangePattern=InOut&preserveMessageQos=true")
            .routeId("id1") // Set the routeId to the class name. The routeId is printed when logging.
            .process(this.feedProcessorTrigger)
            .log("The FeedProcessor route has finished\n\n"));  
    }

FeedProcessorTrigger.java

  public class FeedProcessorTrigger implements Processor{
  @Override
  public void process(Exchange exchange) throws Exception {
            //I have added my processing logic here
    }
 }

When i deploy my war in tomcat i get the following error

15:06:24.602 [localhost-startStop-1] DEBUG o.a.c.c.j.DefaultJmsMessageListenerContainer - Could not establish shared JMS Connection - leaving it up to asynchronous invokers to establish a Connection as soon as possible
javax.jms.JMSException: Error while attempting to add new Connection to the pool
        at org.apache.activemq.jms.pool.PooledConnectionFactory.createJmsException(PooledConnectionFactory.java:243) ~[activemq-jms-pool-5.9.1.jar:5.9.1]
        at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:198) ~[activemq-jms-pool-5.9.1.jar:5.9.1]
        at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:177) ~[activemq-jms-pool-5.9.1.jar:5.9.1]
        at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184) ~[spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
        at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:405) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
        at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:373) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:765) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
        at org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:280) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
        at org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:265) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:566) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
        at org.apache.camel.component.jms.JmsConsumer.startListenerContainer(JmsConsumer.java:105) [camel-jms-2.13.1.jar:2.13.1]
        at org.apache.camel.component.jms.JmsConsumer.prepareAndStartListenerContainer(JmsConsumer.java:171) [camel-jms-2.13.1.jar:2.13.1]
        at org.apache.camel.component.jms.JmsConsumer.doStart(JmsConsumer.java:155) [camel-jms-2.13.1.jar:2.13.1]
        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2042) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:2336) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:2272) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2202) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1981) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1851) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1683) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1651) [camel-core-2.13.1.jar:2.13.1]
        at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:254) [camel-spring-2.13.1.jar:2.13.1]
        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120) [camel-spring-2.13.1.jar:2.13.1]
        at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:318) [camel-spring-2.13.1.jar:2.13.1]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151) [spring-context-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128) [spring-context-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331) [spring-context-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773) [spring-context-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483) [spring-context-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) [spring-web-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.2.RELEASE.jar:4.1.2.RELEASE]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) [catalina.jar:7.0.54]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) [catalina.jar:7.0.54]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.54]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.54]
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.54]
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) [catalina.jar:7.0.54]
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083) [catalina.jar:7.0.54]
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880) [catalina.jar:7.0.54]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_05]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [na:1.7.0_05]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166) [na:1.7.0_05]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_05]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_05]
        at java.lang.Thread.run(Thread.java:722) [na:1.7.0_05]
Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.SocketException: Permission denied: connect
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:358) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:303) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:243) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:251) ~[activemq-jms-pool-5.9.1.jar:5.9.1]
        at org.apache.activemq.jms.pool.PooledConnectionFactory$1.makeObject(PooledConnectionFactory.java:98) ~[activemq-jms-pool-5.9.1.jar:5.9.1]
        at org.apache.activemq.jms.pool.PooledConnectionFactory$1.makeObject(PooledConnectionFactory.java:78) ~[activemq-jms-pool-5.9.1.jar:5.9.1]
        at org.apache.commons.pool.impl.GenericKeyedObjectPool.addObject(GenericKeyedObjectPool.java:1748) ~[commons-pool-1.6.jar:1.6]
        at org.apache.activemq.jms.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:196) ~[activemq-jms-pool-5.9.1.jar:5.9.1]
        ... 46 common frames omitted
Caused by: java.net.SocketException: Permission denied: connect
        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.7.0_05]
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:75) ~[na:1.7.0_05]
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) ~[na:1.7.0_05]
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) ~[na:1.7.0_05]
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) ~[na:1.7.0_05]
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) ~[na:1.7.0_05]
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) ~[na:1.7.0_05]
        at java.net.Socket.connect(Socket.java:579) ~[na:1.7.0_05]
        at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:501) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:464) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:138) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58) ~[activemq-client-5.9.1.jar:5.9.1]
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:338) ~[activemq-client-5.9.1.jar:5.9.1]
        ... 53 common frames omitted

My ActiveMq is running and i can access http://localhost:8161/admin/queues.jsp I dont know why I am getting access denied error.

like image 479
Yasmeen Avatar asked Jan 20 '15 10:01

Yasmeen


Video Answer


1 Answers

After wasting full day on this error i was able to resolve it by changing activemq url:

From

activemq_location=tcp://localhost:61616

To

activemq_location=tcp://0.0.0.0:61616
like image 52
Yasmeen Avatar answered Sep 29 '22 21:09

Yasmeen