File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes Help required for JMS on Jboss server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Help required for JMS on Jboss server" Watch "Help required for JMS on Jboss server" New topic

Help required for JMS on Jboss server

Yogi Mehta

Joined: Jun 24, 2009
Posts: 5

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.

at com.ui.action.HelloG.mains(
at com.ui.action.TestAction.process(
at com.ui.BAction.execute(

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" ?>
<mbean code=""
<depends optional-attribute-name="DestinationManager"></depends>

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.

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

// create a queue session
QueueSession queueSession = queueConn.createQueueSession(false,

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

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

// send the message

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

// close the queue connection

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) {


Nilu Deshmukh

Joined: Aug 03, 2009
Posts: 22
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..
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441


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.

[My Blog] [JavaRanch Journal]
Nilu Deshmukh

Joined: Aug 03, 2009
Posts: 22
I Was a Issue of .jar files .
The Issue is resolved.
It is sorta covered in the JavaRanch Style Guide.
subject: Help required for JMS on Jboss server
It's not a secret anymore!