0

目前我有一个 Java J2SE 客户端,它在会话 EJB 中调用两个方法。一种方法 (EJB.test()) 有效,而另一种 EJB.create() 无效。

看起来像这样的代码

Properties props = new Properties();
props.load(new FileInputStream("jndi.properties"));
InitialContext ctx = new InitialContext(props);

BeanRemote EJB = (BeanRemote) ctx.lookup("stateless.pack.BeanRemote");
System.out.println(EJB.test()); //Method works

Testobj t = new Testobj();
t.setName("User");  
EJB.create(t);   //Doesnt Work . This is the remote version. When tried through the local version using servlet of the Enterprise App it works.

EJB 实现是

@Stateless
public class Bean implements BeanLocal,BeanRemote
{
    public @PersistenceContext(unitName="emp")   EntityManager manager;

    @Override
    public String test() 
    { return "test123";}

    @Override
    public Testobj create(Testobj cust) 
    {        manager.persist(cust);
             return cust;
    }
   .....
   .....
}

我得到错误

Jul 21, 2012 9:16:23 AM com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator handleFullLogging
WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream
org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream  vmcid: OMG  minor code: 11 completed: Maybe
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
    at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:95)
    at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.handleFullLogging(WrapperGenerator.java:387)
    at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.access$400(WrapperGenerator.java:107)
    at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator$2.invoke(WrapperGenerator.java:511)
    at com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:99)
    at $Proxy24.valuehandlerReadException(Unknown Source)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:1022)
    at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1123)
    at com.sun.corba.ee.impl.encoding.CDRInputObject.read_value(CDRInputObject.java:531)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:2162)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2404)
    at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1224)
    at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:425)
4

1 回答 1

0

您必须定义一个接口并使用@Remote 对其进行注释并让EJB 实现这样的接口。

于 2012-08-28T09:05:26.213 回答