You are receiving this e-mail because you elected to receive e-mail from Sun Microsystems, Inc. To update your communications preferences, please see the link at the bottom of this message. We respect your privacy and post our privacy policy prominently on our Web site http://sun.com/privacy/ Please do not reply to the mailed version of the newsletter, this alias is not monitored. Feedback options are listed in the footer for both content and delivery issues. |
| ||||||
In this Issue | ||
Welcome to the Enterprise Java Technologies Tech Tips for February 25, 2006. Here you'll get tips on using enterprise Java technologies and APIs, such as those in Java 2 Platform, Enterprise Edition (J2EE) and Java Platform, Enterprise Edition (Java EE). This issue covers: » Porting Java WSDP 2.0-Based Web Services to Java EE 5 » Call Flow Monitoring in GlassFish These tips were developed using an open source reference implementation of Java EE 5 called GlassFish. You can download GlassFish from the GlassFish Community Downloads page. You can download the sample archive for the tip Porting Java WSDP 2.0-Based Web Services to Java EE 5. You can download the sample archive for the Call Flow Monitoring in GlassFish tip.. Any use of this code and/or information below is subject to the license terms. See the Subscribe/Unsubscribe note at the end of this newsletter to subscribe to Tech Tips that focus on technologies and products in other Java platforms. | ||
PORTING JAVA WSDP 2.0-BASED WEB SERVICES TO JAVA EE 5 | ||
by Vijay Ramachandran One of the technologies available in J2EE for developing and deploying web services is Java API for XML-Based RPC (JAX-RPC). However, using JAX-RPC technology requires a developer to specify a lot of information in deployment descriptors such as To simplify the web services programming model, the Java API for XML Web Services (JAX-WS) was introduced. The main focus of JAX-WS technology is ease of web services development and deployment. A lot of this simplicity results from annotations. An earlier Tech Tip, "Developing Web Services Using JAX-WS" showed some of these annotations in use. These and other JAX-WS features have eliminated the requirement for deployment descriptors. JAX-WS technology was initially made available in the Java Web Services Developer Pack (Java WSDP) Version 2.0. This allowed early adopters to develop JAX-WS-based web services and deploy them on J2EE 1.4 implementations such as the J2EE 1.4 SDK (which includes the Sun Java System Application Server 8.2 Platform Edition) or Apache Tomcat. However, because JAX-WS technology became available after the release of J2EE 1.4, using it with that level of the platform required the addition of some platform-specific information in various deployment descriptors. Unfortunately, that platform-specific information restricts porting to Java EE 5 of any JAX-WS-based web services developed using Java WSDP 2.0. This Tech Tip describes what you need to do to change a JAX-WS-based web service developed using Java WSDP 2.0 and deployed on the J2EE 1.4 platform so that it can be ported to the Java EE5 platform. Getting Started A sample package accompanies this tip to help demonstrate the migration process. It contains the source code and associated files for building a web service. Two versions of the code and files are provided. One version is for building a web service using Java WSDP 2.0 and deploying it on Java System Application Server 8.2 Platform Edition. The other version is for building and deploying a web service on GlassFish, an open source reference implementation of Java EE 5. If you haven't already done so, download and install the following:
<sample_install_dir>/ttapr2006migws , where <sample_install_dir> is the directory in which you installed the sample package. You can find the two versions of the code and files in the jwsdp-as82 directory and jwsdp-gf directories below the ttapr2006migws directory. Building a Web Service With Java WSDP 2.0 To build the web service, you need to:
AddNumbers , is provided in the jwsdp-82\endpoint directory. You can compile the web service and generate the portable artifacts it needs, by executing an asant task that's defined in the build file in the jwsdp-82 directory. First start Java Application Server 8.2 Platform Edition: %S1AS_HOME%\bin\asadmin start-domainThen execute the following command: <sample_install_dir>\jwsdp-82\asant serviceThe service task compiles the endpoint implementation class and runs the wsgen tool to generate the portable artifacts. To package the web service as a WAR file and deploy it, execute the following command (on one line): %S1AS_HOME%\bin\asadmin deploy <sample_install_dir>\jwsdp-82\build\jwsdp-add.warWhat's significant here from a portability point of view is that this process requires various descriptor files: a web.xml file (in this case, jwsdp-web.xml ) and sun-jaxws.xml . These need to be packaged with the web service for deployment. The web.xml file includes a <listener> element that registers a servlet context listener for the web application being deployed. <listener> <listener-class> com.sun.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener>The registration of the servlet context listener is required by the Java WSDP 2.0 to do all the needed initialization for the web service endpoint when the WAR is deployed. <servlet> <servlet-name>AddService</servlet-name> <servlet-class> com.sun.xml.ws.transport.http.servlet.WSServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet>The web.xml file also includes a <servlet> element that points to com.sun.xml.ws.transport.http.servlet.WSServlet . This reference is specific to the Java WSDP platform. It's required so that all requests for the URL defined for this web service endpoint get routed through a common servlet. The common servlet then routes the requests to the appropriate web service endpoint. The sun-jaxws.xml file contains additional information about the endpoint. After you deploy the web service, you can view its generated WSDL file by pointing your browser to the URL http://localhost:8080/jwsdp-add/addnum?wsdl. A client references this WSDL file to use the web service. Although the deployed web service is certainly valid and usable by J2EE and Java EE 5 clients, it's not portable to all Java EE containers. That's because the content of the jwsdp-web.xml file contains platform-specific information. In addition, the sun-jaxws.xml file is a vendor-specific file. Now let's look at how to make the web service portable so that you can use it in Java EE 5. Making the Web Service Portable The specification "Implementing Enterprise Web Services", JSR-109, specifies the programming model for implementing a web service in Java EE 5. To make a web service developed using Java WSDP 2.0 and deployed on the J2EE 1.4 platform deployable on the Java EE5 platform, you need to ensure that it conforms to the JSR-109 specification. You still need to provide an endpoint implementation class and compile it. However based on JSR-109, you no longer package the vendor-specific descriptor file, web.xml file. If you don't provide the file, the platform will define a default one. However if you do provide it for packaging with the web service, you need to ensure that:
You can see this by examining the files provided in the One other important item of note: You have the option of running the wsgen tool to generate portable artifacts or not. If you don't run wsgen, the Java EE 5 platform implementation will generate portable artifacts for you at the time of deployment. You can build and deploy the same JAX-WS-based web service as you did for J2EE 1.4. This time you'll build and deploy it in Java EE 5, using the files in the jwsdp-gf directory. You can find the endpoint implementation class, Start GlassFish as follows: %GLASSFISH_HOME%\bin\asadmin start-domain Then execute the following commands: <sample_install_dir>\jwsdp-gf\asant service %GLASSFISH_HOME%\bin\asadmin deploy <sample_install_dir>\jwsdp-gf\build\javaee-add.war Notice that the service task does not run wsgen. There is no wsgen in the build file for the task. The portable artifacts are generated automatically when you deploy the WAR file. After you deploy the web service, you can view its generated WSDL file by pointing your browser to the URL http://localhost:8080/javaee-add/addnum?wsdl. In summary, the Java EE 5 platform makes the service portable by:
Vijay Ramachandran is a senior member of the Sun Java Application Server team. He has worked in the J2EE group for the last six years, and was a key contributor to the deployment and web services-related features of Sun Java System Application Server versions 8.X and 9.X. Previously, Vijay was the technical lead for Java BluePrints team, where he co-authored books on the J2EE 1.3 and 1.4 platforms. Back to Top | ||
CALL FLOW MONITORING IN GLASSFISH | ||
by Harpreet Singh and Anissa Lam The January 28, 2006 Tech Tip, Monitoring Web Services describes how you can use GlassFish, an open source application server implementation of Java EE 5, to monitor web services. However, there are other useful monitoring and management capabilities in GlassFish. One important GlassFish feature called Call Flow enables you to monitor applications deployed in the application server. A developer can use this feature at development time to see how the application behaves. An administrator can use this feature to monitor the runtime behavior of deployed applications. Call Flow collects runtime information about an application, such as the time spent in various containers, and time spent in the application code. This information can help in performance tuning and debugging an application. Calls from the application are monitored as they flow through various containers in the application server and through the application code. For example, consider a servlet in the application that calls a method on an enterprise bean. In this scenario, Call Flow monitors the request as it enters the web container, and continues monitoring the request as it flows from the servlet's service method, to the EJB container, and finally to the enterprise bean method. CallFlow then writes the collected information to a persistent storage device. You can then examine the recorded information. You can also "drill down" to get further information about a specific application request. This Tech Tip shows you how to use Call Flow from the GlassFish Administration Console to monitor an enterprise application. Step 1: Getting Started If you haven't already done so, download GlassFish from the GlassFish Community Downloads page. Then set the following environment variables:
Step 2: Start GlassFish Start GlassFish by entering the following command:<GF_install_dir>/bin/asadmin start-domain domain1where <GF_install_dir> is the directory in which you installed GlassFish. Step 3. Start the Administration Console After GlassFish starts, open the Administration Console by pointing your browser to:http://localhost:4848The host ID localhost is the default host ID and 4848 is the default port number for the Administration Console. Change these values, as appropriate, for your configuration. Then login with the appropriate administrator user name and password (the default username is Step 4: Enable Call Flow You can enable Call Flow either in the Administration Console or by command. To enable Call Flow from the Administration Console, do the following:
<GF_install_dir>/bin/asadmin asadmin start-callflow-monitoring server Step 5: Download and Deploy the Sample Archive Download the sample archive for the tip. The sample archive is a deployable archive for an enterprise application that you will monitor with Call Flow. After you download the sample archive deploy it. You can do this in various ways. For example, you can copy the sample archive to the GlassFish autodeploy directory ( Step 6. Run the Application Run the deployed application by entering the URL "Duke" and click the Process button. In response you should see a page that says something like this: Hello World ! Good morning, Duke. Enjoy your morning. Step 7: Display Call Flow Data Use the Administration Console to view the data that was recorded by Call Flow. Although Call Flow needs to be enabled to monitor and record call flow data, it doesn't need to be enabled for you to view data it already recorded. So you can optionally disable Call Flow before you view the data. (See "Step 8: Disable Call Flow" for instructions on how disable Call Flow.) You can find the call flow data in the Call Flow Data section of the Call Flow page in the Administration Console. The data is displayed in a table, with each row of the table displaying data for a specific request. You should see a row of data for the Hello World sample application that you ran. The table includes data such as the time stamp when the request was processed by the application server, the principal used to send the request (a call that is made without any user principal is displayed in the table as "anonymous"), and the name of the application to which the request was sent to. If you want to delete the data for a request listed in the table, check the checkbox of that row and click the Delete button. This will remove the data permanently. There is a drop down menu that allows you to filter the request. By default, data for all requests to the server are displayed. You can filter the displayed data based on:
You can display more detailed data about a request by clicking on the entry for the request in the Time Stamp column. In response, you should see a Call Flow Details page that displays information such as the response time for the request, and how much time the request spent in each container. You'll also see a table that presents in sequence the call flow of the request through the containers. For each step in the calling sequence, the table displays the pertinent container, component, and method. You can display the a parent-child view of the methods called in the call flow by clicking the View Tree button. Step 8: Disable Call Flow As is the case for enabling Call Flow, you can disable it from the Administration console or by command. To display Call Flow from the Administration Console, uncheck the Enabled checkbox on the Call Flow configuration page. To disable Call Flow by command, enter the following command (on one line):<GF_install_dir>/bin/asadmin asadmin stop-callflow-monitoring server Note that Call Flow is automatically disabled when you stop the application server. After you next start the application server, you can reenable Call Flow by rechecking the Enabled checkbox on the Call Flow configuration page. Additional Information About Call Flow For more information about Call Flow, see the GlassFish project CallFlow home page.About the Authors Harpreet Singh is a member of Sun Java System Application Server group at Sun Microsystems. He has been involved in J2EE development from the last seven years. His current interests are call flow monitoring and web services management. In the past, he has been a key contributor in security infrastructure of the Application Server. Anissa Lam is a member of the Sun Java System Application Server group at Sun Microsystems. She has worked in the J2EE group for the last five years, focusing on various IDEs, such as Sun Java Studio, and deployment tools. Anissa has been a key contributor to the Administration Console function of the Application Server. Back to Top | ||
Comments? Send your feedback on the Tech Tips: http://developers.sun.com/contact/feedback.jsp?category=newslet Subscribe to the following newsletters for the latest information about technologies and products in other Java platforms:
IMPORTANT: Please read our Terms of Use, Privacy, and Licensing policies: http://www.sun.com/share/text/termsofuse.html http://www.sun.com/privacy/ http://developer.java.sun.com/berkeley_license.html ARCHIVES: You'll find the Enterprise Java Technologies Tech Tips archives at: http://java.sun.com/developer/EJTechTips/index.html © 2006 Sun Microsystems, Inc. All Rights Reserved. For information on Sun's trademarks see: http://sun.com/suntrademarks Java, J2EE, J2SE, J2ME, and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. |
Please unsubscribe me from this newsletter. |
Born on shraavana shudha chauthi of dundubhi naama samvaswara, Im kiran alias kini alias kiri bought up by loving parents. Being from agricultural family I have learnt plowing, carting but never learnt climbing trees. Now away from home I have lost touch with the agricultural skills.