Reputation: 936
Im was trying to build an example from book Im reading about JBoss 5 (JBoss AS 5 Developmet), however even the code directly from the book simply does not work.
This is my interface:
@Remote
public interface Mailer {
public void sendMail(String aToEmailAddr,
String aSubject, String aBody);
}
This is EJB that implements this interface
@Stateless
@RemoteBinding(jndiBinding="remote/MailerEJB")
public class MailerBean implements Mailer {... }
And this is the client application which tries to lookup the bean.
public class MailClient {
public static void main(String[] args) throws Exception
{
InitialContext ctx = new InitialContext();
Mailer mailer = (Mailer) ctx.lookup("remote/MailerEJB");
}
}
When i try to run MailClient class ive got following exception
Exception in thread "main" javax.naming.NameNotFoundException: remote not bound
I also have jndi.properties file, which I added to the build path, and it looks like this>
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jnp.interfaces
Even in jmx-console I simply cant see remote/MailerEJB Bean.
Im using jboss-5.0.1.GA + JBDS + java 1.7.0
Can somebody help me out ?
Upvotes: 0
Views: 1208
Reputation: 1381
First of all you've to be sure that the EJB is properly deployed in the JBoss and the binding name it's given, so if you can't see the bean in the JNDIView of the JMX Console, it's surely a deployment problem. To be sure that it's correctly deployed you can check the JBoss logs in the moment of deploying the EJB (you ejb-jar or ear), look for a line similar to:
EJBBindingName - EJB3.x Default Remote Business Interface
In your case, if the binding you've defined is correct, it should be:
remote/MailerEJB - EJB3.x Default Remote Business Interface
This line indicates the real JNDI name that is given to the EJB, and it's the one you've to use in your remote calls.
On the other hand, try to remove the line between the annotations and the class definition:
@Stateless
@RemoteBinding(jndiBinding="remote/MailerEJB")
public class MailerBean implements Mailer {... }
Moreover in this post you can find specific instructions about how to make a remote call to an EJB from a simple command line Java program.
Upvotes: 1