如何从客户端调用远程ejb

时间:2014-09-13 16:07:39

标签: java java-ee netbeans glassfish ejb

客户端应用程序在EJB上进行远程调用时,是否需要本地接口,或者是否使用远程接口客户端和EJB通用吗?

当我尝试关注Netbeans tutorial时,我收到了一个错误,即我通过调用EJB解决了selected bean is not in the same module or enterprise application

    Context ic = new InitialContext();
    Object o = ic.lookup("java:global/RemoteSalutation-ejb/MyRemoteSessionClass!net.bounceme.dur.glassfish.MyRemoteSession");

至少推动了这个问题 - 我不相信潜在的问题已经解决了。 Netbeans拒绝插入对Enterprise Bean的调用意味着存在更深层次的问题。编组或坏的param,或者不可序列化对我来说意味着我在设置EJB模块,glasfish或JNDI时出错了。所有这些,还是只有一个?

以下是整体组织:

RemoteLookup /

├── build.xml
├── nbproject
│   ├── ant-deploy.xml
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── private
│   │   ├── private.properties
│   │   └── private.xml
│   ├── project.properties
│   └── project.xml
├── src
│   ├── conf
│   │   ├── application-client.xml
│   │   └── MANIFEST.MF
│   └── java
│       ├── jndi.properties
│       └── net
│           └── bounceme
│               └── dur
│                   └── remote
│                       ├── MyProps.java
│                       └── RemoteLookup.java
└── test

RemoteSalutation /

├── build.xml
├── nbproject
│   ├── ant-deploy.xml
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── private
│   │   ├── private.properties
│   │   └── private.xml
│   ├── project.properties
│   └── project.xml
├── RemoteSalutation-ejb
│   ├── build.xml
│   ├── nbproject
│   │   ├── ant-deploy.xml
│   │   ├── build-impl.xml
│   │   ├── genfiles.properties
│   │   ├── private
│   │   │   ├── private.properties
│   │   │   └── private.xml
│   │   ├── project.properties
│   │   └── project.xml
│   └── src
│       ├── conf
│       │   └── MANIFEST.MF
│       └── java
│           └── net
│               └── bounceme
│                   └── dur
│                       └── glassfish
│                           └── MyRemoteSessionClass.java
└── src
    └── conf
        └── MANIFEST.MF

EJBRemoteInterface /

├── build.xml
├── nbproject
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── private
│   │   └── private.properties
│   ├── project.properties
│   └── project.xml
└── src
    └── net
        └── bounceme
            └── dur
                └── glassfish
                    └── MyRemoteSession.java

堆栈跟踪:

run-deploy:

-as-retrieve-option-workaround:
     [copy] Copying 1 file to /home/thufir/NetBeansProjects/RemoteLookup/dist
     [copy] Copying 2 files to /home/thufir/NetBeansProjects/RemoteLookup/dist/RemoteLookupClient
     [copy] Warning: /home/thufir/NetBeansProjects/RemoteLookup/dist/gfdeploy/RemoteLookup does not exist.

-init-run-macros:

-run-pregfv3:

