Sun Java System Application Server 

Samples Index

The Management Web Service Sample Application

This sample application provides an example of a simple web service based on the Web Services for J2EE. It includes a web service named managementws and a stand-alone Java client named Client.

The ManagementWSIF interface is the service endpoint that defines the methods of the web service. The ManagementWS_Impl class implements this interface. Before the first request, Application Server creates and manages a service instance, the ManagementWSPort Port component.

The standalone client uses JNDI lookup to access the ManagementWS Service object. It then gets access to ManagementWSPort and invokes the service's methods.

Required Configuration Steps

This web service application requires modification of the server's default security policy. Before you invoke the web service, follow these steps:

  1. Add the following grant clause to domain_root_dir/domain_name/config/server.policy
     // permissions for managementws classes
          grant {
             permission javax.management.MBeanPermission "*", "*";
             permission java.lang.RuntimePermission "*";
          };
  2. Restart the server

You must also enter the URL of the web service in the WSDL file. Edit app_dir/managementws-share/web/WEB-INF/wsdl/ManagementWS.wsdl. Look for the following line:

<soap:address location="REPLACE_WITH_ACTUAL_URL"/>

Change "REPLACE_WITH_ACTUAL_URL" to http://hostname:instance-port/managementws.

Building, Deploying, and Running the Application

The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:

Follow this general procedure:

  1. Build the Application. The build file, build.xml, is in the app_dir directory, specifically, install_dir/samples/webservices/jaxrpc/apps/managementws.
  2. Deploy the Application. The EAR file is install_dir/samples/webservices/jaxrpc/apps/managementws/managementws.ear.
  3. Run the application as described below.

Running the Application

  1. Change your working directory to install_dir/samples/webservices/jaxrpc/apps/managementws
  2. Run the standalone client with the command asant run. The program displays the following:
    Buildfile: build.xml
    
    run:
    
    package-client:
         [echo] Building the client JAR  file....
       [delete] Deleting: app_dir\managementws-standalone-client\build\assemble\
                client\managementwsClient.jar
          [jar] Building jar: app_dir\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] *********************
    ...
    
  3. In a different shell window, deploy the QuickStart "Hello World" sample application. Follow these steps:
    1. Change your working directory to install_dir/samples/quickstart.
    2. Enter the command asant deploy. You will then see deployment events displayed in the first shell window (where you ran the client). You will see output similar to this:
           [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
      
  4. To terminate the client application, enter Ctrl-C in the first shell window (where you ran the client).

Troubleshooting

When you run the client, if you see the error Connection refused, make certain that the soap:address setting in app_dir/managementws-share/web/WEB-INF/wsdl/ManagementWS.wsdl is set to http://hostname:instance-port/managmenetws.

If you need to modify the file, execute asant core before running the sample again.


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