5 Replies Latest reply: Sep 5, 2013 9:46 PM by Xianyi.Ye RSS

    Need Help: <JMSAdapter> <BEA-2041101> <无法将 JMS 消息转换为事件。正在放弃消息: java.lang.ClassCastException: weblogic.jms.common.TextMessageImpl

    Xianyi.Ye

      Hi all,

       

      I configured an JMS Adapter to receive Inbound message. And created a custom Converter between JMS Messages and Event Types.

      The Converter code is referred from Oracle doc. (Configuring JMS Adapters)

      However, when I test my app, I got class cast exception, like attached info.

       

      Is there anyone know what's going on?

      I thing i do not understand is why JVM did not allow me to cast the Message object to TextMessage?

       

      I do appreciate any suggestion or help.

       

      <2013-8-22 下午04时25分36秒 CST> <Notice> <LoggingService> <BEA-320400> <The log file D:\Oracle\Middleware\user_projects\domains\ocep_domain\defaultserver\server.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms like Windows.>

      <2013-8-22 下午04时25分36秒 CST> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to D:\Oracle\Middleware\user_projects\domains\ocep_domain\defaultserver\server.log00044. Log messages will continue to be logged in D:\Oracle\Middleware\user_projects\domains\ocep_domain\defaultserver\server.log.>

      <2013-8-22 下午04时25分39秒 CST> <Notice> <evs4j> <BEA-2049007> <集群协议已禁用>

      <2013-8-22 下午04时25分39秒 CST> <Notice> <BDBProvider> <BEA-2052004> <已创建并注册 BDBProvider default-provider>

      <2013-8-22 下午04时25分41秒 CST> <Notice> <Spring> <BEA-2047000> <"com.oracle.cep.cartridge.jdbc" 的应用程序上下文已成功启动>

      <2013-8-22 下午04时25分42秒 CST> <Notice> <Spring> <BEA-2047000> <"com.bea.wlevs.dataservices" 的应用程序上下文已成功启动>

      <2013-8-22 下午04时25分42秒 CST> <Notice> <部署> <BEA-2045000> <已将应用程序绑定 "TradeReport" 成功部署到版本为 1377159286940 的file:/D:/Oracle/Middleware/user_projects/domains/ocep_domain/defaultserver/applications/TradeReport/TradeReport.jar>

      <2013-8-22 下午04时25分43秒 CST> <Notice> <Spring> <BEA-2047000> <"TradeReport" 的应用程序上下文已成功启动>

      <2013-8-22 下午04时25分43秒 CST> <Notice> <服务器> <BEA-2046000> <服务器已启动>

      <2013-8-22 下午04时25分44秒 CST> <Notice> <Spring> <BEA-2047001> <应用程序上下文 "TradeReport" 已成功关闭>

      <2013-8-22 下午04时25分46秒 CST> <Notice> <Spring> <BEA-2047000> <"TradeReport" 的应用程序上下文已成功启动>

      Type is:weblogic.jms.common.TextMessageImpl

      <2013-8-22 下午04时25分46秒 CST> <Warning> <JMSAdapter> <BEA-2041101> <无法将 JMS 消息转换为事件。正在放弃消息: java.lang.ClassCastException: weblogic.jms.common.TextMessageImpl

      java.lang.ClassCastException: weblogic.jms.common.TextMessageImpl

          at com.customer.MessageConverter.convert(MessageConverter.java:23)

          at com.bea.wlevs.adapters.jms.InboundJmsAdapter.onMessage(InboundJmsAdapter.java:300)

          at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:544)

          at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:482)

          at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)

          at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)

          at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)

          at com.bea.core.asyncbeans.internal.DefaultMessageListenerContainer.receiveAndExecute(DefaultMessageListenerContainer.java:59)

          at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:983)

          at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)

          at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)

          at com.bea.core.asyncbeans.internal.WorkManagerTaskExecutor$1.run(WorkManagerTaskExecutor.java:39)

          at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:204)

          at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)

          at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)

          at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

      >

       

      My converter code is:

       

      package com.customer;

       

      import java.util.ArrayList;

      import java.util.List;

       

      import javax.jms.JMSException;

      import javax.jms.Message;

      import javax.jms.TextMessage;

       

      import com.bea.wlevs.adapters.jms.api.InboundMessageConverter;

      import com.bea.wlevs.adapters.jms.api.MessageConverterException;

       

      public class MessageConverter implements InboundMessageConverter{

       

          @Override

          public List convert(Message message) throws MessageConverterException,

                  JMSException {

       

              JMSEvent event = new JMSEvent();

             TextMessage textMessage = (TextMessage) message;

              event.setMessage(textMessage.getText());

             

              List events = new ArrayList(1);

              events.add(event);

              return events;

             

          }

       

       

       

      }

       

      My Component Config file:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"

                    xmlns:jdbc="http://www.oracle.com/ns/ocep/config/jdbc">

         

         

          <jms-adapter>

              <name>jmsInbound</name>

              <jndi-provider-url>t3://localhost:7101</jndi-provider-url>

              <destination-jndi-name>jms/OSS_RequestQueue</destination-jndi-name>

              <user>weblogic</user>

              <password>weblogic1</password>

              <work-manager>JettyWorkManager</work-manager>

              <concurrent-consumers>1</concurrent-consumers>

              <session-transacted>false</session-transacted>

          </jms-adapter>

         

      </wlevs:config>

       

      My Context Config file:

      <?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" xmlns:n1="http://www.bea.com/ns/wlevs/config/application"

          xsi:schemaLocation="

        http://www.bea.com/ns/wlevs/config/application wlevs_application_config.xsd

        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_7.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="JMSEvent">

                  <wlevs:class>com.customer.JMSEvent</wlevs:class>

              </wlevs:event-type>

          </wlevs:event-type-repository>

       

         

          <!-- Event bean that is an event sink -->

          <wlevs:event-bean id="mySink" class="com.customer.MySink"/>

         

          <!-- Inbound JMS adapter with custom converter class; adapter sends events to mySink event bean -->

          <bean id="myConverter" class="com.customer.MessageConverter"/>

         

          <wlevs:adapter id="jmsInbound" provider="jms-inbound">

              <wlevs:instance-property name="converterBean" ref="myConverter" />

              <wlevs:listener ref="mySink" />

          </wlevs:adapter>

         

       

      </beans>