NoInitialContextException错误的含义 [英] The meaning of NoInitialContextException error

查看:94
本文介绍了NoInitialContextException错误的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的EJB编写一个客户端,并且在尝试执行该客户端时,出现以下异常:

I am writing a client for my EJB and when trying to execute it, I get the following exception :

javax.naming.NoInitialContextException:需要指定类名 在环境或系统属性中,或作为applet参数,或在 应用程序资源文件.

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

我只是不明白问题是什么.

I just can't understand what the problem is.

推荐答案

javax.naming程序包包含JNDI API.由于它只是一个API,而不是一个实现,因此您需要告诉它要使用哪个JNDI实现.这些实现通常特定于您要与之对话的服务器.

The javax.naming package comprises the JNDI API. Since it's just an API, rather than an implementation, you need to tell it which implementation of JNDI to use. The implementations are typically specific to the server you're trying to talk to.

要指定实现,请在构造InitialContext时传入Properties对象.这些属性指定要使用的实现以及服务器的位置.默认的InitialContext构造函数仅在存在系统属性时才有用,但是这些属性与您手动传递它们时相同.

To specify an implementation, you pass in a Properties object when you construct the InitialContext. These properties specify the implementation to use, as well as the location of the server. The default InitialContext constructor is only useful when there are system properties present, but the properties are the same as if you passed them in manually.

关于需要设置哪些属性,取决于服务器.您需要查找这些设置并将其插入.

As to which properties you need to set, that depends on your server. You need to hunt those settings down and plug them in.

这篇关于NoInitialContextException错误的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