简体   繁体   English

具有远程业务接口和客户端应用程序的EJB

[英]EJB with remote business interface and Client Application

I've created new class library, which contains class: 我创建了新的类库,其中包含类:

class myData {
  private int id
  private Date date;
  private String text

  //...
  //Getters and setters
  //...
}

Then I've created EJB module and SessionBean with remote interface. 然后,我创建了带有远程接口的EJB模块和SessionBean。

@Stateless
public class myBean implements myBeanRemote {
  @Override
  public myData getData() {
    myData md = new myData();

    //...
    //set md data;
    //...

    return md;
  }

  @Override
  public String getMessage() {
    return "Hello";
  }
}

Then I use this bean in my application. 然后,在我的应用程序中使用此bean。

public class myApp {
  @EJB
  private static myBeanRemore mbr;

  public static void main(String[] args) {
    System.out.println( mbr.getMessage() );
    System.out.println( mbr.getData() );
  }
}

EJB runs on GlassFish 4. Bean method getMessage() is working good, problem is with getData() . EJB在GlassFish 4上运行。Bean方法getMessage()运行良好,问题出在getData() I get error: java.lang.reflect.InvocationTargetException . 我收到错误: java.lang.reflect.InvocationTargetException

Where is the point with my custom class myData ? 我的自定义类myData的意义在哪里? Library with myData is included everywhere, in Glassfish libraries too. 带有myData库随处都包含在Glassfish库中。 I tried to change bean creation with InitialContext , but it gives the same results. 我尝试使用InitialContext更改bean的创建,但结果相同。

您的myData类应实现java.io.Serializable接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM