users@glassfish.java.net

[gf-users] Re: please help me to confirm if it is a bug in connector component in GF4.1

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Mon, 23 Feb 2015 17:08:17 +0000

William,

The ClassCastException is caused by a mixup somehow in the type of the ConnectionFactory: ConnectionFactoryAdapter is
used for remote connections, DirectConnectionFactory is used for direct (embedded) connections.

Can you supply the domain.xml for the GlassFish instance into which you're deploying the MDB? I'm interested in the
jms-service element.


Nigel


On 23/02/2015 16:29, William wrote:
> Dear all,
>
> I plan to use a message driven bean to receive messages from a remote embed JMS provider in remote Glassfish Server
> 4.1(openMQ as default).
> From instruction of javaEE7.pdf and bunddled sample code from GF4.1, I write a simple MDB as below.
>
> @JMSDestinationDefinition(
> name = "jms/BillReceiveQueue",
> interfaceName = "javax.jms.Queue",
> destinationName = "BillReceiveQueue")
> @MessageDriven(activationConfig = {
> @ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "jms/TestFactory"),
> @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/BillReceiveQueue"),
> @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
> })
> *public* *class* TestMDB *implements* MessageListener {
>
>
> @Override
> *public* *void* onMessage(Message inMessage) {
>
>
> }
> }
>
> I create jms/TestFactory in admin GUI console with java.jms.ConnectionFactory resource type.
> And create jms/BillReceiveQueue in admin GUI console with javax.jms.Queue resource type.
>
> During the deployment, I got the error:
>
> 2015-02-24T00:07:50.718+0800|Warning: RAR8501: Exception during endpoint activation for ra [ jmsra ],
> activationSpecClass [ com.sun.messaging.jms.ra.ActivationSpec ] : java.lang.ClassCastException:
> com.sun.messaging.jms.ra.ConnectionFactoryAdapter cannot be cast to com.sun.messaging.jms.ra.DirectConnectionFactory
> 2015-02-24T00:07:50.718+0800|Severe: MDB00017: [TestMDB]: Exception in creating message-driven bean container:
> [java.lang.Exception]
> 2015-02-24T00:07:50.719+0800|Severe: java.lang.Exception
> java.lang.Exception
> at com.sun.enterprise.connectors.inbound.ConnectorMessageBeanClient.setup(ConnectorMessageBeanClient.java:215)
> at org.glassfish.ejb.mdb.MessageBeanContainer.<init>(MessageBeanContainer.java:252)
> at org.glassfish.ejb.mdb.MessageBeanContainerFactory.createContainer(MessageBeanContainerFactory.java:63)
> at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:221)
>
>
> From documents, I didn’t find any instruction that telling me to change any other setting or configuration.
> So I wonder why it throws a ClassCastException here? Did I miss something?
> Thank you for your kindness reply.
>
> William
> 2015/2/24
>