Hi All,
I am trying to integrate glassfish and mq7.0 using genericRA but I am
not able to do it. I keep getting errors. FYI this is the first time I
am working on mq and glassfish. I am following the integration material
you have put out
https://genericjmsra.dev.java.net/docs/websphere-mq-integration-guide/we
bspheremq_integration_guide.html
I am getting the following exception
INFO: Error in allocating a connection. Cause: javax.naming.Reference
cannot be cast to javax.jms.ConnectionFactory
javax.resource.spi.ResourceAllocationException: Error in allocating a
connection. Cause: javax.naming.Reference cannot be cast to
javax.jms.ConnectionFactory
at
com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnectio
n(ConnectionManagerImpl.java:296)
at
com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(C
onnectionManagerImpl.java:182)
at
com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(C
onnectionManagerImpl.java:159)
at
com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(C
onnectionManagerImpl.java:154)
at
com.sun.genericra.outbound.ConnectionFactory.createConnection(Connection
Factory.java:75)
at
net.ensode.glassfishbook.MessageReceiver.getMessages(MessageReceiver.jav
a:42)
I am using a simple java program to read the message from the queue. I
am using the appclient functionality of glassfish
private static ConnectionFactory connectionFactory;
private static Queue queue;
private static Context context = null;
private static Connection connection;
public void getMessages()
{
Context context = null;
MessageConsumer
messageConsumer;
TextMessage textMessage;
boolean goodByeReceived
= false;
try
{
System.out.println("Coming here 1 before the context");
context = new
InitialContext();
System.out.println("Coming here 2");
queue=(javax.jms.Queue)context.lookup("jms/MyQueue");
System.out.println("Got
the queue" + queue);
System.out.println("Coming here 3");
connectionFactory =
(ConnectionFactory)context.lookup("jms/MyQCF");
System.out.println("Got
the factory-- " + connectionFactory);
System.out.println("Coming here 4");
System.out.println("The
conenction value is --" + connectionFactory.createConnection());
connection = connectionFactory.createConnection();
System.out.println("Coming here 5");
Session
session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
System.out.println("Coming here 6");
//System.out.println("The queue name is -- "+ queue.getQueueName());
messageConsumer = session.createConsumer(queue);
System.out.println("Coming here 7");
connection.start();
System.out.println("Coming here 8");
while
(!goodByeReceived)
{
System.out.println("Waiting for messages...");
textMessage = (TextMessage) messageConsumer.receive();
if (textMessage != null)
{
System.out.print("Received the following message: ");
System.out.println(textMessage.getText());
System.out.println();
}
if (textMessage.getText() != null
&& textMessage.getText().equals("Good bye!"))
{
goodByeReceived = true;
}
}
messageConsumer.close();
session.close();
connection.close();
}
catch (JMSException e)
{
e.printStackTrace();
}catch(Exception ie){
ie.printStackTrace();
}
}
public static void main(String[] args)
{
System.out.println("Atlest coming inside
the class");
new
MessageReceiver().getMessages();
}
}
Can you please let me know what I am missing here. This is kind of
urgent. Thank you so much for your help in advance. Please let me know
if you need anything else
Thanks
Gokul Dharumar