Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:09:31+00:00 2026-06-02T17:09:31+00:00

I have searched for the solution of my problem as much as I could.

  • 0

I have searched for the solution of my problem as much as I could.
My App runs on Glassfish v3.This app sends a message to Glassfish JMS queue and this message is supposed to be read by a standalone client on the same host but outside Glassfish JVM.

I have written standalone client java code – have included appserv-rt.jar and gf-client.jar from Glassfish installation directory.

This client code is unable to receive the message.System out statements print till “got consumer”.After that nothing happens.

If I change the name of the queue-I get an error saying Queue not found.So it seems client code is able to find queue but it does not receive any messages.What do I need to include in my client code?

Here is my Java class :-

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;

import javax.annotation.Resource;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.jms.Queue;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.log4j.Category;

import domain.RedirectFile;

 public class ZblBulkUploadThread implements Runnable,MessageListener{

 private static final Category log = Category.getInstance(ZblBulkUploadThread.class) ;



    private Queue queue;

public void run()
{
    try
    {

        System.out.println(" inside try") ;
        InitialContext jndiContext = null;

        MessageConsumer messageConsumer=null;


        jndiContext = new InitialContext();

        System.out.println(" got context ") ;

        ConnectionFactory connectionFactory = (ConnectionFactory)jndiContext.
                lookup("jms/SimpleConnectionFactory");



        System.out.println("got connectionfactory") ;

    Connection connection = connectionFactory.createConnection();

    System.out.println("got connection") ;
    Session session = connection.createSession(false,
            Session.AUTO_ACKNOWLEDGE);

    queue = (Queue)jndiContext.lookup("jms/SimpleQueue") ;

    System.out.println("got queue"+queue.getQueueName()) ;

    messageConsumer = session.createConsumer(queue);

    System.out.println(" selector "+messageConsumer.getMessageSelector()) ;

    System.out.println("got consumer") ;

    Message message = messageConsumer.receive() ;

    System.out.println("Message is "+message) ;

    System.out.println("destination is "+message.getJMSDestination()) ;

    ObjectMessage om = ((ObjectMessage)message) ;
    try
    {

    RedirectFile file = (RedirectFile)om.getObject() ;

    log.debug("filePath "+file.getFilePath()) ;
    log.debug(" userName "+file.getUserName()) ;
    log.debug(" mode is "+file.getMode()) ;

    System.out.println("filePath "+file.getFilePath()) ;
    System.out.println(" userName "+file.getUserName()) ;
    System.out.println(" mode is "+file.getMode()) ;
    }
    catch(Exception ex)
    {
        log.error("ERROR "+ex.getMessage()) ;
        ex.printStackTrace() ;
    }

    log.debug("session created") ;

    }
    catch(Exception ex)
    {

        ex.printStackTrace() ;
        log.error("Error "+ex.getMessage()) ;
    }
}


public void onMessage(Message message)
{
    System.out.println("Message received "+message) ;
}

public static void main(String[] args)
{
    ZblBulkUploadThread zbut = new ZblBulkUploadThread() ;
    new Thread(zbut).start() ;
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:09:34+00:00Added an answer on June 2, 2026 at 5:09 pm

    try: connection.start(); somewhere before the receive call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched google and SO for a solution to this problem but have not
I have searched extensively on this, but cannot find the solution to my problem.
I have searched and searched for a solution to this problem, but it seems
I have searched to find a solution to this problem without anyluck. I have
I have searched for hours now and haven't found a solution for my problem.
I have searched the web but I cannot find the solution to my problem.
I have searched for a general solution to this but only find answers to
I have searched around Google and StackOverflow trying to find a solution to this,
I've searched for two days trying to find a solution to this. My problem
I have searched a lot to find a solution for my problem, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.