2

I've got a session bean, defined in an ejb-jar.xml and jboss.xml. It's defined with an ejb-name, remote and home interface and an implementation.

When I fire up JBoss and view the JNDI tree the home interface seems to be there under the JNDI name of the ejb-name (I've tried defining jndi-name and local-jndi-name in the ejb-jar.xml with no apparent effect). But the remote interface does not appear in the JNDI listing.

If I try and access the ejb-name with a JNDI lookup from a JUnit TestCase things get messy, presumably because I'm accessing a home interface.

Any ideas what I'm likely to be missing? Thanks in advance.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
rich
  • 18,987
  • 11
  • 75
  • 101
  • Not familiar with JBoss myself, but 2 links I can point are http://jaitechwriteups.blogspot.com/2006/07/accessing-secure-ejb-through.html and http://community.jboss.org/thread/31861?tstart=0 – JoseK Aug 05 '10 at 13:05

1 Answers1

3
  1. package the home and remote interfaces into a client jar and put it on the client classpath

  2. put the jboss-client.jar on the client classpath

  3. put a jndi.properties file with the following content on the client classpath

    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    java.naming.provider.url=jnp://localhost:1099
    
  4. perform a lookup on the JNDI name of the remote interface (something like this by default with JBoss)

    Context c = new InitialContext();
    return (Echo) c.lookup("EchoBean/remote"); // use myEarName/HelloWorldBean/remote in an ear
    
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124