-run:
     [java] Sep 13, 2014 9:03:09 AM net.bounceme.dur.remote.RemoteLookup run
     [java] INFO: java.naming.factory.initial   com.sun.enterprise.naming.impl.SerialInitContextFactory
     [java] Sep 13, 2014 9:03:09 AM net.bounceme.dur.remote.RemoteLookup run
     [java] INFO: java.naming.factory.url.pkgs  com.sun.enterprise.naming
     [java] Sep 13, 2014 9:03:09 AM net.bounceme.dur.remote.RemoteLookup run
     [java] INFO: java.naming.factory.state com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
     [java] Sep 13, 2014 9:03:13 AM net.bounceme.dur.remote.RemoteLookup main
     [java] SEVERE: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.provider.url=server.local:1199, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
     [java] javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.provider.url=server.local:1199, 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]     java.io.NotSerializableException: ----------BEGIN server-side stack trace----------
     [java] org.omg.CORBA.BAD_PARAM: WARNING: 00100006: Class com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate is not Serializable  vmcid: SUN  minor code: 6 completed: Maybe
     [java]     at com.sun.proxy.$Proxy209.notSerializable(Unknown Source)
     [java]     at com.sun.corba.ee.impl.misc.ORBUtility.throwNotSerializableForCorba(ORBUtility.java:783)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_abstract_interface(CDROutputStream_1_0.java:556)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_abstract_interface(CDROutputObject.java:523)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAbstractObject(Util.java:492)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:772)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:847)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:246)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:615)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:197)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:234)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:215)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:179)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:711)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:696)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:821)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:789)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:834)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_value(CDROutputObject.java:500)
     [java]     at com.sun.corba.ee.impl.corba.TCUtility.marshalIn(TCUtility.java:157)
     [java]     at com.sun.corba.ee.impl.corba.AnyImpl.write_value(AnyImpl.java:611)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_any(CDROutputStream_1_0.java:489)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_any(CDROutputObject.java:468)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAny(Util.java:365)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$10.write(DynamicMethodMarshallerImpl.java:306)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.writeResult(DynamicMethodMarshallerImpl.java:488)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:177)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
     [java]     at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
     [java] 
     [java] ----------END server-side stack trace----------]
     [java]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:513)
     [java]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
     [java]     at javax.naming.InitialContext.lookup(InitialContext.java:411)
     [java]     at net.bounceme.dur.remote.RemoteLookup.run(RemoteLookup.java:33)
     [java]     at net.bounceme.dur.remote.RemoteLookup.main(RemoteLookup.java:18)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at java.lang.reflect.Method.invoke(Method.java:606)
     [java]     at org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:446)
     [java]     at org.glassfish.appclient.client.AppClientFacade.main(AppClientFacade.java:166)
     [java] Caused by: java.rmi.MarshalException: CORBA BAD_PARAM 1398079494 Maybe; nested exception is: 
     [java]     java.io.NotSerializableException: ----------BEGIN server-side stack trace----------
     [java] org.omg.CORBA.BAD_PARAM: WARNING: 00100006: Class com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate is not Serializable  vmcid: SUN  minor code: 6 completed: Maybe
     [java]     at com.sun.proxy.$Proxy209.notSerializable(Unknown Source)
     [java]     at com.sun.corba.ee.impl.misc.ORBUtility.throwNotSerializableForCorba(ORBUtility.java:783)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_abstract_interface(CDROutputStream_1_0.java:556)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_abstract_interface(CDROutputObject.java:523)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAbstractObject(Util.java:492)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:772)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:847)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:246)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:615)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:197)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:234)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:215)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:179)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:711)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:696)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:821)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:789)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:834)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_value(CDROutputObject.java:500)
     [java]     at com.sun.corba.ee.impl.corba.TCUtility.marshalIn(TCUtility.java:157)
     [java]     at com.sun.corba.ee.impl.corba.AnyImpl.write_value(AnyImpl.java:611)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_any(CDROutputStream_1_0.java:489)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_any(CDROutputObject.java:468)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAny(Util.java:365)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$10.write(DynamicMethodMarshallerImpl.java:306)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.writeResult(DynamicMethodMarshallerImpl.java:488)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:177)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
     [java]     at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
     [java] 
     [java] ----------END server-side stack trace----------
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:300)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:211)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:226)
     [java]     at com.sun.enterprise.naming.impl._SerialContextProvider_DynamicStub.lookup(com/sun/enterprise/naming/impl/_SerialContextProvider_DynamicStub.java)
     [java]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:478)
     [java]     ... 10 more
     [java] Caused by: java.io.NotSerializableException: ----------BEGIN server-side stack trace----------
     [java] org.omg.CORBA.BAD_PARAM: WARNING: 00100006: Class com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate is not Serializable  vmcid: SUN  minor code: 6 completed: Maybe
     [java]     at com.sun.proxy.$Proxy209.notSerializable(Unknown Source)
     [java]     at com.sun.corba.ee.impl.misc.ORBUtility.throwNotSerializableForCorba(ORBUtility.java:783)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_abstract_interface(CDROutputStream_1_0.java:556)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_abstract_interface(CDROutputObject.java:523)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAbstractObject(Util.java:492)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:772)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:847)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:246)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:615)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:197)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:234)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:215)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:179)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:711)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:696)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:821)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:789)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:834)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_value(CDROutputObject.java:500)
     [java]     at com.sun.corba.ee.impl.corba.TCUtility.marshalIn(TCUtility.java:157)
     [java]     at com.sun.corba.ee.impl.corba.AnyImpl.write_value(AnyImpl.java:611)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_any(CDROutputStream_1_0.java:489)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_any(CDROutputObject.java:468)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAny(Util.java:365)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$10.write(DynamicMethodMarshallerImpl.java:306)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.writeResult(DynamicMethodMarshallerImpl.java:488)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:177)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
     [java]     at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
     [java] 
     [java] ----------END server-side stack trace----------
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:292)
     [java]     ... 15 more
     [java] Caused by: org.omg.CORBA.BAD_PARAM: ----------BEGIN server-side stack trace----------
     [java] org.omg.CORBA.BAD_PARAM: WARNING: 00100006: Class com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate is not Serializable  vmcid: SUN  minor code: 6 completed: Maybe
     [java]     at com.sun.proxy.$Proxy209.notSerializable(Unknown Source)
     [java]     at com.sun.corba.ee.impl.misc.ORBUtility.throwNotSerializableForCorba(ORBUtility.java:783)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_abstract_interface(CDROutputStream_1_0.java:556)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_abstract_interface(CDROutputObject.java:523)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAbstractObject(Util.java:492)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:772)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:847)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:246)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:615)
     [java]     at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:197)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:234)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:215)
     [java]     at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:179)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.callWriteValue(CDROutputStream_1_0.java:711)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:696)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:821)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:789)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:834)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_value(CDROutputObject.java:500)
     [java]     at com.sun.corba.ee.impl.corba.TCUtility.marshalIn(TCUtility.java:157)
     [java]     at com.sun.corba.ee.impl.corba.AnyImpl.write_value(AnyImpl.java:611)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_any(CDROutputStream_1_0.java:489)
     [java]     at com.sun.corba.ee.impl.encoding.CDROutputObject.write_any(CDROutputObject.java:468)
     [java]     at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.writeAny(Util.java:365)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$10.write(DynamicMethodMarshallerImpl.java:306)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.writeResult(DynamicMethodMarshallerImpl.java:488)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:177)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
     [java]     at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
     [java]     at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
     [java]     at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
     [java] 
     [java] ----------END server-side stack trace----------  vmcid: SUN  minor code: 6 completed: Maybe
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
     [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
     [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
     [java]     at com.sun.corba.ee.impl.protocol.giopmsgheaders.MessageBase.getSystemException(MessageBase.java:813)
     [java]     at com.sun.corba.ee.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:131)
     [java]     at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.getSystemExceptionReply(MessageMediatorImpl.java:594)
     [java]     at com.sun.corba.ee.impl.protocol.ClientRequestDispatcherImpl.processResponse(ClientRequestDispatcherImpl.java:519)
     [java]     at com.sun.corba.ee.impl.protocol.ClientRequestDispatcherImpl.marshalingComplete(ClientRequestDispatcherImpl.java:393)
     [java]     at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.invoke(ClientDelegateImpl.java:272)
     [java]     at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:198)
     [java]     ... 14 more
     [java] 

