开发者

ejb client in netbeans platform application module

Im trying to create a ejb Client in Netbean platform appliactaions module, to call ejb deployed in glassfish.

I have added all required jar files from my ejb server application and required glashfish jars. appserv-rt.jar,javaee.jar, gf-client.jar.

Following code works fine when called from standalone java application , but when i try to call it from netbeans platfrom application module , Im unable to get context.

Are there any netbean platform specific configurations required?

 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();
    }


This is not an easy task. Have a look at the this tutorial, its a bit old but should still apply.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