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

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

问题描述

我正在为我的 EJB 编写一个客户端,在尝试执行它时,我收到以下异常:

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

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

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天全站免登陆