在 Ibmi 上的 PASE env 中运行的 Java 应用程序 - 初始上下文错误

发布于 2025-01-18 07:59:40 字数 905 浏览 3 评论 0原文

我有一个基本的Java应用程序,可以查找数据源。
我是新手,尤其是在IBMI上运行时。有什么想法/在哪里看? 我知道这是一个模糊的问题。 有人在哪里“放”该错误要提及的班级名称? 我可以访问但找不到的IBMI区域上的JNDI名称的

{
       InitialContext ctx = new InitialContext();
        ctx.lookup("java:comp/env/configdb");
} 

我已经在

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: Defines JNDI properties for standalone Java
java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
java.naming.provider.url=file:/Applications/dev/jndi

声明 这样的一堆东西:

configdb/RefAddr/35/Type=secondary URL                                    
configdb/ClassName=com.ibm.as400.access.AS400JDBCManagedDataSource   

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   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半城柳色半声笛 2025-01-25 07:59:41

尝试在代码中指定上下文工厂,如下所示:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, 
    "com.sun.jndi.fscontext.RefFSContextFactory");

Context ctx = new InitialContext(env);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文