Management Webservice Application

  Samples Index




Management Webservice Sample Application


This document describes how to utilize the Management Webservice sample application in conjunction with the Application Server.

This sample application document contains the following sections:



Overview

This sample application shows you how to create, deploy and run a simple webservice based on the Web Services for J2EE, version 1.1, on the Application Server. The sample application consists of a webservice named managementws and a stand alone java Client named Client.

In the server application, the ManagementWSIF Service Endpoint Interface defines the methods of the ManagementWS webservice, which is implemented by the ManagementWS_Impl Service Implementation Bean. Before the first request, a service instance, the ManagementWSPort Port component is created and managed in the server container.

In the standalone client, the Client application client uses JNDI lookup to access the ManagementWS Service object, gets access to ManagementWSPort, and invokes the methods on the Service.



For more information on the Web Services for J2EE version 1.1, go to http://jcp.org/en/jsr/detail?id=921.



Compiling and Assembling the Application



To recompile, assemble and deploy the application, see the Sample Application Build Facility document for details on using a build facility to quickly perform these tasks.

For example, to rebuild the entire application from scratch, perform the following steps:


  1. Compile and Assemble the J2EE Application.

    Execute the asant command under <install_dir>/samples/webservices/jaxrpc/apps/managementws.

    The default target core is executed to rebuild the .ear file.


  2. Deploy the application.

    After you have re-created the sample application from scratch, proceed to Deploying the Sample Application.


  3. Clean the application project area.

    Execute the asant clean command to clean the application area.


  4. Undeploy the application.

    Execute the asant undeploy command to undeploy the application.


  5. Build Javadocs.

    Execute the asant javadocs command to create Javadocs.

    The Javadocs are created under <install_dir>/samples/webservices/jaxrpc/apps/managementws/javadocs.



Deploying the Sample Application

A pre-built managementws.ear file is supplied with the application server installation. Within the .ear file resides the .xml deployment descriptor files, application class files, and other content required by the application. You can use the pre-built .ear file to deploy the application. If you want to compile and assemble the application from scratch, follow the instructions under Compiling and Assembling the Application.

To deploy the application, the administrative server needs to be running.

To start the administrative server if it is not already started:


For UNIX
Execute <install_dir>/bin/asadmin start-domain domain1


For Windows
Start->Programs->Sun Microsystems->J2EE 1.4 SDK->Start Default Server

Select one of the following approaches to deploy the application:


Command Line-Based Deployment

While Command Line Interface is the quickest means of deploying the application, if you want to deploy through a GUI tool, follow the instructions under the GUI Based Deployment section.

CLI deployment of the application can be performed using either the asant script or the asadmin command.

The deployment process includes deploying the application .ear file to the application server.

Deploy the application using the asant command:


  1. >cd <install_dir>/samples/webservices/jaxrpc/apps/managementws


  2. Execute the asant deploy command.

    It is an interactive command that might prompt you to provide the admin-server host, admin-server port, admin user name, admin password and appserv instance.

Deploy the application file using the asadmin command:


  1. >cd <install_dir>/samples/webservices/jaxrpc/apps/managementws

      Execute the command:
    asadmin
    deploy --user <username> --password <password> --host <host> --port <admin-port> --retrieve <local-dirpath>   managementws.ear

The deployment process involves the following operations:


GUI Based Deployment

Since a pre-built Enterprise Archive (.ear) file for the sample application is included with the application server, you can use the Admin GUI to quickly read in the .ear file and deploy it to the application server.

  1. Start the admin server if it is not already started. Here are the commands for each platform:
    1. Unix - Execute the <install_dir>/bin/asadmin start-domain domain1 command.
    2. Windows - Click "Start->Programs->Sun Microsystems->J2EE 1.4 SDK->Start Default Server"  command.
  2. Open the .ear file.
    1. Start Admin GUI, by entering URL  http://localhost:<admin.port>/asadmin   in browser. See replacing "localhost" and <admin.port> note here to determine correct values to use for your environment
    2. You are prompted to supply the user name and password of the application server. Enter correct values for your installed application server for "User Name:"  and "Password:" input fields, then click on the "Login" button.
    3. In the left-hand frame, click Applications-->Enterprise Applications  icon in the tree.
    4. In the right-hand frame, click on the "Deploy..."  button.
    5. Choose the file to be deployed by clicking on the "Browse..."  button, and navigate to select component to deploy (managementws.ear).
    6. In the browse dialog, click on the "OK"  button.
    7. In the right-hand frame, click on the "Next"  button.
    8. In the right-hand frame, click on the "OK"  button. (Optionally fill in remaining values for application to be deployed)
    9. In the left hand pane, you will see the newly deployed module's icon in the tree. In the right hand pane you will also see the component listed as deployed.

    Now you are ready to run the application (see Running the Sample Application).



