geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ying Tang <yingtang1...@gmail.com>
Subject Re: JNDI in Geronimo 2
Date Tue, 10 Mar 2009 04:20:54 GMT
Hi Russell,

I tried your example on Geronimo 2.1.4.

1. I renamed the implementation class  as FirstObjectBean.  A bit different
from your code:
---------------------------------------------------****

@Stateless

*public* *class* *FirstObjectBean* *implements* *FirstObjectRemote* { import
**

*   public* *String* *hello*(*String* name){

                  *return* "Hello " + name;

   }
}
---------------------------------------------------

2.  In the application client that referece the EJB, I used
---------------------------------------------------
*import ejb.FirstObjectRemote;*
...
*FirstObjectRemote* firstObject = (*FirstObjectRemote*)context.*lookup*("
FirstObjectBeanRemote");
---------------------------------------------------
3. Add the EJB project to the build path of the application client project.
4. Add the two projects to the Geronimo server, and run the application
client.

The application works well and the "Hello Russel" message shows up.

For more detailed information, please refer to:
http://cwiki.apache.org/confluence/display/GMOxDOC22/Deploying+and+running+EJB+application+clients

Hope this helps.


Best Regards,

Ying Tang  (Sophia)


2009/3/9 Russell Collins <Russell.Collins@mclaneat.com>

>  Hello.  I am new to the list, new to EJB 3.0 and new to Geronimo 2.  I am
> pretty sure I understand all of the concepts but I am having an issue with a
> JNDI lookup in Geronimo.  I have created a Bean and it looks as follows.
>
>
>
> Interface:
>
>
>
> @Remote
>
> *public* *interface* *FirstObjectRemote* {
>
>       *public* *String* *hello*(*String* name);
>
> }
>
>
>
> Class:
>
>
>
> @Stateless
>
> *public* *class* *FirstObject* *implements* *FirstObjectRemote* {
>
>
>
>    *public* *FirstObject*() {
>
>    }
>
>
>
>    @Override
>
> *   public* *String* *hello*(*String* name){
>
>                   *return* "Hello " + name;
>
>    }
>
>
>
> }
>
>
>
> Everything deploys just fine (at lease I think it does).  I created a test
> class:
>
>
>
>
>
> *public* *class* *TheClass*
>
> {           **
>
> *public* *static* *void* *main*(*String*[] args)
>
>       {
>
>             *Properties* prop=*new* *Properties*();
>
>             prop.*put*(*Context*.*INITIAL_CONTEXT_FACTORY*,
> "org.apache.openejb.client.RemoteInitialContextFactory");
>
>             prop.*put*(*Context*.*PROVIDER_URL*, "ejbd://localhost:1099");
>
>
>
>             *try*{
>
>                   *Context* context = *new* *InitialContext*(prop);
>
>                   *FirstObjectRemote* firstObject = (*FirstObjectRemote*
> )context.*lookup*("FirstObjectRemote");
>
>                   *System*.*out*.*println*(firstObject.*hello*("Russell"
> ));
>
>             }
>
>             *catch*(*Exception* ex){
>
>                   *System*.*out*.*println*(ex.*toString*());
>
>             }
>
>
>
>       }
>
> }
>
>
>
>
>
> I get an error I when trying to run this.  The error that comes back is:
>
>
>
>
>
> *javax.naming.NamingException*: Cannot lookup '/FirstObjectRemote'. [Root
> exception is *java.rmi.RemoteException*: Error while communicating with
> server: ; nested exception is:
>
>       java.lang.NoClassDefFoundError: javax/transaction/RollbackException]
>
>
>
>
>
>
>
> What am I missing?
>

Mime
View raw message