Inside Scoop on J2EE : Tips and tricks on J2EE and Oracle Application Server by Debu Panda
Updated: 11/18/2004; 5:19:53 PM.

 

Subscribe to "Inside Scoop on J2EE" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Monday, May 03, 2004

TSS Symposium - EJB 3.0 and the

surrounding halo

This year TSS symposium has taken precedence over JavaOne not just in the calendar but also in importance. Earlier Sun used JavaOne as its platform to launch any major technologies. This year EJB 3.0 expert committee is using this symposium as the platform to rejuvenate use of EJB and hence revealing it’s grand plan to make EJB attractive. TheServerSide.com has some what becomes Mecca for the J2EE developers. And The J2EE community has been critical of Sun for not involving the community in the JCP process and terming JavaOne turning into a SunOne conference and increasingly lot of tech savvy of the industry are preferring TSS Symposium to JavaOne, I assume Sun had no alternative.

 

As third-attempt is always a charm and the release 3.0 of EJB certainly looks compelling. I will be in the TSS Symposium and I know most of the attendees will be scrambling to find a seat in Linda Demitchiel’s (Lead of EJB 3.0 Expert committee) technical session where she would reveal some of the proposals for the grand plan for EJB 3.0. If you are not attending then bloggers like Cameron, Dion, Cedric etc. will keep you informed. I’m joining the bloggers bandwagon this year ..

 

 

Some of these grand plans have been revealed by Marc Fleury in his interview with Infoworld and some other circulating as wild fire in the blog sites. However impact for EJB 3.0 will be long lasting and the expert committee has to take proper steps to make EJBs really useful for the enterprise and compelling and simple for developers.

 

In my opinion here are few things developers like me expect from the EJB 3.0

 

·        EJBs as POJOs (without requiring so many interfaces)

·        EJB adopting annotations similar to XDoclet for generating deployment descriptors, code and interfaces if required

·        Make several mundane tasks optional e.g. so many things in deployment descriptors for EJBs, unnecessary lifecycle methods implementation, etc.

·        A simple persistence model like Hibernate and Toplink

·        EJB-QL to be much for flexible query language like SQL. May be provide ability to use SQL it self

·        Provide ability to developers to leveraging existing business logic in database stored procedure and legacy applications without having to rewrite those.

·        Standardize EJB clustering

·        Provide ability to migrate existing EJB applications work with the new model and layout migration plan

 

Every developer has his own wish list and the halo surrounding the tech session by EJB 3.0 team is becoming deeper and deeper with everyone anxiously waiting how will this appear in reality. Let’s see how it satisfies every one’s need when they unveil this. However let me know if you have a wish list I will try to pass these to the expert committee members during the conference.

 

Watch for my updates with full description the real plan for EJB 3.0.

 

Bye !


2:59:09 PM    comment []

An Adventure with J2EE 1.4 Blueprint Application

Have you heard of Java Blue Prints program? Java Petstore and Java Smart Ticket fall under this category.  If you haven’t heard of Adventure Builder the latest addition to the Java blue prints then you are not alone. However, if you have not heard of Java Petstore then probably you are not in the J2EE community for too long. Petstore reached its height of popularity during penultimate phase of the .COM boom era.  You would find Petstore everywhere prominently from each booth of JavaOne to home pages of J2EE tools and application server vendors with their published and unpublished modifications. Even the guys in the .Net camps loved this application and not too long ago they created the fiasco with their Petstore vs. Petshop benchmark.

 

Under this program, Sun outlines application programming model for java platform and hence creates best practices and guidelines for building Java applications. You can find details about Java Blue Prints at at http://java.sun.com/blueprints/.

 

Why A Blueprint application

 

Unequivocally Java Petstore was one of the earliest applications that provided a nice design pattern and guideline for building scalable and portable applications. In my opinion, Petstore is the most popular application built by Sun after Java and J2EE. Petstore went through several revisions between J2EE 1.2 and J2EE 1.4.

 

What do you really care of a Java Blue Application? If you are a hardcore and experienced developer and always ahead of the curve then probably you do not. However this is one of the nicest things Sun deliver to make J2EE popular among the developers.

 

