Hi,
I am very new to the world of spring, camel and activemq.
I am trying to write a code using camel that will poll a file directory and
send the contents of the files inside it to a activemq queue. I need it to
be configured using spring. 
The code is given below along with the log. Please help. Thanks in advance.

pom.xml
--------
<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.learn.camel</groupId>
        <artifactId>CamelDemo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <dependencies>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-core</artifactId>
                        <version>2.15.2</version>
                </dependency>

                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-jms</artifactId>
                        <version>3.1.0.RELEASE</version>
                        <scope>compile</scope>
                </dependency>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-jms</artifactId>
                        <version>2.15.2</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-spring</artifactId>
                        <version>2.15.2</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.xbean</groupId>
                        <artifactId>xbean-spring</artifactId>
                        <version>4.3</version>
                </dependency>


                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-aws</artifactId>
                        <version>2.15.2</version>
                </dependency>

                <dependency>
                        <groupId>org.apache.activemq</groupId>
                        <artifactId>activemq-all</artifactId>
                        <version>5.1.0</version>
                        <scope>compile</scope>
                </dependency>

        </dependencies>

</project>



CamelHello.java
----------------
package com.learn.camel.filetoqueue;
import org.apache.camel.CamelContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class CamelHello {
        public static void main(String args[]) throws Exception {
                try {
                        ApplicationContext springcontext = new
FileSystemXmlApplicationContext("src/main/resources/QBeans.xml");
                        CamelContext context = springcontext.getBean("camel",
CamelContext.class);
                        context.start();
                        context.stop();
                } catch ( Exception e ) {
                }
        }
}



QBeans.xml
----------
<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-4.2.xsd
          http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.11.1.xsd
          http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring-2.15.2.xsd";>

        <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring";>
                <route>
                        <from 
uri="file:C:/Users/abcd/Desktop/targetconsumer.delay=1000" />
                        <convertBodyTo type="java.lang.String" />
                        <to uri="activemq:queue:SAMPLEQUEUE" />
                </route>
        </camelContext>
        <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
                <property name="brokerURL" value="tcp://0.0.0.0:61616" />
        </bean>
        <broker:broker useJmx="true" persistent="false"
xmlns:broker="http://activemq.apache.org/schema/core";  > 
                <broker:transportConnectors>
                        <broker:transportConnector uri="tcp://0.0.0.0:61616" />
                </broker:transportConnectors>
        </broker:broker>
</beans>

Aug 09, 2015 2:26:28 AM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing
org.springframework.context.support.FileSystemXmlApplicationContext@31221be2:
startup date [Sun Aug 09 02:26:28 IST 2015]; root of context hierarchy
Aug 09, 2015 2:26:28 AM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from file
[C:\workspace\CamelDemo\src\main\resources\QBeans.xml]
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
Aug 09, 2015 2:26:30 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@76b1e9b8:
defining beans
[template,consumerTemplate,camel:beanPostProcessor,camel,activemq,org.apache.activemq.xbean.XBeanBrokerService#0];
root of factory hierarchy
Aug 09, 2015 2:26:30 AM org.apache.activemq.broker.BrokerService start
INFO: Using Persistence Adapter: MemoryPersistenceAdapter
Aug 09, 2015 2:26:30 AM org.apache.activemq.broker.BrokerService getBroker
INFO: ActiveMQ null JMS Message Broker (localhost) is starting
Aug 09, 2015 2:26:30 AM org.apache.activemq.broker.BrokerService getBroker
INFO: For help or more information please see: http://activemq.apache.org/
Aug 09, 2015 2:26:31 AM org.apache.activemq.broker.jmx.ManagementContext$1
run
INFO: JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
Aug 09, 2015 2:26:31 AM org.apache.activemq.broker.BrokerService start
SEVERE: Failed to start ActiveMQ JMS Message Broker. Reason:
java.io.IOException: Transport Connector could not be registered in JMX:
Failed to bind to server socket: tcp://0.0.0.0:61616 due to:
java.net.BindException: Address already in use: JVM_Bind
java.io.IOException: Transport Connector could not be registered in JMX:
Failed to bind to server socket: tcp://0.0.0.0:61616 due to:
java.net.BindException: Address already in use: JVM_Bind
        at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
        at
org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1395)
        at
