无法实例化类:com.ibm.Websphere.naming.WsnInitialContextFactory

发布于 2024-12-20 08:04:30 字数 746 浏览 1 评论 0原文

我必须将一个 Web 应用程序从 AIX 移植到 Windows 服务器,但它在 Windows 中新安装的 IBM WebSphere Community Edition 上抛出了类似的异常,如下所示:

javax.servlet.ServletException: javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory in classloader...

跟踪代码并确定是由以下代码引起的:

    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
    Context jdbcCtx = new InitialContext(env);  

AIX Websphere 是完整的WebSphere应用服务器,而Windows版本是社区版。我不确定有什么区别(如果有的话)。

任何人都可以帮忙解决这个问题吗?谢谢!

I have to port a web application from AIX to windows server, but it throws exception like his on the newly installed IBM WebSphere Community Edition in windows like this:

javax.servlet.ServletException: javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory in classloader...

Tracing the code and nailed down to be caused by this code:

    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
    Context jdbcCtx = new InitialContext(env);  

The AIX Websphere is the full WebSphere Application Server while the windows one is Community Edition. I'm not sure what differences if any.

Can anyone help to to fix that? Thanks!

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

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

发布评论

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

评论(2

木森分化 2024-12-27 08:04:30

WebSphere Application Server Community Edition 并不是真正的 WebSphere 应用程序服务器。它是一个“拉皮条的”Apache Geronimo。

我不会指望在 Community Edition 中看到 AIX WebSphere 中存在的任何 IBM 类。

我猜你的选择是:

  • 扔掉所有 IBM 特有的东西。
  • 至少获取 Express 版本。

检查WAS 版本比较

The WebSphere Application Server Community Edition isn't a real WebSphere application server. Its a "pimped" Apache Geronimo.

I wouldn't count on seeing any IBM classes in the Community Edition that where present in your AIX WebSphere.

I guess your options are:

  • Throw everthing IBM specific out.
  • Get at least the Express Edition.

Check the WAS edition comparison.

我很OK 2024-12-27 08:04:30

com.ibm.websphere.naming.WsnInitialContextFactory 是 WebSphere Application Server 特定的类。

正如 Udo 和其他人所说,WebSphere Community Edition 是一个完全不同的产品。

您不仅将运行时操作系统从 AIX 更改为 Windows,而且还将运行时引擎更改为另一个提供商。

如果应用程序包含这样的特定于您的情况下的运行时 (WAS) 的代码,那么当将它们移植到另一个 Java EE 容器(在本例中为 WASCE,它实际上基于 Apache Geronimo)时,它们显然将无法工作服务器)。

正如 Udo 提到的,现在不需要在代码中显式声明 InitialContextFactory 提供程序。在 5-6 年前,应用程序开发人员必须明确说明这些内容。如果您正在查看由同一服务器托管的 JNDI 服务器中的对象,则无需声明这一点。

当您在 WAS CE 上运行并查看在另一个 WAS 上运行的 JNDI 服务器(常规 IBM WAS 不是 CE)时,这是必需的,那么该代码确实是必需的,并且您需要确保这些类存在于您的 WAS CE 中运行时CLASSPATH

com.ibm.websphere.naming.WsnInitialContextFactory is WebSphere Application Server specific class.

As stated by Udo and others, WebSphere Community Edition is a different product altogether.

You have not only changed the run time OS from AIX to Windows but have changed the run time engine to another provider.

If the application contained code like this which is specific to the run time (WAS) in your case, then they will obviously not work when they are ported to another Java EE container (in this case WAS- CE which is actually based on Apache Geronimo Server).

As mentioned by Udo, there is no need to explicitly state the InitialContextFactory provider in the code these days. This used to be true in the past 5-6 years ago where the application developers had to explicitly state these. If you are looking at an object in a JNDI server which is hosted by the same server, there is no need to state this.

It is required when you run on WAS CE and looking at the JNDI server that is running on another WAS (regular IBM WAS not a CE )then this code is indeed required and you would need to ensure that those classes are present in your WAS CE run time CLASSPATH.

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