GlassFish 3.1 中客户端的 ctx.lookup() 时出现 CommunicationException

发布于 2024-11-05 09:01:34 字数 857 浏览 1 评论 0原文

我有一个实现可序列化的实体类,我在客户端上收到此错误:

javax.naming.CommunicationException: 通讯异常 SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [根异常是 java.rmi.MarshalException:CORBA BAD_PARAM 1398079494 也许;嵌套的 例外是: java.io.NotSerializedException: ----------开始服务器端堆栈跟踪---------- org.omg.CORBA.BAD_PARAM:警告: IOP00100006:类 com.sun.ejb.containers.EJBLocalObjectInitationHandlerDelegate vmcid 不可序列化:SUN 次要 代码:6 完成:也许

当我在做时 SomeService serv = (SomeService)ctx.lookup("java:global/MyProject/SomeServiceImpl");

实体类是否应该位于同一个包中服务器和客户端? 现在实体类位于客户端应用程序的包(dir)和服务器上SomeService接口所在的包(dir)中。

I have one entity class which implements Serializable and I got this error on client:

javax.naming.CommunicationException:
Communication exception for
SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.url.pkgs=com.sun.enterprise.naming,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
[Root exception is
java.rmi.MarshalException: CORBA
BAD_PARAM 1398079494 Maybe; nested
exception is:
java.io.NotSerializableException:
----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_PARAM: WARNING:
IOP00100006: Class
com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate
is not Serializable vmcid: SUN minor
code: 6 completed: Maybe

when I'm doing SomeService serv = (SomeService)ctx.lookup("java:global/MyProject/SomeServiceImpl");

Does Entity class should be in the same package both in server and in client?
Now Entity class is in the package (dir) of Client App and in the package (dir) where SomeService interface is on the server.

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

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

发布评论

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

评论(2

南…巷孤猫 2024-11-12 09:01:34

我向服务接口添加了 @Remote 注释,错误消失了。

I added @Remote annotation to service interface and error disapeared.

兔姬 2024-11-12 09:01:34

我尝试了以下操作,一切正常。

创建InitialContext时为:

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

InitialContext ctx = new InitialContext(props);

后来,

myBeanService = (MyBeanService) ctx.lookup("java:global/AppName/MyBeanService");

显示了该异常,但如果我只是这样调用:

myBeanService = (MyBeanService) new InitialContext().lookup("java:global/AppName/MyBeanService");

没有问题。问题在于 JNDI 属性。

I tried the following and everything works Ok.

When creating InitialContext as:

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

InitialContext ctx = new InitialContext(props);

And later,

myBeanService = (MyBeanService) ctx.lookup("java:global/AppName/MyBeanService");

Shows that exception, but if I just call this way:

myBeanService = (MyBeanService) new InitialContext().lookup("java:global/AppName/MyBeanService");

There is no problem. The problem are the JNDI properties.

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