JNDI lookup Failed error while running Sample JMS Application with j2ee1.3

I am getting the following error while executing the SimpleQueueSender Application as specified in the tutorial.

The error is :

JNDI lookup failed : javax.naming.NoInitialContextException:Need to specify class name in environment or system property or as an applet parameter, or in an application resource file: java.naming.factory.Initial.

I have set the jndi.jar in the classpath.

I have also noticed that J2ee console also shows the following messages:

Binding JMS Cnx Factory :

jms/TopicConnectionFactory,Topic,No properties.

jms/QueueConnectionFactory,Queue,No properties

QueueConnectionFactory,Queue,No properties

TopicConnectionFactory,Topic,No properties

Will someone help me out, If i am missing out something, or am i in a wrong path...

[834 byte] By [ajitphilip] at [2007-9-26 3:36:23]
# 1

Hi!

I had just that same problem this morning but managed to solve it somehow. I should always write down what to do with these kinds of errors.

You should have j2ee.jar and jms.jar in your classpath, I don't have jndi.jar in it at all. I also noticed that restarting j2ee solves many strange problems.

I can't remember anything else that differs from the tutorial instructions. So I hope this helps you :)

jonna_yomi at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Thanks for the suggestion but .I did restart J2ee server twice, but got the same error message on the console.
ajitphilip at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Can you post the code, esp the part where you are doing the JNDI lookup
shirish_wagh at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Hello,

I am coming across a new exception now while running the sample application:

SEVERE JMSInitialContext: Unable to get Internal JNDI Context because : javax.naming.CommunicationException: cannot connect to ORB[Root exception is org.omg.CORBA.COMM_FAILURE: minor code 1398079689 Completed :No]

This is the part of JNDI Lookup code from the sample application SimpleQueueSender.java from the tutorial.

==========================================

/*

* Create a JNDI InitialContext object if none exists yet.

*/

try {

jndiContext = new InitialContext();

} catch (NamingException e) {

System.out.println("Could not create JNDI " +

"context: " + e.toString());

System.exit(1);

}

/*

* Look up connection factory and queue. If either does

* not exist, exit.

*/

try {

queueConnectionFactory = (QueueConnectionFactory)

jndiContext.lookup("QueueConnectionFactory");

queue = (Queue) jndiContext.lookup(queueName);

} catch (NamingException e) {

System.out.println("JNDI lookup failed: " +

e.toString());

System.exit(1);

}

==========================================

ajitphilip at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

Hi,

Even I got the same type of error.But I got it when i changed from

java -Djms.properties=%J2EE_HOME%\config\jms_client.properties

SimpleQueueSender MyQueue 3

to

java -Djms.properties=c:\j2sdkee1.3\config\jms_client.properties

SimpleQueueSender MyQueue 3

n_kanjana at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

Hi,

I made all I could but I couldn't run the simple examples from JMS tutorial.

I'm getting the same output no matter what I'm changing

E:\4w2k\j2sdkee1.3beta2\jms_tutorial\examples\simple>java -Djms.properties=E:\4w

2k\j2sdkee1.3beta2\config\jms_client.properties SimpleQueueSender MyQueue 2

Queue name is MyQueue

JNDI lookup failed: javax.naming.CommunicationException: java.rmi.MarshalExcepti

on: CORBA MARSHAL 1398079699 Maybe; nested exception is:

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :m

inor code: 1398079699 completed: Maybe

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :minor cod

e: 1398079699 completed: Maybe

at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_value(CDRInput

Stream_1_0.java:923)

at com.sun.corba.ee.internal.iiop.CDRInputStream.read_value(CDRInputStre

am.java:281)

at com.sun.corba.ee.internal.corba.TCUtility.unmarshalIn(TCUtility.java:

274)

at com.sun.corba.ee.internal.corba.AnyImpl.read_value(AnyImpl.java:554)

at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_any(CDRInputSt

ream_1_0.java:605)

at com.sun.corba.ee.internal.iiop.CDRInputStream.read_any(CDRInputStream

.java:252)

at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.readAny(Util.java:203)

at javax.rmi.CORBA.Util.readAny(Util.java:92)

at org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lo

okup(Unknown Source)

at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:133

)

at javax.naming.InitialContext.lookup(InitialContext.java:350)

at SimpleQueueSender.main(SimpleQueueSender.java:69)

dacus at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7
Hi. Maybe later, but anyway... Remember (from the jms tutorial) that j2ee1.3 doesn't work with j2se 1.3. You must have j2e1.3.1. I faced the same problem and I think that was the cause.Remember also to set jms.properties. Hope this help.
rodrigocoronado at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 8

The definitive solution to running EJB's from a remote client:

1) In the client machine, you need some archives in the CLASSPATH:

- Client JAR of the EJB generated when the EJB has been deployed.

- j2ee.jar

- in the subfolder nativelib/, the shared library ioser12.dll

- home and remote interfaces of the EJB.

2) The client code to call the EJB could be like this:

System.setProperty("org.omg.CORBA.ORBInitialHost","host");

Hashtable p = new Hashtable();

p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.enterprise.naming.SerialInitContextFactory");

p.put(Context.PROVIDER_URL,"iiop://host:port");

Context initial = new InitialContext(p);

Object objref = initial.lookup("EJBname");

EJBhomeInterface home = (EJBhomeInterface) PortableRemoteObject.narrow(objref,EJBhomeInterface.class);

EJBremoteInterface remote = home.create();

...

