facebook

working with ejb3 and jboss in eclipse

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #253965 Reply

    paata_lom
    Member

    fierst of all sorry for my english :).
    1.Eclipse Version: 3.1.0
    2.jboss-4.0.4.GA
    3.Ejb 3.0

    there is my simple example :
    1.Remote Interface

    
    package org.jboss.tutorial.stateless.bean;
    
    import javax.ejb.Remote;
    
    @Remote
    public interface CalculatorRemote {
       public int add(int x, int y);
       public int subtract(int x, int y);
    }
    

    2.Local Interface

    
    package org.jboss.tutorial.stateless.bean;
    import javax.ejb.Local;
    
    @Local
    public interface CalculatorLocal extends CalculatorRemote
    {
       public int add(int x, int y);
       public int subtract(int x, int y);
    }
    

    3.Bean

    
    package org.jboss.tutorial.stateless.bean;
    import javax.ejb.Stateless;
    import org.jboss.tutorial.stateless.bean.CalculatorRemote;
    
    public @Stateless
    class CalculatorBean implements CalculatorRemote {
       public int add(int x, int y) {
          return x + y;
       }
       public int subtract(int x, int y) {
          return x - y;
       }
    }
    

    4. and Client

    
    package org.jboss.tutorial.stateless.client;
    
    import org.jboss.tutorial.stateless.bean.CalculatorRemote;
    import javax.naming.InitialContext;
    
    public class Client
    {
       public static void main(String[] args) throws Exception
       {
          InitialContext ctx = new InitialContext();
          CalculatorRemote calculator = (CalculatorRemote) ctx.lookup("CalculatorBean/remote");
          System.out.println("1 + 1 = " + calculator.add(1, 1));
          System.out.println("1 - 1 = " + calculator.subtract(1, 1));
       }
    }
    

    then in eclipse ide i did project jar file using export and copy it in the
    jboss_home/server/all/deploy folder
    then start jboss from eclipse
    when i’m running client a get an error like that :

    Exception in thread “main” javax.naming.NameNotFoundException: CalculatorBean not bound

    is there enything wrong ?

    #254102 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev

    #254151 Reply

    zambizzi
    Member

    Yes, you’ve made a syntactical error.

    When looking the bean up via JNDI you need to specify EarProjectName/BeanName/local (or remote in your case).

    Try this:
    InitialContext ctx = new InitialContext();
    CalculatorRemote calculator = (CalculatorRemote) ctx.lookup(“MyEarProjectName/CalculatorBean/remote”);

    Substitute “MyEarProjectName” with the name of your enterprise project.

    Also, why does your local interface derive from your remote interface? You should use just one or the other on the bean implementation.

    HTH

    -v

    #254294 Reply

    maheshdss
    Member

    HI ,
    What you said i have done the same thing but still i m facing the same problem.

    Step 1:

    InitialContext ctx = new InitialContext();
    Calculator calculator = (Calculator) ctx.lookup(“CalculatorBean/remote”);

    System.out.println(“1 + 1 = ” + calculator.add(1, 1));
    System.out.println(“1 – 1 = ” + calculator.subtract(1, 1));

    i got following error :
    run:
    [java] Exception in thread “main” javax.naming.NameNotFoundException: CalculatorBean not bound
    [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
    [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
    [java] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
    [java] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java] at java.lang.reflect.Method.invoke(Method.java:585)
    [java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    [java] at sun.rmi.transport.Transport$1.run(Transport.java:153)
    [java] at java.security.AccessController.doPrivileged(Native Method)
    [java] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    [java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    [java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    [java] at java.lang.Thread.run(Thread.java:595)
    [java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    [java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    [java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
    [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
    [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
    [java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
    [java] at client.Client.main(Client.java:33)
    [java] Java Result: 1

    Step 2:

    InitialContext ctx = new InitialContext();
    Calculator calculator = (Calculator) ctx.lookup(“sampleproject/CalculatorBean/remote”);

    System.out.println(“1 + 1 = ” + calculator.add(1, 1));
    System.out.println(“1 – 1 = ” + calculator.subtract(1, 1));

    then i got following error :
    run:
    [java] Exception in thread “main” javax.naming.NameNotFoundException: sampleproject not bound
    [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
    [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
    [java] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
    [java] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java] at java.lang.reflect.Method.invoke(Method.java:585)
    [java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
    [java] at sun.rmi.transport.Transport$1.run(Transport.java:153)
    [java] at java.security.AccessController.doPrivileged(Native Method)
    [java] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
    [java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
    [java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
    [java] at java.lang.Thread.run(Thread.java:595)
    [java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    [java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
    [java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
    [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
    [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
    [java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
    [java] at client.Client.main(Client.java:33)
    [java] Java Result: 1

    Here i have made sampleproject.jar file and uploaded on all/deploy folder.

    Please suggest me.

    #281967 Reply

    prasadsagala
    Member

    hi to all,
    I am also getting the same problem as u explained above…..can any body help me be out the above problem…..if u got solution to the above problem plz send me a mail or reply to the post…

    Thanks in Advance
    Prasad Sagala (sagala.prasad@yahoo.co.in)

    #284293 Reply

    fjefeoi
    Member

    This message has not been recovered.

    #284296 Reply

    fjefeoi
    Member

    This message has not been recovered.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: working with ejb3 and jboss in eclipse

You must be logged in to post in the forum log in