【问题标题】:ejb client in netbeans platform application modulenetbeans平台应用模块中的ejb客户端
【发布时间】:2011-07-04 15:52:10
【问题描述】:

我试图在 Netbean 平台应用程序模块中创建一个 ejb 客户端,以调用部署在 glassfish 中的 ejb。

我已经从我的 ejb 服务器应用程序中添加了所有必需的 jar 文件和必需的 glashfish jar。 appserv-rt.jar,javaee.jar, gf-client.jar.

以下代码在从独立 java 应用程序调用时工作正常,但是当我尝试从 netbeans platfrom 应用程序模块调用它时,我无法获取上下文。

是否需要任何特定于 netbean 平台的配置?

 try {
       Properties props = new Properties();
       props.setProperty("java.naming.factory.initial", 
                         "com.sun.enterprise.naming.SerialInitContextFactory");

       props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");

       props.setProperty("java.naming.factory.state",
                        "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"
        );

       props.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1");
       props.setProperty("org.omg.CORBA.ORBInitialPort","3700");

       InitialContext ctx = new InitialContext (props);
       MySessionBeanRemote mySessionBean=
                             (MySessionBeanRemote)ctx
                                 .lookup("sessions.MySessionBeanRemote");


      Userprofile user = new Userprofile();
        user.setActive('A');
        user.setDescription("some desc");
        user.setEmail("abc");
        user.setFirstname("xyz");
        user.setLastname("123");
        user.setPassword("pwd");
        user.setStatus("Enabled");
        user.setUserid(Long.valueOf(25));

        user.setUsername("abc");
        mySessionBean.persist(user);
      } catch (javax.naming.NamingException ne) {
        ne.printStackTrace();

    } catch (Exception e) {
        e.printStackTrace();
    }

【问题讨论】:

    标签: ejb netbeans-platform


    【解决方案1】:

    这不是一件容易的事。看看this tutorial,它有点旧,但应该仍然适用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-23
      • 1970-01-01
      • 1970-01-01
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-20
      相关资源
      最近更新 更多