org.apache.activemq.broker.BrokerService.startTransportConnector(BrokerService.java:1848)
        at
org.apache.activemq.broker.BrokerService.startAllConnectors(BrokerService.java:1801)
        at 
org.apache.activemq.broker.BrokerService.start(BrokerService.java:455)
        at
org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:50)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at com.learn.camel.filetoqueue.CamelHello.main(CamelHello.java:11)
Caused by: java.io.IOException: Failed to bind to server socket:
tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use:
JVM_Bind
        at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:33)
        at
org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:124)
        at
org.apache.activemq.transport.tcp.TcpTransportFactory.doBind(TcpTransportFactory.java:60)
        at
org.apache.activemq.transport.TransportFactory.bind(TransportFactory.java:123)
        at
org.apache.activemq.broker.TransportConnector.createTransportServer(TransportConnector.java:293)
        at
org.apache.activemq.broker.TransportConnector.getServer(TransportConnector.java:135)
        at
org.apache.activemq.broker.TransportConnector.asManagedConnector(TransportConnector.java:98)
        at
org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1389)
        ... 18 more
Caused by: java.net.BindException: Address already in use: JVM_Bind
        at java.net.DualStackPlainSocketImpl.bind0(Native Method)
        at
java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
        at 
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:382)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at
javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
        at
org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:120)
        ... 24 more

Aug 09, 2015 2:26:31 AM
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
destroySingletons
INFO: Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@76b1e9b8:
defining beans
[template,consumerTemplate,camel:beanPostProcessor,camel,activemq,org.apache.activemq.xbean.XBeanBrokerService#0];
root of factory hierarchy
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in file
[C:\workspace\CamelDemo\src\main\resources\QBeans.xml]: Invocation of init
method failed; nested exception is java.io.IOException: Transport Connector
could not be registered in JMX: Failed to bind to server socket:
tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use:
JVM_Bind
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at com.learn.camel.filetoqueue.CamelHello.main(CamelHello.java:11)
Caused by: java.io.IOException: Transport Connector could not be registered
in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616 due to:
java.net.BindException: Address already in use: JVM_Bind
        at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
        at
org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1395)
        at
org.apache.activemq.broker.BrokerService.startTransportConnector(BrokerService.java:1848)
        at
org.apache.activemq.broker.BrokerService.startAllConnectors(BrokerService.java:1801)
        at 
org.apache.activemq.broker.BrokerService.start(BrokerService.java:455)
        at
org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:50)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
        ... 12 more
Caused by: java.io.IOException: Failed to bind to server socket:
tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use:
JVM_Bind
        at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:33)
        at
org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:124)
        at
org.apache.activemq.transport.tcp.TcpTransportFactory.doBind(TcpTransportFactory.java:60)
        at
org.apache.activemq.transport.TransportFactory.bind(TransportFactory.java:123)
        at
org.apache.activemq.broker.TransportConnector.createTransportServer(TransportConnector.java:293)
        at
org.apache.activemq.broker.TransportConnector.getServer(TransportConnector.java:135)
        at
org.apache.activemq.broker.TransportConnector.asManagedConnector(TransportConnector.java:98)
        at
org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1389)
        ... 18 more
Caused by: java.net.BindException: Address already in use: JVM_Bind
        at java.net.DualStackPlainSocketImpl.bind0(Native Method)
        at
java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
        at 
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:382)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at
javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
        at
org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:120)
        ... 24 more



--
View this message in context: 
http://camel.465427.n5.nabble.com/Error-when-trying-to-send-file-contents-to-ActiveMq-tp5770476.html
Sent from the Camel Development mailing list archive at Nabble.com.

Reply via email to