Hi. I'm using geronimo-jetty-2.1.4 running with jdk1.6.  This geronimo
has an activemq (4.1.2) running on 61616. I have created queue
'SendReceiveQueue' using geronimo and it works. Generally, I would
like to add camel as mediation engine which will connect Http, Cometd,
 Restlet , and geronimo JMS,

 I have started to just create simple consumer / producer binded to
the existed JMS queue. Unfortunately, I have got NPE when inject
producer.

It's is interesting that I can inject ConnectionFactory + Queue in
standard Servlet using EJB. So the problem in

public class CustomServlet extends org.restlet.ext.servlet.ServerServlet{
        
         @Resource(name="DefaultActiveMQConnectionFactory")
         private ConnectionFactory connectionFactory;
        
         @Resource(name="SendReceiveQueue")
         private Queue queue;
        
         protected Log log = LogFactory.getLog(this.getClass());
        @Override
        public void init() throws ServletException {
                try {
                        if(queue!=null && connectionFactory!=null)
                        log.info("ok");


 Here is the code
------------------------------------------ SimpleProducer
----------------------------------------
public class SimpleProducer {
        
        @EndpointInject(uri="jms:queue:SendReceiveQueue")
    ProducerTemplate producer;
        
        @EndpointInject(uri="jms:SendReceiveQueue")     
    ProducerTemplate producer2;
        
        @EndpointInject(uri="activemq:SendReceiveQueue")
    ProducerTemplate producer3;
        
        @EndpointInject(uri="activemq:queue:SendReceiveQueue")
    ProducerTemplate producer4;
        
        Log log = LogFactory.getLog(this.getClass());
        
        public  void produceMessage() {
        // Everything is NULL
         if(producer!=null)     
{producer.sendBody("<message>test</message>");log.info("ok1"); };
         if(producer2!=null){ producer2.sendBody("<message>test</message>");
log.info("ok2");};
         if(producer3!=null){ producer3.sendBody("<message>test</message>");
log.info("ok3");};
         if(producer4!=null){ producer4.sendBody("<message>test</message>");
log.info("ok4");};
        }
}

------------------------------------ Routing
----------------------------------------
public class RoutingConfiguration extends RouteBuilder {
        protected static Log log = 
LogFactory.getLog(RoutingConfiguration.class);

            @Override
        public void configure() throws Exception {
                log.info("Listing components..");
                
                for (String e : getContext().getComponentNames())
                        log.info(e);
                
                log.info("Listing endpoints...");
                for (Endpoint e : getContext().getEndpoints())
                        log.info(e);            
        }
}       
------------------------------------------ WEB-INF
/applicationContext.xml ----------------------------
<?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:camel="http://camel.apache.org/schema/spring";
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:broker="http://activemq.apache.org/schema/core";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
       http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd";>

    <!-- Spring IoC scan -->
    <context:component-scan base-package="com.iba.trainunion.trainlist.camel"/>

    <!-- Define camel -->
        <camel:camelContext id="camel">         
              <!-- will auto discover camel router in the specified package -->
              <camel:package>com.iba.trainunion.trainlist.camel</camel:package>
              <camel:jmxAgent id="agent" createConnector="true"/>
        </camel:camelContext>   
                
    <bean id="jms"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="brokerURL" value="tcp://localhost:61616"/>
        </bean>
        
        <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>
</beans>

--------------------------------------- WEB-INF / 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";
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID"
version="2.5">

  <!-- ============ CAMEL ================= -->
   <!--  Start spring autowiring configured in applicationContext.xml  -->
    <listener>
      
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
  <!-- ============ / CAMEL ================= -->

.......


--------------------------------------- WEB-INF / geronimo-web.xml
------------------------------------
I have deployed spring-tx, spring-aop, spring into geronimo, since
there are a lack of them in standard repository.


<?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>com.iba.trainunion</dep:groupId>
            <dep:artifactId>trainlist-web</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.3</dep:version>
                <dep:type>car</dep:type>
            </dep:dependency>
        </dep:dependencies>
        <dep:hidden-classes>
                        <dep:filter>org.springframework.</dep:filter>
                        <dep:filter>META-INF/spring</dep:filter>
        </dep:hidden-classes>
    </dep:environment>
    <web:context-root>/trainunion/realtime</web:context-root>
</web:web-app>

----------------------------------------------------- Log when deploy
-------------------------------------------
Geronimo Application Server started
INFO RMI TCP Connection(39)-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.
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.ContextLoader - Root
WebApplicationContext: initialization started
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.support.XmlWebApplicationContext -
Refreshing 
org.springframework.web.context.support.xmlwebapplicationcont...@143363:
display name [Root WebApplicationContext]; startup date [Tue May 05
20:13:11 EEST 2009]; root of context hierarchy
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.beans.factory.xml.XmlBeanDefinitionReader -
Loading XML bean definitions from ServletContext resource
[/WEB-INF/applicationContext.xml]
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.support.XmlWebApplicationContext -
Bean factory for application context
[org.springframework.web.context.support.xmlwebapplicationcont...@143363]:
org.springframework.beans.factory.support.defaultlistablebeanfact...@bc80fa
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.support.XmlWebApplicationContext -
Bean 'agent' is not eligible for getting processed by all
BeanPostProcessors (for example: not eligible for auto-proxying)
INFO RMI TCP Connection(40)-169.254.167.193
org.apache.camel.impl.DefaultCamelContext - JMX enabled. Using
InstrumentationLifecycleStrategy.
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.support.XmlWebApplicationContext -
Bean 'com.iba.trainunion.trainlist.camel.RoutingConfiguration' is not
eligible for getting processed by all BeanPostProcessors (for example:
not eligible for auto-proxying)
INFO RMI TCP Connection(40)-169.254.167.193
com.iba.trainunion.trainlist.camel.RoutingConfiguration - Listing
components..
INFO RMI TCP Connection(40)-169.254.167.193
com.iba.trainunion.trainlist.camel.RoutingConfiguration - spring-event
INFO RMI TCP Connection(40)-169.254.167.193
com.iba.trainunion.trainlist.camel.RoutingConfiguration - Listing
endpoints...
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.support.XmlWebApplicationContext -
Bean 'camel' is not eligible for getting processed by all
BeanPostProcessors (for example: not eligible for auto-proxying)
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.support.XmlWebApplicationContext -
Bean 'camel' is not eligible for getting processed by all
BeanPostProcessors (for example: not eligible for auto-proxying)
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.beans.factory.support.DefaultListableBeanFactory -
Pre-instantiating singletons in
org.springframework.beans.factory.support.defaultlistablebeanfact...@bc80fa:
defining beans 
[org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,agent,camel:beanPostProcessor,camel,jms,activemq];
root of factory hierarchy
INFO RMI TCP Connection(40)-169.254.167.193
org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.0-M1
(CamelContext:camel) is starting
INFO RMI TCP Connection(40)-169.254.167.193
org.apache.camel.management.DefaultInstrumentationAgent - JMX
Connector thread started and listening at:
service:jmx:rmi:///jndi/rmi://perez_a:1099/jmxrmi/camel
INFO RMI TCP Connection(40)-169.254.167.193
org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.0-M1
(CamelContext:camel) started
INFO RMI TCP Connection(40)-169.254.167.193
org.springframework.web.context.ContextLoader - Root
WebApplicationContext: initialization completed in 2026 ms



Best regards,
     ~ Xasima Xirohata ~

Reply via email to