run:

BUILD SUCCESSFUL
Total time: 19 seconds
thufir@dur:~/NetBeansProjects/RemoteLookup$ 

从初始上下文中查找bean:

package net.bounceme.dur.remote;

import java.util.Enumeration;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class RemoteLookup {

    private static final Logger log = Logger.getLogger(RemoteLookup.class.getName());
    private final MyProps p = new MyProps();

    public static void main(String... args) {
        try {
            new RemoteLookup().run();
        } catch (NamingException ex) {
            Logger.getLogger(RemoteLookup.class.getName()).log(Level.SEVERE, ex.getExplanation(), ex);
        }
    }

    private void run() throws NamingException {
        Properties jndi = p.getJNDI();
        Enumeration e = jndi.propertyNames();
        while (e.hasMoreElements()) {
            String key = (String) e.nextElement();
            String val = jndi.getProperty(key);
            log.info(key + "\t" + val);
        }
        Context ic = new InitialContext();
        Object o = ic.lookup("java:global/RemoteSalutation-ejb/MyRemoteSessionClass!net.bounceme.dur.glassfish.MyRemoteSession");
    }
}

豆本身:

package net.bounceme.dur.glassfish;

import javax.ejb.Stateless;

//@LocalBean
@Stateless(mappedName = "salutationBean")
public class MyRemoteSessionClass implements MyRemoteSession {

    @Override
    public String SayHello() {
        return "hello from glassfish..";
    }

    @Override
    public String SayBye() {
        return "goodbye..";
    }
}

此bean实现MyRemoteSession,它也位于客户端应用程序的类路径中。我需要第二个本地界面吗?

0 个答案:

没有答案