[ https://issues.apache.org/activemq/browse/CAMEL-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=51936#action_51936 ]
Claus Ibsen edited comment on CAMEL-1636 at 5/27/09 4:29 AM: ------------------------------------------------------------- As a workaround do not use @EndpointInject and use a simple Spring setter {code:xml} <bean id="producer" class="org.camel.test.conf.SimpleProducer"> <property name="producer" ref="template"/> </bean> <camelContext ...> <template id="template"/> ... </camelContext> {code} And then use: {code} producer.sendBody("activemq:queue: activemq:queue:SendReceiveQueue", "this is my body"); {code} And have a setProducer() method on your Producer bean. was (Author: davsclaus): As a workaround do not use @EndpointInject and use a simple Spring setter {code:xml} <bean id="producer" class="org.camel.test.conf.SimpleProducer"> <property name="producer" ref="template"/> </bean> <camelContext ...> <template id="template"/> ... </camelContext> And then use: {code} producer.sendBody("activemq:queue: activemq:queue:SendReceiveQueue", "this is my body"); {code} And have a setProducer() method on your Producer bean. > camel-geronimo-2.1.4 integration tutorial > ----------------------------------------- > > Key: CAMEL-1636 > URL: https://issues.apache.org/activemq/browse/CAMEL-1636 > Project: Apache Camel > Issue Type: Improvement > Components: bean-integration > Affects Versions: 2.0-M1 > Environment: geronimo-jetty6-javaee5-2.1.4, java 6 > Reporter: alexander j. perez tchernov > Attachments: CAMEL_GeronimoTest-WEB.zip > > Original Estimate: 3 hours > Remaining Estimate: 3 hours > > I think that we need an tutorial / example how to use camel with JMS queue > created in geronimo-jetty-2.1.4 . I have got NPE when try to use camel > producer in simple servlet > I have created > --------- Simple Producer --- > public class SimpleProducer { > @EndpointInject(uri="activemq:queue:SendReceiveQueue") > ProducerTemplate producer; > public void produceMessage() { > producer.sendBody("<message>test</message>"); } > } > --------- WEB-INF/applicationContext.xml--- > <context:component-scan base-package="org.camel.test.conf"/> > <context:annotation-config /> > <bean id="producer" class="org.camel.test.conf.SimpleProducer"/> > <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent"> > <property name="connectionFactory"> > <bean class="org.apache.activemq.ActiveMQConnectionFactory"> > <property name="brokerURL" > value="tcp://localhost:61616"/> > </bean> > </property> > </bean> > -------- UserServlet ------------- > public class UserServlet extends javax.servlet.http.HttpServlet implements > javax.servlet.Servlet{ > @Resource(name="jms/TestConnectionFactory") > private ConnectionFactory connectionFactory; > @Resource(name="jms/TestQueue") > private Queue queue; > protected void doGet (...) { > //use EJB 3.0 injected resources - works fine > producer.send(session.createMessage()); > // NPE > new SimpleProducer().produceMessage(); > } > } > -------- NPE ------------- > Geronimo Application Server started > INFO RMI TCP Connection(7)-169.254.167.193 > org.apache.geronimo.deployment.DeploymentContext - The Strict Manifest > Classpath processing mode is in effect. > This option can be altered by specifying > -DXorg.apache.geronimo.deployment.LenientMFCP=true|false > Specify ="true" for more lenient processing such as ignoring missing jars and > references that are not spec compliant. > ERROR DefaultThreadPool 195 org.mortbay.log - /camel/UserServlet > java.lang.NullPointerException > at > org.camel.test.conf.SimpleProducer.produceMessage(SimpleProducer.java:30) > at webjms.UserServlet.doGet(UserServlet.java:68) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) > at > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) > at > org.apache.geronimo.jetty6.InternalJettyServletHolder.handle(InternalJettyServletHolder.java:65) > at > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) > at > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) > at > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) > at > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726) > at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) > at > org.apache.geronimo.jetty6.handler.TwistyWebAppContext.access$101(TwistyWebAppContext.java:40) > at > org.apache.geronimo.jetty6.handler.TwistyWebAppContext$TwistyHandler.handle(TwistyWebAppContext.java:65) > at > org.apache.geronimo.jetty6.handler.ThreadClassloaderHandler.handle(ThreadClassloaderHandler.java:46) > at > org.apache.geronimo.jetty6.handler.InstanceContextHandler.handle(InstanceContextHandler.java:58) > at > org.apache.geronimo.jetty6.handler.UserTransactionHandler.handle(UserTransactionHandler.java:48) > at > org.apache.geronimo.jetty6.handler.ComponentContextHandler.handle(ComponentContextHandler.java:47) > at > org.apache.geronimo.jetty6.handler.TwistyWebAppContext.handle(TwistyWebAppContext.java:59) > at > org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206) > at > org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) > at > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) > at org.mortbay.jetty.Server.handle(Server.java:324) > at > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) > at > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828) > at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514) > at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) > at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) > at > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) > at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:214) > at > org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:344) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) > at java.lang.Thread.run(Thread.java:619) > ----------- WEB-INF / lib ---------- > activemq-camel-5.2.0 > activemq-web-5.2.0 > apache-camel-2.0-M1 > camel-core-2.0-M1 > camel-jms-2.0-M1 > camel-spring-2.0-M1 > camel-spring-integration-2.0-M1 > ----------- ${geronimo-home} / repository / org /springframework / ---------- > spring > spring-aop > spring-beans > spring-context > spring-core > sprinx-txn > spring-web > ----------- geronimo-web.xml---------- > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <web:web-app > xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" > > xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" > xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" > xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" > xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" > xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" > xmlns:pers="http://java.sun.com/xml/ns/persistence" > xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" > xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" > xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"> > <dep:environment> > <dep:moduleId> > <dep:groupId>org.apache.camel</dep:groupId> > <dep:artifactId>geronimo-test</dep:artifactId> > <dep:version>1.0</dep:version> > <dep:type>car</dep:type> > </dep:moduleId> > <dep:dependencies> > <dep:dependency> > <dep:groupId>org.springframework</dep:groupId> > <dep:artifactId>spring-beans</dep:artifactId> > <dep:version>2.5.6</dep:version> > <dep:type>jar</dep:type> > </dep:dependency> > <dep:dependency> > <dep:groupId>org.springframework</dep:groupId> > <dep:artifactId>spring-context</dep:artifactId> > <dep:version>2.5.6</dep:version> > <dep:type>jar</dep:type> > </dep:dependency> > <dep:dependency> > <dep:groupId>org.springframework</dep:groupId> > <dep:artifactId>spring-core</dep:artifactId> > <dep:version>2.5.6</dep:version> > <dep:type>jar</dep:type> > </dep:dependency> > <dep:dependency> > <dep:groupId>org.springframework</dep:groupId> > <dep:artifactId>spring-web</dep:artifactId> > <dep:version>2.5.6</dep:version> > <dep:type>jar</dep:type> > </dep:dependency> > <dep:dependency> > <dep:groupId>org.springframework</dep:groupId> > <dep:artifactId>spring-aop</dep:artifactId> > <dep:version>2.5.6</dep:version> > <dep:type>jar</dep:type> > </dep:dependency> > <dep:dependency> > <dep:groupId>org.springframework</dep:groupId> > <dep:artifactId>spring-tx</dep:artifactId> > <dep:version>2.5.6</dep:version> > <dep:type>jar</dep:type> > </dep:dependency> > <dep:dependency> > <dep:groupId>org.springframework</dep:groupId> > <dep:artifactId>spring</dep:artifactId> > <dep:version>2.5.6</dep:version> > <dep:type>jar</dep:type> > </dep:dependency> > <dep:dependency> > <dep:groupId>org.apache.geronimo.configs</dep:groupId> > <dep:artifactId>activemq-ra</dep:artifactId> > <dep:version>2.1.4</dep:version> > <dep:type>car</dep:type> > </dep:dependency> > </dep:dependencies> > </dep:environment> > <web:context-root>/camel</web:context-root> > <name:resource-ref> > <name:ref-name>jms/TestConnectionFactory</name:ref-name> > <name:pattern> > <name:groupId>org.apache.geronimo.configs</name:groupId> > <name:artifactId>activemq-ra</name:artifactId> > <name:version>2.1.4</name:version> > <name:name>DefaultActiveMQConnectionFactory</name:name> > </name:pattern> > </name:resource-ref> > <name:resource-env-ref> > <name:ref-name>jms/TestQueue</name:ref-name> > <name:pattern> > <name:groupId>org.apache.geronimo.configs</name:groupId> > <name:artifactId>activemq-ra</name:artifactId> > <name:version>2.1.4</name:version> > <name:name>SendReceiveQueue</name:name> > </name:pattern> > </name:resource-env-ref> > </web:web-app> > I'll try to upload the attachment with overall project but reduced web-inf/lib -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.