'Java Application Running in PASE env on Ibmi - Initial Context Error
I have a basic java application that looks up a data source.
I am new to this, especially when it is running on the IBMi. ANy thoughts of what/where to look?
I know this is a vague question.
Where would someone "put" the class name the error is mentioning?
I have looked for the declaration of the jndi name on the area of the ibmi that i have access to, but cannot find it....
{
InitialContext ctx = new InitialContext();
ctx.lookup("java:comp/env/configdb");
}
It imediately throws this error:
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
jndi.properties:
# jndi.properties: Defines JNDI properties for standalone Java
java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
java.naming.provider.url=file:/Applications/dev/jndi
and the dev/jndi/.bindings directory has a whole bunch of stuff in it like this:
configdb/RefAddr/35/Type=secondary URL
configdb/ClassName=com.ibm.as400.access.AS400JDBCManagedDataSource
Solution 1:[1]
Try specifying the context factory in your code like this:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
Context ctx = new InitialContext(env);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