The following are some benefits from Java Blueprint applications:

 

·         Act a sample application for new technology that be used by developers to learn the new technology.

·         Define the application-programming model for the J2EE platform, thus it provides best practices/design guidelines

·         Provides architectural recommendations for real-world application scenarios.

·         May be used as a sample application to test J2EE compatibility of your application server vendor.

 

Adventure Builder – An introduction

 

The Adventure Builder application 1.0 is a nice application that demonstrates J2EE 1.4 technology and simple design patterns. 

 

The concept of buying Adventure online is more realistic than the vague idea of buying Pets online. The details about the Java Adventure Builder can be found at

http://java.sun.com/blueprints/code/adventure/1.0/docs/index.html

.  This application uses JAX-RPC, JAXP, Servlet 2.4, JSP 2.0, JSTL and EJB.  Unfortunately the documentation is still for the early access 3.1 release and does not live up to the expectation.

 The Adventure Builder application consists of six modules and here is a little description of this application.

 

The Adventure Builder web module (ConsumerWebsite.ear) provides a web interface to search and submit orders for adventure packages.

 

The Order Processing Center module (OPC.ear) – is the main order-processing module that receives and fills customer oders by coordinating with other suppliers. It uses web services to interact with the suppliers and bank.

 

ActivitySupplier – receives and fulfills Activity orders from OPC.

 

AirlineSupplier - receives and fulfills flight bookings from OPC.

 

LodgingSupplier - receives and fulfills Lodging orders from OPC.

 

The supplier applications are fairly simple and have very similar structure. The main purpose is to demonstrate inter application communication using web service so the suppliers and hence do not have a lot of internal business logic.

 

Each supplier receives a web service request for a purchase order from OPC, does some business logic, and later sends an invoice document to OPC.

 

Bank – authorizes credit card request from OPC.

 

Architecture Review of Adventure Builder

 

The detailed architecture guide for Adventure Builder can be found at

http://java.sun.com/blueprints/code/adventure/1.0/docs/architecture.html

.  Unfortunately the architecture guide is not updated with information on the back-end modules

 Data Access Objects for Persistence from web modules

 

The Adventure Builder web module (ConsumerWebsite.ear) uses a lightweight persistence model and use Data Access Objects to browse Adventures and put an order for an adventure. Unlike its predecessor Petstore application it does not use entity beans.

 

Custom framework to use implement MVC

 

It uses a custom framework named Web Application Framework (WAF) instead of using a popular framework like Struts.

 

Web service as interaction between application modules

 

This application uses web services heavily for interaction between web modules. For example, the web module invokes web services to submit an order or to retrieve an order. The stateless EJBs are exposed as web service using the JAX-RPC endpoint interface.

 

Entity beans for persistence in the back-end modules

The Order Processing Center module (OPC.ear), ActivitySupplier, AirlineSupplier and LodgingSupplier have CMP entity beans for persisting the order/invoice information.

JMS and MDBs for asynchronous communication

The OPC module uses JMS for asynchronous communication internally for fulfilling an order and hence there are few MDBs are used.

 

A Showcase for J2EE Technologies

 

Adventure Builder is undoubtedly one the earliest and best application that I’ve seen that uses a myriad of J2EE 1.4 technology. The application has also great user interface that is much better than the earlier versions of blueprint application.

 

·        Web Service endpoint with JAX-RPC. Relies on web service heavily and demonstrates use of web services using JAX-RPC

·        JSP 2.0 features such as Expression Language, Tag files, JSTL, Custom tags, etc.

·        Use of a custom MVC framework.

·        Data Access Objects for persistence from the web tier

·        CMP entity beans for persistence in the business logic tier

·        MDBs for asynchronous communication

 

Minor Problems in the application

 

Following are the few issues that need to be addressed to make this application as popular as Petstore

 

·        Improve documentation  and include

·        Avoid packaging with J2EE 1.4 Samples like Petstore that can be downloaded standalone

·        Make build scripts are simpler and remove too much dependency on Sun Application Server

·        Use a framework like Struts that is popular

·        Provide documentation to make this run on your database of choice

