1 2 Previous Next 20 Replies Latest reply: Jun 1, 2012 3:16 AM by matvei Go to original post RSS
  • 15. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml  = unstable CLASSPATH issue
    Stephen Coy Master

    If you're using Java 7, you may be encountering CAMEL-4955

  • 16. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml  = unstable CLASSPATH issue
    Stephen Coy Master

    Reading between the lines I think you have encountered an incompatibility between Apache Camel and JAXB 2.2 (which is part of the standard JEE6 spec and also incorporated into Java 7).

     

    It looks like the Camel folks are actively working on a fix for their 2.10.0 release.

  • 17. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml  = unstable CLASSPATH issue
    matvei Newbie

    That's interesting. Actually an idea to use Camel was mostly because of simple @Producer.

    I have one session bean,  every method of this bean associated with one JMS queue. In this way I may autoinject this session bean inside other MDBs and SessionBeans and easily send messages, completely abstract (no more JMS "create session" and other standard things), just methods like "sendToDeliveryProcess(DeliveryEntity delivery)"

     

    It would be pity not to use these feature (in the future I would also like to use Camel routes), how do you send your JMS messages inside EJB3 Application?

  • 18. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml  = unstable CLASSPATH issue
    Stephen Coy Master
    @Stateless
    @LocalBean
    public class Messenger {
    
    
        @Inject
        private Logger logger;
        
        @Resource(mappedName = "java:/JmsXA")
        private ConnectionFactory connectionFactory;
    
    
        @Resource(mappedName = "java:/queue/test")
        private Queue testQueue;
      
        public void sendMessage(String message) {
            logger.infof("Queueing message '%s'", message);
            
            try {
                Connection connection = connectionFactory.createConnection();
                try {
                    Session session = connection.createSession(true, 0);
                    MessageProducer producer = session.createProducer(testQueue);
                    Message jmsMessage = session.createObjectMessage(message);
                    producer.send(jmsMessage);
                } finally {
                    connection.close();
                }
            } catch (JMSException e) {
                throw new EJBException("Failed to send JMS message", e);
            }
            
        }
    
    
    }

     

     

     

    It's a lot easier now with @Resource than it used to be when we had to code JNDI lookups as well.

     

    I think the CDI people are looking at better JMS integration for JEE7.

  • 19. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml  = unstable CLASSPATH issue
    matvei Newbie

    Ok, I've removed Camel beans from XML configuration businessBeans.xml file and any references from my MDB. Since that I've stopped and started Jboss 7 even with JDK 1.7.0_04 without NullPointerException. It looks like the problem was localisated, but I have no workaround to fix it, unfortunately. Just have to wait.

     

    Thanks for the code, actually that is exactly what I want to avoid.

    The reasons are: in such a case you have to care about message delivery inside your code. Camel offers redelivery attempts (configurable), for example, in a case of network problem / instability.

     

    It's a little bit easier with camel, I will give an example here:

     

    businessBeans.xml, Camel configuration (JMS + Bean)

     

     

     

       <!-- init Camel Context, insert routes here -->
       <camel:camelContext id="camel" />
       <!-- MQ Series Part -->
       <bean id="mqseries"
        class="org.apache.camel.component.jms.JmsComponent"> 
            <property name="configuration">
                <bean class="org.apache.camel.component.jms.JmsConfiguration"> 
                    <property name="connectionFactory"> 
                        <bean class="com.ibm.mq.jms.MQQueueConnectionFactory"> 
                            <property name="hostName" value="my.company.com"/> 
                            <property name="port" value="1421"/> 
                            <property name="queueManager" value="QM01"/> 
                            <property name="channel" value="SYSTEM.DEF.SVRCONN"/> 
                            <property name="transportType" value="1"/> 
                        </bean> 
                    </property>
                </bean> 
            </property>
        </bean> 
        <!-- MQ Series Part END -->
    
       <!-- Session Bean handler for JMS Queues -->
       <bean id="producers" class="my.company.camel.producer.ProducersHandler"/>
    

     

     

    And now the session bean code:

     

     

    package my.company.camel.producer;
    
    import org.apache.camel.ProducerTemplate;
    import org.apache.camel.EndpointInject;
    
    /**
     * This class should handle automatically injected (via DI using Spring)
     * links to Camel Producers / JMS Queues
     * 
     * @author matvey
     *
     */
    public class ProducersHandler
        implements ProducersInterface
    {
    
    
            /**
             * Q1. Updates
             */
        @EndpointInject(uri="mqseries:JB.Updates")
        ProducerTemplate checkedUpdates;
    
       
          /**
           * Q2: I2Updates 
           */
        @EndpointInject(uri="mqseries:JB.I2Updates")
        ProducerTemplate i2Updates;
        
        /**
         * Q1: CheckedUpdates
         * 
         * @param ms - Object which implements Serializable Interface
         */
        public void sendToCheckedUpdates(Object ms)
        {
            checkedUpdates.sendBody(ms);
        }
    
        /**
         * Q2: I2Updates
         * 
         * @param ms - Object which implements Serializable Interface
         */
        public void sendToI2Updates(Object ms) {
            i2Updates.sendBody(ms);
            
        }
    
    }
    

     

     

    Now all you have to do in your MDB / Session bean - just  inclide this Producers Session Bean:

     

    @Autowired

    private ProducersInterface producers;

     

    That's all. You just call the Method ot this SB to send a message in an appropriate queue.

     

    It would be pity if I can not use this approach.

  • 20. Re: Jboss 7.1.1 + Spring 3 + beanRefContext.xml  = unstable CLASSPATH issue
    matvei Newbie

    Interesting.

    It works now, I've just rolled back JAXB Version inside JBOSS.

     

    If anyone has the same problem, the solution for JBOSS 7.1.1 FInal is:

     

    Go into $JBOSS_HOME/modules/com/sun/xml/bind/main

    delete all files (jaxb-impl-2.2.4.jar, jaxb-xjc-2.2.4.jar etc, 5 files)

     

    The simplest way is to take the same module, version 2.2, from JBOSS 7.0.1, it has jaxb 2.2, just copy all 5 files from

    jboss_7.0.1/modules/com/sun/xml/bind/main/*

    to

    jboss_7.1.1.Final/modules/com/sun/xml/bind/main/

     

    I am using camel 2.9.2 again, no snapshot version (or 2.10) necessary.

     

    I've started and stopped it again at least 10 times, it's working. Now I understand, why I did not get such a trouble with jboss 7.0.1.

     

    it could be also helpful:

    http://java.net/jira/browse/JAXB-860

1 2 Previous Next