• 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

jdeveloper look up error for jms

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i am using jdeveloper for a project on jms and ejb. i created jms web service where i have mentioned my queueConnectionFactory as MyQueueConnectionFactory and queue as MyQueue. the web.xml file is also created which shows this. now i have written a small client code to send messages and message driven bean to receive messages. the code is written below:
package mypackage1;
import javax.jms.*;
import javax.naming.*;
import java.util.Hashtable;
import java.lang.Object;
import javax.rmi.PortableRemoteObject;
/**
* The SimpleClient class sends several messages
* to a queue.
*/
public class simpleClient
{
public simpleClient()
{
}
/**
* Main method.
*/
public static void main(String[] args)
{
Context jndiContext = null;
QueueConnectionFactory
queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueSender queueSender = null;
TextMessage message = null;
final int NUM_MSGS = 3;

/*
* Create a JNDI API InitialContext object.
*/
try
{
Hashtable env = new Hashtable();
env.put (Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
env.put(Context.PROVIDER_URL, "ormi://localhost:23893/current-workspace-app");
jndiContext = new InitialContext(env);
System.out.println("context: " + jndiContext);

}
catch (NamingException e)
{
System.out.println("Could not create JNDI API " +
"context: " + e.toString());
System.exit(1);
}

/*
* Look up connection factory and queue. If
either does not exist, exit.
*/
try
{
queueConnectionFactory = (QueueConnectionFactory)
PortableRemoteObject.narrow(jndiContext.lookup
("jms/MyQueueConnectionFactory"),QueueConnectionF actory.class);
System.out.println("found QCF ");
queue = (Queue)jndiContext.lookup("jms/MyQueue");
System.out.println("found Q");
}
catch (NamingException e)
{
System.out.println("JNDI API lookup failed: " +
e.toString());
System.exit(1);
}
/*
* Create connection.
* Create session from connection; false means
session is not transacted.
* Create sender and text message.
* Send messages, varying text slightly.
* Finally, close connection.
*/
try
{
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
queueSender = queueSession.createSender(queue);
message = queueSession.createTextMessage();
for (int i = 0; i (lessa than) NUM_MSGS; i++)//sorry for syntax error, this page was not excepting less than sign.
{
message.setText("This is message " + (i + 1));
System.out.println("Sending message: " +
message.getText());
queueSender.send(message);
}
}
catch (JMSException e)
{
System.out.println("Exception occurred: " +
e.toString());
}
finally
{
if (queueConnection != null)
{
try {
queueConnection.close();
}
catch (JMSException e) {}
}
System.exit(0);
}
}
}
while running this client code i get the following output:
context: javax.naming.InitialContext@4
JNDI API lookup failed: javax.naming.NamingException: Lookup error: java.net.ConnectException: Connection refused: connect; nested exception is:
java.net.ConnectException: Connection refused: connect
Process exited with exit code 1.
i tried both local and remote lookups to see if either works. but i m not able to find the error.
please let me know wht should i do to solve this problem.
thanks,
ashmi.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic