Receive an error when the Naming Service can not be found
(Last modified: 11Apr2003)
This document (10082044) is provided subject to the disclaimer at the end of this document.
fact
Novell exteNd Jbroker MQ 1.3.6
Novell exteNd Application Server 3.7.4
Solaris 2.7
symptom
Receive an error when the Naming Service can not be found
When the Naming Service can not be found, the application leaks java.net.ServerSockets
Error: javax.naming.ConfigurationException: COS Name Service not registered with ORB under the name 'NameService'. Root exception is
org.omg.CORBA.ORBPackage.InvalidName: unable to resolve initial reference: NameService
cause
The current Application code created a new java.net.ServerSocket with each call.
fix
Modify the Application code so that it only uses one (1) java.net.ServerSocket and one (1) ORB. The code will continue to use and re-use the one java.net.ServerSocket and one ORB, even if the server with the Naming Service goes down and is restarted.
note
Using VMGEAR OptimizeIt Profiler 4.1 to profile the Application Code is how the Cause was discovered.
Here is a code sample that uses one (1) java.net.ServerSocket and one (1) ORB:
It will be necessary to change "<server_name>" in the following line:
System.setProperty("ORBDefaultInitRef","iioploc://<server_name>:3506");
to the actual server name
(i.e.:System.setProperty("ORBDefaultInitRef","iioploc://TestMachine:3506");
/**
* Generated by SilverStream XSLT Code Generator, version 1.0.
* This generated source file may be freely modified.
*/
package com.novell.test;
import javax.jms.*;
import java.util.*;
import javax.naming.*;
import java.io.*;
import org.omg.CORBA.*;
/**
MQCall
*/
public class MQCall
{
InitialContext ctx = null;
ORB orb = null;
int i=0;
public MQCall()
{
String[] args = null;
System.setProperty("ORBDefaultInitRef","iioploc://<server_name>:3506");
System.setProperty("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
System.setProperty("java.naming.factory.object","com.sssw.jms.naming.JMQObjectFactory");
orb = ORB.init(args,null);
}
public static void main( String [] args )
{
System.out.println("get going...");
MQCall myVar = new MQCall();
myVar.work();
System.out.println("done!");
System.exit(0);
}
private void work()
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = null;
while (true)
{
i++;
this.initQueue();
try
{
System.out.print(">next ?");
line = br.readLine();
}
catch(Exception ie)
{
ie.printStackTrace();
}
if ("exit".equalsIgnoreCase(line))
break;
}
closeContext();
}
private InitialContext getContext()
{
try
{
if (ctx == null)
{
System.out.println("\r\n---------------------------\r\n...getting Context\r\n---------------------------\r\n");
Hashtable ht = new Hashtable(5, 0.75f);
ht.put("java.naming.corba.orb",orb);
ctx = new InitialContext(ht);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return ctx;
}
public void initQueue()
{
System.out.println("attempt: " + i);
QueueConnectionFactory qConFac = null;
try
{
ctx = getContext();
if(ctx != null)
{
System.out.println(" looking for the queue...");
//lookup the Queue from the naming service
Queue queue = (Queue)ctx.lookup("queue/queue0");
queue = null;
}
else
{
System.out.println(" no context found ; skipping this time ;)");
}
}
catch(Throwable e)
{
e.printStackTrace();
System.out.println(":-----> discarding the context!");
closeContext();
}
}
private void closeContext()
{
if (ctx != null)
{
try{ctx.close();}catch(Exception e){}
ctx = null;
}
}
}
.
Here is the complete Stack Trace:
javax.naming.ConfigurationException: COS Name Service not registered with ORB under the name 'NameService'. Root exception is
org.omg.CORBA.ORBPackage.InvalidName: unable to resolve initial reference: NameService
at com.sssw.jbroker.orb.ORB.resolve_initial_references(ORB.java:1265)
at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:276)
at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:251)
at com.sun.jndi.cosnaming.CNCtx.createUsingURL(CNCtx.java:88)
at com.sun.jndi.url.iiop.iiopURLContextFactory.getUsingURLIgnoreRest(iiopURLContextFactory.java:55)
at com.sun.jndi.url.iiop.iiopURLContextFactory.getUsingURL(iiopURLContextFactory.java:60)
at com.sun.jndi.url.iiop.iiopURLContextFactory.getObjectInstance(iiopURLContextFactory.java:32)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:577)
at javax.naming.spi.NamingManager.processURL(NamingManager.java:359)
at javax.naming.spi.NamingManager.processURLAddrs(NamingManager.java:339)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:311)
at javax.naming.spi.NamingManager.getContext(NamingManager.java:417)
at javax.naming.spi.ContinuationContext.getTargetContext(ContinuationContext.java:33)
at javax.naming.spi.NamingManager.getContinuationContext(NamingManager.java:761)
at com.sssw.rt.jndi.AgInitCtx.checkFederatedContext(AgInitCtx.java:196)
at com.sssw.rt.jndi.AgInitCtx.checkFederatedName(AgInitCtx.java:98)
at com.sssw.srv.jndi.AgInitServerCtx.lookup(AgInitServerCtx.java:56)
at com.sssw.rt.jndi.AgBaseCtx.lookup(AgBaseCtx.java:241)
at javax.naming.InitialContext.lookup(InitialContext.java:345)
at ca.mda.nlischan.sys.MessageFactory.initQueue(MessageFactory.java:486)
at ca.mda.nlischan.sys.MessageFactory.validateQueueConnection(MessageFactory.java:602)
at ca.mda.nlischan.sys.MessageFactory.reconnectToQueue(MessageFactory.java:306)
at ca.mda.nlischan.jms.QueueMonitor.run(QueueMonitor.java:171)
document
Document Title: | Receive an error when the Naming Service can not be found |
Document ID: | 10082044 |
Solution ID: | NOVL88498 |
Creation Date: | 10Apr2003 |
Modified Date: | 11Apr2003 |
Novell Product Class: | Web Services |
disclaimer
The Origin of this information may be internal or external to Novell. Novell makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Novell makes no explicit or implied claims to the validity of this information.
Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark information.