Run the Application






In this section you will test the application. It covers:
  1. Ejb module test
    1. Creation of a test client
    2. Running the test client
  2. Web module test

1. Ejb module test

1.1. Creation of a test client


We need a test client.
Open the class diagram popup menu.
Select New->Class





Click on the Client class inside the class diagram editor and open the popup menu.
Select New->Attribute





Enter the name of the attribute and browse.





Select the type of this attribute.
Start typing in the field and then select in the lower window the matching type.





Unselect the use of accessors and press on the OK button.





Check that the Client class is shown in your diagram editor as below, if not use the maximize function.
Select the class->open the popup menu->Maximize.
Select the main method and open the popup menu->Properties.





Copy the following code:

try {
        java.util.Properties prop = new java.util.Properties();
        prop.put(
                javax.naming.Context.INITIAL_CONTEXT_FACTORY,
                "org.jnp.interfaces.NamingContextFactory"
        );
        prop.put(javax.naming.Context.PROVIDER_URL, "localhost:1099");
        prop.put(
                "java.naming.factory.url.pkgs",
                "org.jboss.naming:org.jnp.interfaces"
        );
        javax.naming.Context context = new javax.naming.InitialContext(prop);
        Object ref = context.lookup("ejb/hello");
        home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(
                ref,
                HelloHome.class
        );
} catch (ClassCastException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
} catch (javax.naming.NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
}
try {
        tutorial.interfaces.Hello bean = home.create();
        System.out.println("bean says " + bean.sayHello());
} catch (javax.ejb.CreateException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
}
Select the Implementation tab and paste the code.





1.2. Running the test client.

We can now run the application. In the menu bar select Run->Run...





Select in the Configurations explorer New_Configuration and click on the Classpath tab.





To run the application, we need to some add axternal JARs...





Inside your Jboss 3.2.2RC4 folder, select the client sub folder.





Select the following JARs files in the client folder and press ok.





Check that everything is loaded and run the application.





We save our class diagram.
Select Tutorial.ucd and click on the OK button.





The Eclipse console view shows the result.





2. Web module test


Open your favorite browser (I personnaly like using Mozilla).





Our browser will be considered as a client from our Jboss server. Use the 8080 port to reach the servlet.
See the result in your browser.








 
Last update Sat Nov 29 11:19:25 CEST 2003 Valid XHTML 1.0 Valid CSS All text, graphics © 2003 by Omondo