Naturally, yoy need to replace the words host,port,EJBname,EJBhomeInterface and EJBremoteInterface by the settings appropiate to your case.

3) If you have security problems setting the ORBInitialHost property of the system, you have to change the appropiate .policy file (depending on where are you running the code) and add a line like this:

permission java.util.PropertyPermission "*", "read,write";

(in my case -calling the EJB from a scriptlet in a JSP deployed in a server in other machine-, the files that I've changed where %J2EE_HOME%/lib/security/server.policy and %J2EE_HOME%/lib/security/client.policy)

Doing this it has to work.

Sorry for the bad english ;-P

urotsuki at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 9
If you are having more than one JVM running and if your client and j2ee server are running in different JVM, then JNDI look up will fail. Check this. It worked for me.Regards,Ashuitosh
dandavatea at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 10
If you are having more than one JVM running and if your client and j2ee server are running in different JVM, then JNDI look up will fail. Check this. It worked for me.Regards,Ashutosh
dandavatea at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 11
I have the same problem with dacus, and I try to follow the all replied messages but in vain.Is there any other possible solution for this problem?
axxis at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 12

If jndi.jar is in your classpath then you might be using the wrong JDK. The j2ee.jar that comes with J2EE1.3 has the jndi libray within it, and doesnt need to be a seperate entry in your classpath.

The suggestion about J2SE 1.3 not compatible is a good one. Make sure you are using the latest J2SE.

Otherwise make sure your hostname is correct. ping the hostname.

turbobutton at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 13

one more thought. you must have an appropriate JMS destination added to your J2EE server.

follow the instructions you add a queue using j2eeadmin.

this queue will remain on your server until you remove it using j2eeadmin.

therefore when you boot your j2ee server. it will say ...

> j2ee -verbose

...

binding: < JMS Destination : MyQueue , javax.jms.Queue >

...

or you can use the j2eeadmin tool to list your JMS Destinations.

turbobutton at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 14

I am trying to execute

SimpleQueueSender.java from jms tutorial but unforunately getting following

errors.

Errors-->

Queue name is MyQueue

JNDI lookup failed: javax.naming.CommunicationException:

java.rmi.MarshalException: CORBA MARSHAL 13

98079699 Maybe; nested exception is:

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :

minor code: 139807969

9 completed: Maybe

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :minor

code: 1398079699 comple

ted: Maybe

at

com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_

1_0.java:936)

at

com.sun.corba.ee.internal.iiop.CDRInputStream.read_value(CDRInputStream.java

:292)

at

com.sun.corba.ee.internal.corba.TCUtility.unmarshalIn(TCUtility.java:268)

at

com.sun.corba.ee.internal.corba.AnyImpl.read_value(AnyImpl.java:562)

at

com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_

0.java:618)

at

com.sun.corba.ee.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:2

63)

at

com.sun.corba.ee.internal.javax.rmi.CORBA.Util.readAny(Util.java:103)

at javax.rmi.CORBA.Util.readAny(Util.java:92)

at

org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lookup(Un

known Source)

at

com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:154)

at javax.naming.InitialContext.lookup(InitialContext.java:350)

at SimpleQueueSender.main(SimpleQueueSender.java:70)

I have all the setup required for running jms api examples & also tried all the tips mentioned here ,but still getting these errors . Any

help would be greatly appreciated.

Praveg

praveg at 2007-6-29 12:07:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 15

A note at the end of the "Writing Simple JMS Client Applications" says that there is a known bug in the JMS provider in the J2EE SDK that MAY cause a tuntime failure to create a connection to systems that use DHCP to obtain an IP Address.

My system does and it fails exactly like those posted above. But so you can be sure, here is my error output:

=================

C:\java sandbox\samples>java SimpleQueueReceiver MyQueue

Queue name is MyQueue

JNDI lookup failed: javax.naming.CommunicationException: java.rmi.MarshalException:

CORBA MARSHAL 1398079699 Maybe;

nested exception is:

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :

minor code: 1398079699 completed: Maybe

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :minor code: 1398079699 completed: Maybe

========================================

My Windows 2000/professional machines do use a DHCP router for their IP Addresses. I am going to take a machine standalone with a static IP and see if this changes the behavior.

I would be interested in knowing if the other folks who were not successful with the samples were on a windows machine using a DHCP server.

Thanks!

Al...

ajamison at 2007-7-1 9:15:53 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 16

Ok. I have some information.

I found a work-around for the following error:

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : m

inor code: 1398079699 completed: Maybe

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : minor cod

e: 1398079699 completed: Maybe

I solved this problem on windows 2000 and XP-Pro by:

1. COPYING my j2ee_home and Java_home directories to another location.

2. Add/Delete the j2ee, jdk, and jre packages that were installed on my system. I am guessing that the formal installation added some registry entries that affects machines that are configured on a bridge with DHCP. This step cleans out your system. I re-booted after this step just to be safe.

3. Move the original directories back to their original locations and check that your environment variables point at the right trees.

I don't think it is a code bug so much as it is a registry configuration setting issue - which I did not research - but the steps above point to a Java component installation confusion.

My examples ran correctly and without flaw for the first time since I set up this machine. Without this sequence of steps, the sample JMS programs failed to run on my Win2K and Win-XP/Pro machines. Performing this copy/remove/copy procedure, my XP machine is running the samples flawlessly - even under a DHCP providing router.

Hope this helps anyone out there who is still puzzling over this.

Al...

ajamison at 2007-7-1 9:15:53 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...