External Application Clients

Written by Joseph Ottinger

Getting external application clients can be interesting, but it's doable.

There are two forms of application clients; this article concerns itself with application clients that are running in a separate VM from Orion. There are a few steps to getting an application client to run.

They are:

  1. Deploy the application.
  2. Configure the principals.
  3. Configure the client application.

Application deployment has nothing unique about it, so it won't be addressed. Configuring the principals has nothing unique about it, with one caveat: the user must have a specific permission attached to it, the rmi:login permission. A sample group for principals.xml might look like this:  users  The permission name is very important! It enables an external JNDI client to, well, log in. Without it, nothing works, and it can be very frustrating to use the correct factory and settings, only to have the server tell you that your user credentials are wrong. The last element is to configure your application client itself. External application clients need to have orionclient.jar in their classpath. This is fairly trivial, of course. The InitialContext used should be retrieved with code similar to the following:


Properties props=new Properties(); 

props.setProperty("java.naming.factory.initial", 
    "com.evermind.server.rmi.RMIInitialContextFactory");
props.setProperty("java.naming.provider.url", "ormi://localhost/app");  
props.setProperty("java.naming.security.principal", "user");
props.setProperty("java.naming.security.credentials", "password"); 
Context ctx=new InitialContext(props);
 

Replace "app" with your application, "user" with a valid user (i.e., one that belongs to a group with the rmi:login permission enabled), and "pass" with that user's password, of course. The Orion context factories will look for "/META-INF/application-client.xml" in the classpath.

Now, for the sake of explanation, let us assume the "app" application has an EJB referenced at "ejb/1.0/MyEJB". A web-module might have an EJB reference at "ejb/MyEJB," which a deployer maps to point to "ejb/1.0/MyEJB," which means the application programmer can find the EJB via the name "java:comp/env/ejb/MyEJB". All that's well and good, except that an external application client using RMIInitialContextFactory has no local context. Such a client can only access the EJB by its actual position in the JNDI tree, thus "ejb/1.0/MyEJB". This is slightly inconvenient, because it removes one of JNDI's greatest strengths, but that's simply one of the drawbacks of using an external application client. Internal application clients get their own context (and are also much easier to work with in terms of getting the initial context) and are covered elsewhere.

Copyright © 2007 IronFlare AB