geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell Collins <Russell.Coll...@mclaneat.com>
Subject RE: JNDI in Geronimo 2
Date Fri, 13 Mar 2009 03:00:21 GMT
Thanks for the suggestion.  I will probably end up doing just that in a week or so.



From: Ying Tang [mailto:yingtang1983@gmail.com]
Sent: Thursday, March 12, 2009 9:14 PM
To: user@geronimo.apache.org
Subject: Re: JNDI in Geronimo 2

Hi Russell,

  As you mentioned that you couldn't reinstall the Geronimo Eclipse Plugin after removing
it from Eclipse,  we'd suggest you give up this Eclipse instance, and start from a clean Ganymede
SR1.


Best Regards,

Ying Tang

2009/3/12 Russell Collins <Russell.Collins@mclaneat.com<mailto:Russell.Collins@mclaneat.com>>

I finally got this to work.  The main issue that I was running into was the configuration
of the project.  The main culprit was OpenEJB.  Here are my two main observations on this
journey.



1.    OpenEJB - In the tutorial (and many other posts including Rex's) it says that in order
for the application to be able to establish a remote connection to the application server
the OpenEJB assembly needs to be added to the classpath.  In most of these posts, there is
a link to the OpenEJB site.  So I went to this site and downloaded the latest assembly that
was there.  In this case it is OpenEJB 3.1.  Upon further investigation, Rex along with a
different post caused me to search for and retrieve the OpenEJB assembly from the application
server.  So while I had an OpenEJB assembly in the classpath, it was obviously incompatible
with the version associated with the Application Server.  When I replaced version 3.1 with
3.0, things started changing for the better.



2.    After updating the classpath with the correct version of the OpenEJB client, I had to
backtrack all of the different ways in which I tried to call the remote beans.  I did not
see this posted anywhere so I didn't know this until everything started coming together. 
I had a class called CountryCapitalBean and a Remote interface called CountryCapital.  By
default, Geronimo creates a JNDI entry  that is of the format {BeanName}Remote.  I don't know
if it is viewable on the console, but it is on the deployment logs.  In this example, the
JNDI entry is called called CountryCapitalBeanRemote.  When I change the name of the bean
by saying @Stateless (name="TheBean"), the JNDI entry ends up being TheBeanRemote.



Thanks to everyone that helped and welcomed me to the community.





From: Russell Collins
Sent: Wednesday, March 11, 2009 6:10 PM

To: 'user@geronimo.apache.org<mailto:user@geronimo.apache.org>'
Subject: RE: JNDI in Geronimo 2



Ok, I finally got my environment to work again and I am having the same problems.  I use the
example exactly the way it is and I am getting the same errors.  This is the stack trace



java.lang.RuntimeException: Invalid response from server: -1

      at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:292)

      at javax.naming.InitialContext.lookup(Unknown Source)

      at appclient.ApplicationClient.main(ApplicationClient.java:32)



From: Russell Collins
Sent: Wednesday, March 11, 2009 11:11 AM
To: 'user@geronimo.apache.org<mailto:user@geronimo.apache.org>'
Subject: RE: JNDI in Geronimo 2



I want to thank you Wang, Tang and everyone else who has helped me.  I have tried everyone's
suggestions and have even ran through the tutorial exactly the way it is on the site with
no success.  This leads me to believe that there is something wrong with my installation of
Ganymede.  I have since cleaned out all of the plug-ins associated with the Geronimo App Server.
 Upon trying to reinstall the plug-ins, I got errors saying that it could not be installed.
 I will need to figure out what is wrong before I can continue.  I think that once I have
those environment issues worked out, I will be fine.  I will keep you guys posted.







From: Rex Wang [mailto:rwonly@gmail.com<mailto:rwonly@gmail.com>]
Sent: Tuesday, March 10, 2009 9:45 PM
To: user@geronimo.apache.org<mailto:user@geronimo.apache.org>
Subject: Re: JNDI in Geronimo 2



BTW
you should add
repository\org\apache\openejb\openejb-client\3.0\openejb-client-3.0.jar
to your client's build path.


Rex

2009/3/11 Rex Wang <rwonly@gmail.com<mailto:rwonly@gmail.com>>

Russell, could you provide the whole exception strack?

I can not got your problem.

here is my code:
public class Client {
    public static void main(String[] args) throws Exception {

        try {
            Properties p = new Properties();
            p.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
            p.setProperty("java.naming.provider.url", "ejbd://localhost:4201");

            InitialContext context = new InitialContext(p);

            FirstObjectRemote obj= (FirstObjectRemote) context.lookup("FirstObjectBeanRemote");
            System.out.println(obj.hello("Rex"));

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

I try it with Tang's EJB code as follows:
import javax.ejb.Stateless;

@Stateless
public class FirstObjectBean implements FirstObjectRemote{

        public String hello(String name){
                      return "Hello " + name;
       }
}

import javax.ejb.Remote;

@Remote
public interface FirstObjectRemote {
    public String hello(String name);
}

Rex

2009/3/11 Russell Collins <Russell.Collins@mclaneat.com<mailto:Russell.Collins@mclaneat.com>>



Thank you Wang and Tang.  Here are the things that I have done.



*         Changed the JDK to version 1.5.0_6

*         Updated all of my classes to use this version of Java

*         Changed the provider url to ejbd://localhost:4201



I get the error



java.lang.RuntimeException: Invalid response from server: -1









From: Ying Tang [mailto:yingtang1983@gmail.com<mailto:yingtang1983@gmail.com>]
Sent: Tuesday, March 10, 2009 3:23 AM

To: user@geronimo.apache.org<mailto:user@geronimo.apache.org>
Subject: Re: JNDI in Geronimo 2



Yes,  should be ejbd://localhost:4201. The same as the example in the doc<http://cwiki.apache.org/confluence/display/GMOxDOC22/Deploying+and+running+EJB+application+clients>.

2009/3/10 Rex Wang <rwonly@gmail.com<mailto:rwonly@gmail.com>>

Tang, I believe Russell use a remote client, but not a application client.

to Russell, try "ejbd://localhost:4201"


Rex.

2009/3/10 Ying Tang <yingtang1983@gmail.com<mailto:yingtang1983@gmail.com>>



Hi Russell,

I suggest you use JDK 1.5 instead of 1.6. It is also recommended that Eclipse and Geronimo
use the same Java environment.

Please let me know if there is still any problem.

Best Regards,

Ying Tang

2009/3/10 Russell Collins <Russell.Collins@mclaneat.com<mailto:Russell.Collins@mclaneat.com>>



Thank you Tang.  This should be real strait forward but there has got to be some reason why
this is not working.  Here is the configuration that I have.  This may help in solving this
issue.



Eclipse Ganymede

Java 1.6..0_11

Geronimo 2.1.2

Geronimo 2.1.3 (tried it on both)



There are a couple of other things that I tried that gave me different results.

1.    Added a runtime dependency to the Geronimo Runtime.  This gave me a different error.
 It was a java runtime error that said that the response from the server is: -1

2.    Created a client j2ee application to run my app.



Basically, I am following everything in that link that you sent me.  I am just getting these
errors when trying to look up the object.  Any more insight would be greatly appreciated.





From: Ying Tang [mailto:yingtang1983@gmail.com<mailto:yingtang1983@gmail.com>]
Sent: Monday, March 09, 2009 11:21 PM
To: user@geronimo.apache.org<mailto:user@geronimo.apache.org>
Subject: Re: JNDI in Geronimo 2



Hi Error! Filename not specified.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<mailto: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