Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Note

The default namespace of the above XML document is http://java.sun.com/xml/ns/javaeeImage Removed. The XML elements that do not have a namespace prefix belong to the default namespace. Hence, in the above XML document, all the XML elements belong to the default namespace.

...

Note

The default namespace of the above XML document is http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0Image Removed. The XML elements that do not have a namespace prefix belong to the default namespace. Hence, in the above XML document, <application-client>, <ejb-ref> and <ref-name> elements belong to the default namespace.

...

The below is the client code that looks up the ejb and calls the method on it.

JAVA
Code Block
JAVA
borderStylesolid
titleConverterClient.java
JAVA
package examples.appclient.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import examples.appclient.Converter;

public class ConverterClient {

 //The remote interface of the ConverterBean packaged with the
 //Java EE client jar
   private static Converter converter;

   private static double amount = 50;
   public static void main(String[] args) {
    amount = Double.parseDouble(args[0]);
    doConversion();
   }

    public static void doConversion() {
     try {
            
        Context context = new InitialContext();
        converter = (Converter) 
                 context.lookup("java:comp/env/ejb/Converter");
        double dollars = converter.getDollars(amount);
        System.out.println("Rs " + amount + " is " + dollars + " Dollars.");
        System.exit(0);
            
        } catch (Exception ex) {
            System.err.println("Caught an unexpected exception!");
            ex.printStackTrace();
        }
    }
}

...