[jboss-user] [EJB 3.0] - Basic EJB - cant be invoked from client

r12345_2003 do-not-reply at jboss.com
Thu Apr 3 04:17:53 EDT 2008


Hi,

I am trying to create a simple EJB and deploy to JBoss. The EJB is created and deployed to JBoss successfully. However when i try to invoke it from a standalone client i am unable to do so. I get a javax.naming.CommunicationException: exception.

Following is the code for my EJB Local interface:

  | import javax.ejb.Local;
  | 
  | @Local
  | public interface CalculatorLocal
  | {
  |     public float add(float x, float y);
  | }
  | 
Following is the code for the EJB:

  | import javax.ejb.Local;
  | import javax.ejb.Stateless;
  | 
  | 
  | @Stateless
  | public class CalculatorBean implements CalculatorLocal
  | {
  | 
  |     public float add(float x, float y)
  |     {
  |         return x+y;
  |     }
  | 
  | }
  | 
Following is the code for the client:

  | import javax.naming.InitialContext;
  | 
  | import uk.co.autotrader.ejb3.stateless.CalculatorLocal;
  | 
  | 
  | public class CalculatorClient
  | {
  |     public static void main(String args[]){
  |         try {
  |             InitialContext ic = new InitialContext();
  |             CalculatorLocal calculator = (CalculatorLocal)ic.lookup("CalculatorBean/local");
  |             float total = calculator.add(2F, 5F);
  |             System.out.println("sum is "+total);
  |         }
  |         catch(Exception e){
  |             System.out.println("Exception "+e);
  |         }
  |     }
  | }
  | 
Following is the exception message at the console when the client is run:

  | javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
  | 

I have included the necessary JAR files and also have jndi.properties in my client code class path (After referring http://www.jboss.org/?module=bb&op=viewtopic&t=57223)

I am using JBoss 4.2.2 GA.

Can anyone help?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141189#4141189

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4141189



More information about the jboss-user mailing list