2 Replies Latest reply: May 2, 2012 3:05 PM by 916271 RSS

    Error: Invalid configuration for the JMS adapter

    916271
      Hi!

      I'm doing a test with CEP to get messages from a JMS WebLogic queue but I'm getting the following error:

      <BEA-2045010> <The application context "Teste" could not be initialized: org.springframework.beans.FatalBeanException: Error in initialization context lifecycle; nested exception is java.lang.IllegalArgumentException: Invalid configuration for the JMS adapter, you must Bean or specify a converter or a type of event.

      Teste.context.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:osgi="http://www.springframework.org/schema/osgi"
      xmlns:wlevs="http://www.bea.com/ns/wlevs/spring"
      xmlns:jdbc="http://www.oracle.com/ns/ocep/jdbc"
      xmlns:spatial="http://www.oracle.com/ns/ocep/spatial"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/osgi
      http://www.springframework.org/schema/osgi/spring-osgi.xsd
      http://www.bea.com/ns/wlevs/spring
      http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd
      http://www.oracle.com/ns/ocep/jdbc
      http://www.oracle.com/ns/ocep/jdbc/ocep-jdbc.xsd
      http://www.oracle.com/ns/ocep/spatial
      http://www.oracle.com/ns/ocep/spatial/ocep-spatial.xsd">

           <wlevs:event-type-repository>
                <wlevs:event-type type-name="Pet">
                     <wlevs:class>testewithprotobuf.MyPet$Pet</wlevs:class>
                </wlevs:event-type>
           </wlevs:event-type-repository>

           <wlevs:adapter id="pet_messageAdapter" provider="jms-inbound">
                <wlevs:listener ref="pet_inputChannel" />
                <wlevs:instance-property name="converterBean"
                     ref="PetMessageConverter" />
           </wlevs:adapter>
           
           <wlevs:channel id="pet_inputChannel" event-type="Pet">
                <wlevs:listener ref="pet_messageProcessor" />
           </wlevs:channel>
           
           <bean id="PetMessageConverter" class="testewithprotobuf.PetMessageConverter" />
           <bean id="PetBean" class="testewithprotobuf.PetBean" />
           
           <wlevs:processor id="pet_messageProcessor">
                <wlevs:listener ref="pet_outputChannel" />          
           </wlevs:processor>

           <wlevs:channel id="pet_outputChannel" event-type="Pet">
                <wlevs:listener ref="PetBean" />
           </wlevs:channel>
      </beans>

      My converter class:

      import java.util.Collections;
      import java.util.List;

      import javax.jms.BytesMessage;
      import javax.jms.JMSException;
      import javax.jms.Message;

      import testewithprotobuf.MyPet.Pet;

      import com.bea.wlevs.adapters.jms.api.InboundMessageConverter;
      import com.bea.wlevs.adapters.jms.api.MessageConverterException;
      import com.google.protobuf.InvalidProtocolBufferException;

      public class PetMessageConverter implements InboundMessageConverter {

           @SuppressWarnings("rawtypes")
           @Override
           public List convert(Message message) throws MessageConverterException,
                                                                  JMSException {

                BytesMessage bytesMessage = (BytesMessage) message;

                long bodyLen = bytesMessage.getBodyLength();
                byte[] buffer = new byte[(int) bodyLen];

                bytesMessage.readBytes(buffer);

                try {
                     Pet pet = Pet.parseFrom(buffer);               

                     return Collections.singletonList(pet);

                } catch (InvalidProtocolBufferException e) {
                     throw new MessageConverterException(e);
                }
           }
      }

      Please, what's wrong?
      Thanks!