Running the Sample Application

Perform the following steps to run the sample application:

  1. The Management Web Service performs tasks that require the modification of the default security policy of the server. Please make sure to add the following grant clause to the <install_dir>/domains/<domain_name>/config/server.policy file and restart the server, before you invoke this web service:
    // permissions for managementws classes
    grant {
            permission javax.management.MBeanPermission "*", "*";
            permission java.lang.RuntimePermission "*";
    };


  2. NOTE: You MUST restart the server before proceeding with step number 4. Otherwise the client will throw a security exception and hang.



  3. cd <install_dir>/samples/webservices/jaxrpc/apps/managementws
  4. Execute the stand alone java client via asant run command.
  5. The program displays the following lines:

    Buildfile: build.xml
    
    run:
    
    package-client:
         [echo] Building the client JAR  file....
       [delete] Deleting: C:\ias81\samples\webservices\jaxrpc\apps\managementws\mana
    gementws-standalone-client\build\assemble\client\managementwsClient.jar
          [jar] Building jar: C:\ias81\samples\webservices\jaxrpc\apps\managementws\
    managementws-standalone-client\build\assemble\client\managementwsClient.jar
    
    run-client:
         [echo] Running the jaxrpcmejb.Client program:
         [java] Endpoint address = http://localhost:8080/service/ManagementService
         [java] ListenerURI = http://ottid:4371
         [java] Default Domain = DefaultDomain
         [java] Number of MBeans = 305
         [java] queryNames *:* found 305 names
         [java] test isRegistered = true
         [java] queryNames JMImplementation:type=MBeanServerDelegate found 1 names
    
         [java]  [ 0 ]
    
         [java] ObjectName: JMImplementation:type=MBeanServerDelegate
         [java] Description: Represents  the MBean server from the management point
    of view.
    
         [java] ***  Attributes   ***
    
         [java] name: MBeanServerId value: ottid_1086721589573
         [java] name: SpecificationName value: Java Management Extensions
         [java] name: SpecificationVersion value: 1.2 Maintenance Release
         [java] name: SpecificationVendor value: Sun Microsystems
         [java] name: ImplementationName value: JMX
         [java] name: ImplementationVersion value: 1.2.2_r34
         [java] name: ImplementationVendor value: Sun Microsystems
         [java] *********************
    
    
         [java] *** Constructors  ***
    
         [java] *********************
    
    
         [java] *** Notifications ***
    
         [java] Name: javax.management.MBeanServerNotification
         [java] Description: Notifications sent by the MBeanServerDelegate MBean
         [java] JMX.mbean.unregistered
         [java] JMX.mbean.registered
         [java] *********************
    
    
         [java] ***  Operations   ***
    
         [java] *********************
    
         [java]

  6. In a seperate shell, execute the deployment of <install_dir>/samples/quickstart/hello.war :

            cd <install_dir>/samples/quickstart/

    Now execute command:

           asant deploy


    to see deployment events being captured in the shell where you invoked asant run.
    You should see output similar to :
          [java]  NOTIFICATION RECIEVED:
         [java] message =
         [java] sequence = 332
         [java] source = JMImplementation:type=MBeanServerDelegate
         [java] timestamp = 1086725008188
         [java] type = JMX.mbean.unregistered
         [java] user data = null
         [java] handback = MEJB
         [java] MBean Name = com.sun.appserv:type=RequestProcessor,worker=http1618,name=HttpRequest1
    
  7. To quit the application, execute <Ctrl-C> in the shell where you invoked asant run.


Troubleshooting

If you see a Connection refused error, when you do asant run command, make certain that soap:address location in <install_dir>/samples/webservices/jaxrpc/apps/managementws/managementws-share/web/WEB-INF/wsdl/ManagementWS.wsdl is set to http://<hostname>:<instance-port>/managmenetws. Please modify the file and execute asant core before running the sample again.



Copyright © 2004 Sun Microsystems, Inc. All rights reserved.

Last Updated September 2, 2004