Hi,
we are developing out project from 3 different eclipse projects. One is utils project
which expose common.jar file. This file has simple interface that implements Serializable
and class which implement :
public interface PublishCommand extends Serializable {
| // some methods
| }
|
| public class PublishBaseCommand implements PublishCommand {
|
| private String operationType;
|
| public PublishBaseCommand() {
| }
| // some get/set methods
| }
This will be class which will be sanded into queue1.
Also, there is second project - Web application (on Spring) which instantiate upper class
and send it to queue1. Deploy file is .war, and it contain common.jar in it's
WEB-INF/lib path. Code for sending message:
try {
| jmsDistributionTemplate.send(new MessageCreator() {
| public Message createMessage(Session session) throws JMSException {
| ObjectMessage oMessage = session.createObjectMessage();
| oMessage.setObject(new PublishBaseCommand() );
| return oMessage;
| }
| });
| }
| catch(JmsException e) {
| // ...
| }
|
Third application is also Web application (also on Spring). This application contains
listener:
public void onMessage(Message message) {
| if (message instanceof ObjectMessage) {
| try {
| ObjectMessage objectMessage = (ObjectMessage)message;
| log.info("MSG === " + objectMessage.getObject());
| log.info("MSG HASH === " +
objectMessage.getObject().getClass().hashCode());
| log.info("NED HASH === " + PublishBaseCommand.class.hashCode());
| PublishBaseCommand= (PublishBaseCommand)objectMessage.getObject();
| }
| catch(JMSException e) {
| // ...
| }
| }
| }
main problem is in thrid application - in part where we call getObject and convert it to
PublishBaseCommand - we got ClassCastException:
[Thread-22] listener.SimpleMessageListenerContainer
(AbstractMessageListenerContainer.java:634) - Execution of JMS message listener
failed
| java.lang.ClassCastException: publishing.service.impl.PublishBaseCommand
| at updater.service.impl.PublishListenerImpl.onMessage(PublishListenerImpl.java:33)
| at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:531)
| at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:466)
| at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
| at
org.springframework.jms.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:407)
| at
org.springframework.jms.listener.SimpleMessageListenerContainer.processMessage(SimpleMessageListenerContainer.java:290)
| at
org.springframework.jms.listener.SimpleMessageListenerContainer$2.onMessage(SimpleMessageListenerContainer.java:266)
| at
org.jboss.jms.client.remoting.MessageCallbackHandler.callOnMessage(MessageCallbackHandler.java:153)
| at
org.jboss.jms.client.remoting.MessageCallbackHandler$ListenerRunner.run(MessageCallbackHandler.java:884)
| at
EDU.oswego.cs.dl.util.concurrent.QueuedExecutor$RunLoop.run(QueuedExecutor.java:89)
| at java.lang.Thread.run(Unknown Source)
Also following output is traced from upper log.info:
MSG === publishing.service.impl.PublishBaseCommand@126cb1a
| MSG HASH === 13712958
| NEED HASH === 13628909
P.S.
I removed most of the code for readability.
Thanks,
Zaharije Pasalic
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4184968#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...