error NoInitialContextException - why ?

i am receiving this error when i run my app from AIX

java.lang.Exception: An exception occurred in Metrics

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 run the same code in WIN with the same dir structure and it works fine and logs to my Metrics log and DB

but when I push the jar to AIX I get the error however it logs to my metrics log just not the DB?

is there something else i need to do for an AIX environment setup..

my jndi.properties looks like this

java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory

java.naming.provider.url=file:////systemapp//appFolder

where my jndi.properties are stored

can anyone make a suggestion on what i need to do?

thanks in advance

[911 byte] By [annie613a] at [2007-10-2 16:50:39]
# 1
The jndi.properties is probably not in the classpath.
aniseeda at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 2

this is the .sh file i use to start the app

cd /sysapp/appFolder

CLASSPATH=/usr/java130/jre/lib/rt.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/unzip.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/log4j-1.2.6.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/cts.util.mq.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/fscontext.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/mail.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/jdom_b7.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/activation.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/providerutil.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/com.ibm.mq.iiop.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/jms.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/com.ibm.mq.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/jndi.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/com.ibm.mqjms.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/xerces_1.3.1.jar

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/com.test.commonhlper.jar

CLASSPATH=$CLASSPATH:/usr/opt/db2_08_01/java/db2java.zip

CLASSPATH=$CLASSPATH:/sysapp/appFolder/bin/sshtools-j2ssh-0.1.0-beta.jar

CLASSPATH=$CLASSPATH:/usr/opt/db2_08_01/java

LIBPATH=/sysapp/appFolder/secExit:/home/archive/sqllib/java12:/usr/opt/db2_08_01/lib

PATH=$PATH:/sysapp/appFolder/

java com.app.Launcher /sysapp/appFolder/Unzip/config/ABC/ABC1/Unzip.properties &

and i have the jndi.jar there am i missing something else

annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 3
The jndi.properties! Where is it placed? Is it in a directory included in the classpath?
aniseeda at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 4
the jndi.properties is located in this dir/sysapp/appFolderdir
annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 5
yes the jndi.properties is in the classpath now -and i still get the errordo i need to put the jndi.properties in the CLASSPATH?
annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 6
> the jndi.properties is located in this dir> > /sysapp/appFolder> > dirI don't see that included in the classpath. It seems to be the working directory but then your classpath does not include a dot -- "."
aniseeda at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 7
> do i need to put the jndi.properties in the> CLASSPATH?Yes, and the classpath has to be the classpath of the server, not the system classpath. By the way, is it a stand-alone application or a serverside application?
aniseeda at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 8
i just added /sysapp/appFolderto the class path and reran the app and it still gave me the errorwhat '.' dot do i need?
annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 9
> what '.' dot do i need?never mind the dot for now. post the code where this exception is generated.
aniseeda at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 10
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rnam_example_prop1.htmlAlso check if this could be of some help.
aniseeda at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 11
i dont have the code where it breaks b/c its a commonhelp.jar that breaks and i dont have access to that code i just include it to my appthe commonhelper.jar works b/c i have used it in prior apps and it works and logs and tothe DB - im just confused on this one
annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 12
thx for the link - i will read over that and see what i can get out of it - i will post again shortly and see if it helps me resolve the issue :)
annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 13
i got it! thanks - i typo when i added the new line to the class pathi had/sysapp/appFodlerinstead of /sysapp/appFolderhowever i typed it right when i put it on the board - THANKS! CHEERS
annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 14
btw - the link was useful too !
annie613a at 2007-7-13 18:02:16 > top of Java-index,Java Essentials,Java Programming...
# 15

> i got it! thanks - i typo when i added the new line

> to the class path

>

> i had

>

> /sysapp/appFodler

>

> instead of /sysapp/appFolder

>

> however i typed it right when i put it on the board -

>

> THANKS! CHEERS

Hmm, good! I was beginning to think that I don't know anything about J2EE.

aniseeda at 2007-7-20 23:04:56 > top of Java-index,Java Essentials,Java Programming...
# 16

I'm new to JNDI and I was trying to set up a JDBC Connection Pool with JNDI according to the example illustrated here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

When I tried the JDBC via Connection Pool , on the Command Line I got this error too:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file

After scratching my head for a long time, I figured... hmm JNDI is set inside Tomcat's server.xml Context - so by running a JNDI example from the command line , how will my small application see what's in Tomcat's server.xml ?

The only way I was able to fix this error was to run my JDBC JNDI test from inside a web application in Tomcat.

If I tried to run the example independent of Tomcat it wouldn't work !

D'uh :-)

appy77a at 2007-7-20 23:04:56 > top of Java-index,Java Essentials,Java Programming...