ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » [Solved] RefFSContextFactory NameNotFoundException

Post new topic  Reply to topic
 [Solved] RefFSContextFactory NameNotFoundException « View previous topic :: View next topic » 
Author Message
cschaul
PostPosted: Fri Jan 03, 2003 6:35 am    Post subject: [Solved] RefFSContextFactory NameNotFoundException Reply with quote

Novice

Joined: 08 Nov 2002
Posts: 13

If anyone can provide some insight into why this isnt working that would be great! I used JMSAdmin on my WinNT machine to load up the jndi names:
def ctx(ehub)
chg ctx(ehub)
def qcf(QCF) qmgr(TCK6) +
tran(client) chan(TCK6.TO.CLIENTS) +
host(rs111) port(1414)
def q(Q) qmgr(TCK6) queue(EHT.TDSIREQUEST)
end

So i run my program's main method through WSAD, and it gives me the following error:
{java.naming.provider.url=file:/c:/errors, java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory}
javax.naming.NameNotFoundException: ehub/QCF
at com.sun.jndi.fscontext.RefFSContext.getObjectFromBindings(RefFSContext.java:400)
at com.sun.jndi.fscontext.RefFSContext.lookupObject(RefFSContext.java:327)
at com.sun.jndi.fscontext.RefFSContext.lookup(RefFSContext.java:146)
at com.sun.jndi.fscontext.FSContext.lookup(FSContext.java:127)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.csx.ehub.getMQMessage2.setConnection(getMQMessage2.java:117)
at com.csx.ehub.getMQMessage2.main(getMQMessage2.java:27)
Connection setting error: javax.naming.NameNotFoundException: ehub/QCF
Back to top
View user's profile Send private message
leongor
PostPosted: Sun Jan 05, 2003 2:18 am    Post subject: Reply with quote

Master

Joined: 13 May 2002
Posts: 264
Location: Israel

Are you sure you have .binding in c:\errors path as declared ?
Another consideration, if you created it with right values on the firt time or not ?
Because JMSAdmin configuration utility appends this file.
_________________
Regards.
Leonid.

IBM Certified MQSeries Specialist.
Back to top
View user's profile Send private message
cschaul
PostPosted: Mon Jan 06, 2003 4:06 am    Post subject: Reply with quote

Novice

Joined: 08 Nov 2002
Posts: 13

Yes, i deleted the c:/errors/ehub directory, then ran the jmsadmin program again to readd that directory with the .bindings file.
Is there any other program I need running? I am running my MQReceiver program out of WSAD. I had it running just fine with an IBM example using iiop, but would rather use the file system jndi.
Back to top
View user's profile Send private message
bower5932
PostPosted: Mon Jan 06, 2003 7:49 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I thought that you had to put a '/' on the front of the ehub:

/ehub/QCF

Did you try this?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
cschaul
PostPosted: Mon Jan 06, 2003 9:08 am    Post subject: Reply with quote

Novice

Joined: 08 Nov 2002
Posts: 13

yes ive tried that. Heres the code im using:


public class getMQMessage2 extends Thread implements MessageListener {

private static final String INITIAL_CONTEXT_FACTORY_PROP = "initialContextFactory";
private static final String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial";
private static final String PROVIDER_URL = "file://c:/errors";

private QueueConnection connection;
private QueueSession session;
private QueueReceiver receiver;
private InitialContext initContext;
private String initialContextFactory;
private String exceptionMessage;
private String message;
private static getMQMessage2 ivjReceiver = null;

public static void main(String argv[]) {
ivjReceiver = new getMQMessage2();
InputStreamReader userInput = new InputStreamReader(System.in);
try {
ivjReceiver.setConnection("/ehub/QCF");
ivjReceiver.setQueue("/ehub/Q");
} catch (java.lang.Throwable ex) {
System.out.println("Connection setting error: " + ex);
System.exit(0);
}
char answer = '\0';
System.out.println("To stop receiver, enter Q and <return>");
while (!((answer == 'q') || (answer == 'Q'))) {
try {
answer = (char) userInput.read();
} catch (IOException iex) {
}

}
}

public void close() throws JMSException, NamingException, Throwable {

try {
System.out.println("Closing connection");
if (connection != null)
connection.stop();
if (receiver != null)
receiver.close();
if (session != null)
session.close();
if (connection != null)
connection.close();
if (initContext != null)
initContext.close();
} catch (Throwable e) {
setExceptionMessage(e);
throw e;
}
}

public String getExceptionMessage() {

return exceptionMessage;
}

public String getMessage() {

return message;
}

private InitialContext getInitContext() throws NamingException {

if (initContext == null) {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, getInitialContextFactory());
properties.put(Context.PROVIDER_URL, PROVIDER_URL);
// System.out.println(properties.toString());
initContext = new InitialContext(properties);
// System.out.println(initContext.toString());
}
return initContext;
}

private String getInitialContextFactory() {

if (initialContextFactory == null) {
initialContextFactory = System.getProperty(INITIAL_CONTEXT_FACTORY_PROP);
}
return initialContextFactory;
}

public void onMessage(Message message) {

String msgText = null;
try {
msgText = ((TextMessage) message).getText();
System.out.println(msgText);
if (msgText.substring(0, 3).equals("$*$")) {
System.out.println("A server message was received");
} else
SendRequestToFord2.SendRequest(msgText);
} catch (Throwable e) {
setExceptionMessage(e);
msgText = getExceptionMessage();
}
}

public void setConnection(String connectionName)
throws JMSException, NamingException, Throwable {

try {
close();
QueueConnectionFactory factory =
(QueueConnectionFactory) getInitContext().lookup(connectionName);
System.out.println("After setting QCF");
connection = factory.createQueueConnection();
System.out.println("After creating Queue Connection");
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("After creating Queue Session");
} catch (Throwable e) {
setExceptionMessage(e);
e.printStackTrace();
sleep(1000);
throw e;
}
}

private void setExceptionMessage(Throwable t) {

exceptionMessage = "Exception: " + t.toString();
}

public void setQueue(String queueName)
throws JMSException, NamingException, Throwable {

try {
if (connection != null)
connection.stop();
if (receiver != null)
receiver.close();
Queue queue = (Queue) getInitContext().lookup(queueName);
receiver = session.createReceiver(queue);
receiver.setMessageListener(this);
connection.start();
} catch (Throwable e) {
setExceptionMessage(e);
throw e;
}
}
}
Back to top
View user's profile Send private message
cschaul
PostPosted: Mon Jan 06, 2003 10:38 am    Post subject: Reply with quote

Novice

Joined: 08 Nov 2002
Posts: 13

i figured out a solution:
private static final String PROVIDER_URL = "file://c:/errors/ehub";
and then having the queueconnectionfactory as "QCF"
and the queue name as "Q"

Any ideas why setting the intial url as c:/errors did not work? But changing it to c:/errors/ehub did work?
Back to top
View user's profile Send private message
JustinM
PostPosted: Sat Apr 26, 2003 2:20 am    Post subject: Reply with quote

Novice

Joined: 10 Apr 2002
Posts: 13

Hi

IBM's documentation in this regard is scant.
From http://www7b.software.ibm.com/wsdd/techjournal/0204_minocha/minocha.html:

'On the other hand, the file system JNDI service has trouble resolving names qualified by subcontexts. For example, name "Sample/JMS/Q1" refers to object Q1 in subcontext JMS of subcontext Sample. Looking up "Sample/JMS/Q1" works in Application Server, but you may have to flatten the name, for example to "JMSQ1," for the file system.'

Cheers

Justin
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » [Solved] RefFSContextFactory NameNotFoundException
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.