Discussions

Web tier: servlets, JSP, Web frameworks: Howto connect to EJB from applet

  1. Howto connect to EJB from applet (3 messages)

    Hi guys...

    I need to connect to a session bean from a client applet.

    I already have the bean deployed on jboss 3.2.3 and it seems to work nicely. I can access it from a jsp page on the jboss server.

    So the core of my question is: How does my applet find the ejb, since the code is evaluated on the client machine there must be something like a jndi.properties file or so that i have to supply with the appletclass so it find the initialcontext correctly...

    Any pointers to a good tutorial would be sufficient, cause i couldnt find any....

    Thx alot

    Jörg

    P.S.: I know i know.... some of you will start with "Use WebServices" or something like that,... but at the moment i need it to work NOW... in the next project ill consider other solutions...

    Threaded Messages (3)

  2. Hi,

    Just try look at this site it talks something abt the same.

    http://www.huihoo.com/jboss/online_manual/3.0/ch13s21.html

    --Mohit
  3. jndi properties[ Go to top ]

    In the client code, assuming you use Jboss server:

    --------------------------------------------------------

    Properties jndiProps = new Properties() ;
             String myServer = this.getCodeBase().getHost ();
             jndiProps.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" ) ;
             jndiProps.setProperty("java.naming.provider.url", myServer ) ;
             jndiProps.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" ) ;
             TestAppletHome home = (TestAppletHome)PortableRemoteObject.narrow( new InitialContext(jndiProps).lookup( "TestAppletBean" ),
                                                                                TestAppletHome.class) ;
             TestApplet remote = home.create() ;
             ejbMessageLabel.setText( remote.getMessage());

    ----------------

    I have deployed an applet accessing a stateless ejb but I het a socket write exception... if you have got a good tutorial please write me: lalbertazzi@tin.it
  4. jndi properties[ Go to top ]

    how do you test your applet ?
    i had a socket write error too but forgot how i fixed it...