gpt4 book ai didi

java - InitialContext 的 OSGi 和 ClassNotFoundException

转载 作者:行者123 更新时间:2023-12-02 05:51:50 28 4
gpt4 key购买 nike

OSGi 客户端尝试连接到 GF4。在 Maven 中,我添加了 gf-client-module 4。我看到 bundle glassfish-naming-4.0.jar 已安装。

所以在 Activator 中我有。

ClassLoader thatLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
Properties jndiProps = new Properties();
jndiProps.put("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
jndiProps.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
jndiProps.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
jndiProps.setProperty("org.omg.CORBA.ORBInitialHost", "x.x.x.x");
jndiProps.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(jndiProps);
} finally {
Thread.currentThread().setContextClassLoader(thatLoader);
}

这就是我得到的

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]

如何解决? bundle glassfish-naming-4.0.jar 里面有 Activator。我应该开始这个 bundle 吗?我尝试过,但遇到了 Unresolved 约束异常。

解决方案SerialInitContextFactory not found in glassfish naming没有帮助。

最佳答案

我找到了解决方案。据我了解,glassfish-naming、gf-client-module 和其他 osgi 包都是属于 glassfish 的包!如果我想使用 gf-client 我必须这样做:

1) Copy the as-install/lib/gf-client.jar file to the client machine and include it in the classpath on the client side.

The gf-client.jar file references GlassFish Server JAR files in its MANIFEST.MF file. If there is no GlassFish Server installation on the client machine, 2) you must also copy the as-install/modules directory to the client machine and maintain its directory structure relative to the as-install/lib/gf-client.jar file. Or you can use the package-appclient script; see Using the package-appclient Script.

这是来自http://docs.oracle.com/cd/E18930_01/html/821-2418/gkusn.html

关于java - InitialContext 的 OSGi 和 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23464424/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com