Harley,

If I'm correct the attached files should give you a working example, if not let me 
know. I have not looked at
it for a year, apart from changing the readme format from (UNIX) text to HTML just now 
onder the save
assumption not everybody works on UNIX.

Success,
FE

   

On Monday, April 23, 2001 10:37 PM, Harley Rana [SMTP:[EMAIL PROTECTED]] wrote:
> Hi i have just started out with orion, i can't figure out how to access bean
> from a client. i've followed the Hello-Planet primer and made some changes
> to the bean, repackaged the .ear and redeployed.  Now every thing works fine
> when access the bean from a servlet that is packaged in the .ear file.
> My question is how do you access a bean, from a client not packaged in the
> .ear file?
> 
> Im getting an NamingException usally saying :
> java:comp/env namespace is only available from within a J2EE component
> sometimes saying :
> javax.naming.NamingException: Error reading application-client descriptor:
> No location specified and no suitable instance of the type 'hello.ejb.Hello'
> found for the ejb-ref HelloPlanet
> 
> I do have the application-client.xml file, and if i change details in it i
> see change in message from the second exception type.  so it must be reading
> the .xml file to see the change.
> 
> What do i need to do?
> Could you include code examples please.
> I appreciate any help you can give!
> Thanks, Harley Rana.
>  << File: HelloClient.java >>  << File: hello-planet.ear >> 

Hi,

I've got a simple remote client running. As it took me quite some time, maybe other people might find this example useful to get started.

All this is based on the Orion-Primer of Ernst de Haan. Have a look on his site www.jollem.com for a more detailed explanation of the JSP example before running the remote client.

In the attached archive files you find:

  • the unchanged sources from Ernst,
  • an addapted application.xml file (is that file right?),
  • two extra files: HelloClient.Java and application-client.xml and
  • an addapted build file.

If you have successfully compiled the example as described by Ernst using my sources, you will find a 'orion-primer-client.jar' file in the rel/ directory.

B.T.W. It is fun to see the autodeploy working. Check the log of the server while running 'ant clean' and 'ant'. You'll see the autodeploy picking the file up.

You run the remote client as follows:

  1. Make sure you have a proper java setup on your remote machine.
  2. Copy a jndi.properties file from a orion demo (e.g. the cart demo) to directory X. You'll find it in the directory orion/demo/ejb/cart. Make sure it refers to the server and not localhost.
  3. Copy the following jars from the orion installation dir to directory X: orion.jar, ejb.jar, jndi.jar, jaxp.jar, parser.jar, jdbc.jar, mail.jar.
  4. Copy the orion-primer-client.jar to directory X on your remote machine.
  5. Run the following command: "java -classpath .:orion.jar:ejb.jar:jndi.jar:orion-primer-client.jar hello.client.HelloClient"

If all runs fine you will get some messages on your screen ending with: "Exit cleanly".

HelloClient.java

The code is straightforward, but as it is an example and things can go wrong.

Amongst others:

  • First thing is to get a context. You'll run into trouble here if your jndi.properties are not right.
  • Next step is the get the Home Interface. If the application-client.xml is not right or server does not run (or you point to the wrong server) things will break here.

I guess there are more ways of having fun ...

application-client.xml

The example file is pretty straightforward. It describes under which name you can find the Home Interface, in our case 'ejb/HelloHome'. You have to use that same name in your source file 'HelloClient.java'.

The type of the Bean is of course the same as in the ejb-jar.xml: Session. The other entries in the application-client point to the right Home and Remote interfaces.

classpath / jndi.properties / jars

The '.' in the classpath is necessary to pick up your jndi.properties file. The first three jars mentioned (orion, ejb, and jndi) in the classpath are necessary for the execution environment. The Orion runtime environment will look for the other jars you have copied (mail, jdbc, parser and jaxp) in the directory where the orion.jar file resides (directory X in our example).

The reason why you need mail.jar and jdbc.jar is unclear to me. You get error messages if don't include them. I understood from Karl Avedal that Orion is working on a smaller 'client.jar' that also contains a subset of orion.jar. That would be great for connecting to Orion from a browser. That would take less downloading. Next step for me is to get it running using an applet and a browser. All that work and who will notice the difference with the JSP example 8-). Frank

orion-primer.zip

orion-primer.tar.gz

Reply via email to