William,
<jms-service default-jms-host="default_JMS_host" type="EMBEDDED">
<jms-host port="${JMS_PROVIDER_PORT}" host="localhost" name="default_JMS_host"></jms-host>
</jms-service>
Thanks. Also
<system-property description="Port Number that JMS Service will listen for remote clients connection."
name="JMS_PROVIDER_PORT" value="7677"></system-property>
So when you start this GlassFish instance it will start an embedded (in-JVM) JMS broker which listens on port 7677. This
would be in addition to the JMS broker in the "remote" GlassFish instance. Do you actually intend to use two JMS brokers
here?
The other piece of information in domain.xml (under <config name="server-config">) is the definition of the connection
factory:
<connector-resource pool-name="jms/TestFactory-Connection-Pool" jndi-name="jms/TestFactory"></connector-resource>
<connector-connection-pool max-pool-size="250" steady-pool-size="1" name="jms/TestFactory-Connection-Pool"
resource-adapter-name="jmsra" connection-definition-name="javax.jms.ConnectionFactory">
<property name="AddressList" value="localhost:7676"></property>
</connector-connection-pool>
Did you explicitly set port 7676 there? Is that the port used by the remote JMS broker?
I wouldn't rule out there being a bug here, but my suggestion is that you use the admin console to configure your
jms-service to use a mode of "Remote" rather than "Embedded". This will prevent an embedded JMS broker being started
(assuming you don't intend to use it). You can configure the jms-service with the host:port of the "remote" JMS broker.
This will be used as a default throughout the GlassFish instance and avoid you having to set host:port on each
connection factory explicity. In case of the MDB you can simply omit the connectionFactoryLookup attribute and it will
use the connection details specified in the jms-service.
Nigel
On 24/02/2015 07:37, William wrote:
> Thanks for your quick reply.
> Yes, of course, I paste ‘jms-service’ element here, and you can read whole file as attached file.
>
> <jms-service default-jms-host="default_JMS_host" type="EMBEDDED">
> <jms-host port="${JMS_PROVIDER_PORT}" host="localhost" name="default_JMS_host"></jms-host>
> </jms-service>
>
> The overview of my idea is that I have a local glassfish server, and a remote one.
> The remote glassfish should be as a JMS provider which generates jms messages.
> I plan to develop/deploy a MDB in local glassfish server, to receive messages from the remote glassfish.
> From reading document, I think it should be specified remote ip:port info by setting connectionFactoryLookup attribute.
> But I failed to do that.
>
> =
>
>
>
> also I try to add ‘jmsra ‘ and remove @JMSDestinationDefinition, but it seems not work :(
> thanks very much!
>
> William
> 2015/2/24
>
>
>
>> On Feb 24, 2015, at 1:08 AM, Nigel Deakin <nigel.deakin_at_oracle.com <mailto:nigel.deakin_at_oracle.com>> wrote:
>>
>> 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
>>>
>
> =