·        Create scripts for tables for CMP entity beans

·        Hard coding of web URIs in the application

·        Use a popular persistence framework

 

 

Minor Portability Issues

 

 We found few portability issues when trying to port the application to run on OC4J. There were a few places where assumptions were made in code that were based on this application running on the Sun J2EE Reference Implementations. To address these portability issues, a couple of minor code changes are required in the ConsumerWebsite Web module to make it fully portable. We have  communicated these changes to the Java Blueprints team and will be addressed in the next release of Java Adventure Builder application.

1) TLD issue

The  waftags.tld in WEB-INF/ has in the ConsumerWebsite been changed from a version JSP 1.1/DTD based TLD to a version JSP

2.0/XSD based version.  There are few issues in this file:

<shortname> is valid for 1.1 but for 2.0 it requires <short-name>

<description> tag (the one that says BluePrints Web Application Framework Tags) needs to be removed.

The first description is valid, but the second one is not.

-  All occurrences of <tagclass> needs to be changed to <tag-class>

- Finally, the order is significant in schema, so the order  needs to be changed in the <tag> such that the <description> element

comes first, before the <name>.

 

2) consumerwebsite/waf/src/java/com/sun/j2ee/blueprints/taglibs/smart/OptionTag.java

This class was modified to make JSP 2.0 compliant.

 

public class OptionTag extends BodyTagSupport {
Old:    public int doAfterBody() throws JspTagException {
New:    public int doEndTag() throws JspTagException {
       …
        BodyContent bc = getBodyContent();
        String text = bc.getString();

The enter_oder_information.jsp has a number of tags that use this lib in the form of

<waf:option value="United States">United States</waf:option>

that work correctly.   However, it also has:

<waf:option value="Canada" />

 

When calling OptionTag’s

doEndTag a null pointer exception is thrown on the above bc.getString() line because the

bodyContent (bc) is null.

 

It can be fixed by adding:

       if (bc == null ) {
           return SKIP_BODY;
       }

after getBodyContent(), line number 58.

 

3) Avoid ClassCastException in CartHTMLAction.java

 

The following code snippet in updateActivityHeadCounts() method in CartHTMLAction.java   is illegal and depends upon the specific feature on Tomcat and is not portable. This will result in

ClassCastException in any other web container that does not rely on Tomcat.

HashMap params = (HashMap)request.getParameterMap();

 

The modified code should look like:

Map params = request.getParameterMap();

 

Configuring  and deploying in our J2EE server

 

The Adventure Builder application is really a nice application that is portable with only few minor code issues.

 

Here are few steps that you can use to make this work on your application server of your choice:

 

Rebuild with your vendor deployment descriptors

 

1. Changes in the ejb-jar.xml in the opc-ejb.jar to modify the end-point URL for web services.

2. Package vendor deployment descriptors for web services, EJB and Web modules to include web services end point definitions, environment references and web services references, etc.

3.  Make changes in the build scripts to include the vendor specific deployment descriptors.

4. Make code changes as outline in the earlier section.

5. Rebuild the application with your vendor specific deployment descriptors

 
Configure your application server

 

1. Change the database scripts to make this portable to your database as the PointBase uses “char” whereas Oracle uses “varchar2” for variable character data types.

2. Create a database schema and run the scripts in your database.

3. Make a data-source named “jdbc/adventure/AdventureDB” to point to your database.

4. Create JMS queues and connection factories required by the application.

5. Deploy your application and run your application

 

You can look at Oracle Technology Network at http://otn.oracle.com/tech/java/oc4j/1003/how_to.html#ri for detailed steps required to configure and deploy in

OC4J 10.0.3.

 

Conclusion

Java Blueprint applications provide a nice example of demonstrating Java technology. The latest blueprint application is an excellent application that demonstrates use of J2EE 1.4.

 

References

Java Adventure Builder 1.0 documentation (http://java.sun.com/blueprints/code/adventure/1.0/docs/index.html)


10:33:57 AM    comment []

© Copyright 2004 Debu Panda.

PS: These are my own thoughts and not of my employer ..



Click here to visit the Radio UserLand website.
 


May 2004
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Apr   Jun