• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Help required for JMS on Jboss server

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi All,

I am trying to create a simple JMS Queue program on Jboss Server. But I am getting follwing error. According to this error I am getting SpyQueue object and I am trying to cast it as Queue. Please suggest me what changes i need to do so that I will get Queue object instead of SpyQueue.

java.lang.ClassCastException: org.jboss.mq.SpyQueue
at com.ui.action.HelloG.mains(HelloG.java:27)
at com.ui.action.TestAction.process(TestAction.java:100)
at com.ui.BAction.execute(BAction.java:188)



Here is the Code that I am using. Please help me to get it resolved:

I have created one destination-service.xml file in deploy folder or JBoss app server:

<?xml version="1.0" encoding="UTF-8" ?>
<server>
<mbean code="org.jboss.mq.server.jmx.Queue"
name="jboss.mq.destination:service=Queue,name=queue0">
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
</mbean>
</server>

Here is my class HelloG that is having all the logic:

package com.somthing.action;

import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;


public class HelloG
{
public void mains() throws Exception
{
// get the initial context
InitialContext ctx = new InitialContext();

// lookup the queue object
Queue queue = (Queue) ctx.lookup("queue/queue0");

// lookup the queue connection factory
QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.
lookup("queue/connectionFactory");

// create a queue connection
QueueConnection queueConn = connFactory.createQueueConnection();

// create a queue session
QueueSession queueSession = queueConn.createQueueSession(false,
Session.DUPS_OK_ACKNOWLEDGE);

// create a queue sender
QueueSender queueSender = queueSession.createSender(queue);
queueSender.setDeliveryMode(DeliveryMode.PERSISTENT);

// create a simple message to say "Hello"
TextMessage message = queueSession.createTextMessage("Hello");

// send the message
queueSender.send(message);

// print what we did
System.out.println("sent: " + message.getText());

// close the queue connection
queueConn.close();
}

/**
This method is called asynchronously by JMS when a message arrives
at the queue. Client applications must not throw any exceptions in
the onMessage method.
@param message A JMS message.
*/
public void onMessage(Message message)
{
TextMessage msg = (TextMessage) message;
try {
System.out.println("received: " + msg.getText());
} catch (JMSException ex) {
ex.printStackTrace();
}
}

}



 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I run the above code -- its give me following exception



what would be the problem ..
I wanted to run Simple JMS code...
but I think i am missing some settings...
I configured -service.xml and -ds.xml files..
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nilu,

Please create a separate thread to discuss your issue, which is different what the original poster started this thread for. Also, in the new thread provide more details, including the version of JBoss and version of Java. Also provide relevant config files and any relevant code snippets.
 
Nilu Deshmukh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Was a Issue of .jar files .
The Issue is resolved.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic