Sunday, December 31, 2006

Year 2007: My Self-Study Goals

In the past year of 2006, i took 4 Sun certifications (that includes Java SE 5.0 programmer, J2EE 1.4 Webservices developer, J2EE 1.4 Web component developer and J2EE 1.3 Business component developer) and 2 trainings ( Oracle workforce development program's Introduction to Oracle 9i SQL and Program with Oracle 9i PL/SQL). In short, i invested a lot of effort and time in learning of Java EE based enterprise application development, which became the major focus for me last year. I wanted to cover every aspect of web application development in my learning, right from CSS, JavaScript, Ajax, XHTML on client tier to Servlets/JSP/Struts 1.2 on Web tier to EJB 2.x for Business tier and lastly, relational database SQL and PL/SQL on EIS tier. I also covered Webservices (in great details) which has become a very important tool for A2A (ie EAI) and B2B integrations. Learning of Webservices and my score of 88% in SCDJWS 1.4 exam really makes me feel good as i have felt that Webservices will be a good substitute for SNMP in the network management domain (the domain in which i continue to specialize).

This year (2007) i intend to continue with learning of EJB 3.0 and JSF 1.2 to begin with. I have also started a project BaseApp (a kick-starter application for development using Java EE 5.0). I also have intentions to learn a bit about JBoss Seam framework (since its on standards track and is a framework built around EJB 3 and JSF). I also think that EJB 3 and JSF 1.2 together with up coming Web beans (or current JBoss seam) will be a strong (and standard) contender to Spring framework. So i will be focusing a lot on Java EE this year too.

Also the goal will be complete BaseApp. For now, baseapp happens to be open ended enterprise but we will soon be defining the requirements for the first release formally.

A few things i missed to complete last year are the reading of,
  1. H F Design patterns
  2. JUnit in Action
  3. J2EE Design and Development
  4. H F HTML with CSS & XHTML
  5. Get SCEA certification
  6. BPEL and WSDM/WS-Man
  7. Ruby/Perl
I think with work and the above tasks identified, i will have enough on my plate for this year.

Friday, December 29, 2006

EJB3 development using JBoss 4.0.5.GA

I encountered an issue today while redeploying EJB 3 jar for hot deployment to JBoss 4.0.5.GA which i installed using the JEMS installer 1.2.0 CR1. The issue and the resolution is mentioned here. You will need to install the JBoss EJB 3 RC 9 Patch 1 to fix it. For EJB3 development with JBoss 4.0.5.GA, you must use the JEMS installer only and not the archive releases.

I continue to see the issue of Wrong target message being thrown and the workaround for now is to restart the JBossAS which fixes the issue. EJB 3 RC 9 patch 1 does not do anything to solve this issue (and i found that one of the issues marked as dependent to this issue has been reopened recently). So expect a fix only by early Jan 07. For now reboot is the best bet.

Also i found that you need to have JSE 5.0 only to run your application. Even though the docs say that JDK 1.5+ is supported but you get a strange issue of "Could not dereference object" on deployment of Stateful session beans (see this). So i had to change back from JSE 6.0 to 5.0 in Eclipse.

At one point i really was planning to switch from JBoss to Glassfish :). But for now it seems i am back on track with some workarounds to continue my learning of EJB 3 using JBoss AS.

BTW, Mikalai Zaikin's notes on SCBCD 5.0 exam has a very nice appendix/tutorial (replete with screen caps) for how to develop using JBoss 4.0.5.GA + Eclipse 3.2.1 + WTP 1.5 + JBoss IDE 2.0.0.Beta 2. What's missing is how to use hibernate entity manager JPA implementation for RESOURCE_LOCAL transactions in a JSE standalone application. You will find this documentation useful for this.

If you are planning on using JBoss AS for a green field (from scratch) EJB 3.0 project and Eclipse is your IDE of choice, then you can find the instructions at following URL useful:
Eclipse + JBoss AS + EJB 3.0 setup instructions by Eric Garrido
Starter Skeleton Eclipse Project on JBoss Wiki site

Wednesday, December 27, 2006

Web Beans: JBoss Seam being standardized for Java EE 6 release

Web Beans JSR 299 proposal by JBoss (RedHat Middleware LLC) has been approved unanimously by the JCP executive committee even though IBM and BEA Systems have expressed their concerns regarding it being (too?) ambitious. Following is what they had to say:

------------------------------------------------------------------------------
On 2006-06-05 BEA Systems voted Yes with the following comment:
This appears to be a sufficient challenge to achieve, but, in light of the overwhelming support at this stage of the process, we are prepared to see it go ahead.
------------------------------------------------------------------------------
On 2006-06-05 IBM voted Yes with the following comment:
Delivering on the deep level of integration that is proposed appears to be an ambitious task.

In short, the goal of this initiative is: to enable EJB 3.0 components to be used as JSF managed beans, unifying the two component models and enabling a considerable simplification to the programming model for web-based applications in Java.

The benefit will be: this work will provide a programming model suitable for rapid development of simple data-driven applications without sacrificing the full power of the Java EE 5 platform. This is a domain where Java EE has been perceived as overly complex.

Gavin King (Hibernate founder) is the spec lead for this effort which is targeted for release of a RI with Java EE 6 (fall 2007). This is also the first time that JBoss is leading a standard spec.

Some links to learn more about what Web Beans will offer are:
Gavin's interview by InfoQ on JBoss Seam
Proposed spec description for JSR 299
What Matt Raible (author of Spring Live and AppFuse founder) said about Seam
The JBoss Seam Demo
The JBoss Seam Documentation
JBoss Seam FAQ

What excites me?
Seam is an ambitious full stack framework (unifying and integrating technologies such as Asynchronous JavaScript and XML (AJAX), Java Server Faces (JSF), Enterprise Java Beans (EJB3), Java Portlets and Business Process Management (BPM)) which enables EJB 3.0 components to be JSF managed beans. So your EJB 3.0 beans could become your Action classes and the glue code which was required earlier for enabling Actions to invoke methods on beans in the business tier will go away thus simplifying the development effort required.
Some specifics from the proposal as quoted by Floyd Marinescu at InfoQ are:

  • Changes to EJB 3 that will be needed for EJB's to act as JSF managed beans.
  • Annotations for manipulating contextual variables in a stateful, contextual, component-based architecture.
  • An enhanced context model including conversational and business process contexts.
  • Extension points to allow the integration of business process management engines.
  • Integration of Java Persistence API extended persistence contexts. (The other type of persistence context is transaction-scoped persistence context.)
Now thats what makes Web Beans a full stack framework! :) Here's one Seam Book by JBoss insiders.

Some notable aspects of Seam:
  1. State management: Most other web frameworks store all application state in the HTTP session, which is inflexible, difficult to manage and a major source of memory leak. Seam can manage business and persistence components in several stateful scopes: components that only need to live across several pages are placed in the conversation scope; components that need to live with the current user session are placed in the session scope; components that require interactions from multiple users and last extended period of time (i.e., survive server reboots) are placed in the business process scope. The advanced state management facilities allow us to develop web application features that are previously not possible, or very difficult, to implement.
  2. Multiple browser windows/tabs: Seam supports fine-grained user state management beyond the simple HTTP session. It isolates and manages user state associated with individual browser window or tab (in contrast, HTTP session is shared across all windows of the same browser). So, in a Seam application, each browser window / tab can become a separate workspace that has independent history and context. Multiple user "conversations" can be supported for the same browser. This behavior is similar to that in rich client applications.
  3. Handling back-button navigation: Seam's nested conversation model makes it really easy to build complex, stateful applications that tolerate use of the back button.
  4. Support for REST style bookmarkable URL: it is very easy to expose REST style bookmarkable URLs in a Seam application. In addition, the Seam application can initialize all the necessary backend business logic and persistence components when the user loads that URL. This way, the RESTful URL is not only an information endpoint but also an application interaction start point.
  5. Support for JSR 168 portlets.
  6. Support for internationalization.
  7. JBoss Eclipse IDE provides a sophisticated, template-driven database reverse engineering tool which can generate an entire Seam application in minutes and a graphical jPDL editor for editing Seam pageflows and workflow definitions.

Friday, December 22, 2006

Sunday, December 10, 2006

Using Subversion for your open source project



Subversion has been an open source contribution by CollabNet folks which improves over CVS. The Subversion project started in earnest in February 2000, when CollabNet offered Karl Fogel a full time job developing a replacement for CVS. Karl Fogel and Jim Blandy had previously founded Cyclic Software which provides commercial support for CVS. Subversion was designed from the ground up as a modern, high-performance version control system. In contrast to CVS, which had grown organically from shell scripts and RCS, Subversion carries no historical baggage. Subversion takes advantage of a proper database backend (Berkley DB), unlike CVS which is file based. The Subversion team have tried to make the new system similar in feel to CVS, so users are immediately at home with using it. Most of the features of CVS including tagging, branching and merging, are implemented in Subversion, along with host of new features:

  • versioning support for directories, files and meta-data
  • history tracking across moves, copies and renames
  • truly atomic commits
  • cheap branching and merging operations
  • efficient network usage
  • offline diff and revert
  • efficient handling of binary files

Salient points about Subversion:
  • Subversion is a centralized client-server version control like CVS, VSS or Perforce.
  • Advanced network layer: the Subversion network server is Apache, and client and server speak WebDAV(2) to each other. This gives Subversion an advantage over CVS in interoperability, and provides various key features for free: authentication, wire compression, and basic repository browsing.
  • It's free: Subversion is released under an Apache/BSD-style, open-source license.
  • Like CVS, Subversion has a concept of a single, central repository (often residing on a dedicated server) that stores all data about the projects you are working on. This data is called a repository. You never work in the repository directly, though. Instead, you pull subsets of it into working copies that typically reside on other systems such as your desktop computer. In these working copies, you make your changes, and when you are pleased with them, you commit those changes into the central repository where they become once and forever part of history.
  • Each commit (also called a check-in) to the repository is called a revision, and, in Subversion, revisions are numbered. A commit can be a change to one file or a dozen, to directories, or to metadata.
  • We speak of HEAD when we mean the latest version of the repository; so, when you check in revision 17, then HEAD is revision 17.
  • Atomic Commits: In Subversion, a commit is an atomic operation, meaning it either succeeds entirely or fails entirely; unlike CVS, you can't end up with half of your files saved to the repository but the other half unchanged.
  • Not only does Subversion offer version control of files and directories, it also offers version control of metadata. In the world of Subversion, such metadata is called a property, and every file and directory can have as many properties as you wish. You can invent and store any arbitrary key/value pairs you wish: owner, perms, icons, app-owner, MIME type, personal notes, etc. This is a general-purpose feature for users. Properties are versioned, just like file contents. And some properties are auto-detected, like the MIME type of a file (no more remembering to use the -kb switch).
To read about a quick intro to the setup of a local subversion repository (ie svnadmin create) and how to use the basic svn client commands (checkout, status, commit, update, log, diff, mv, rm, merge, stat, up etc) read this article by Chip Turner. The complete manual for different subversion releases are available too.

If you already have worked with CVS, and you have the option to choose a SCM tool for your project then its better to start with Subversion as it improves upon CVS in several ways. Also the client commands are similar to CVS thus enabling easier migration. Several tools/scripts/IDE plugins/GUI Clients for subversion are now available and mentioned here. Google Code free project hosting and collaborative development site, uses subversion as its version control server.

I have been introduced to subversion in one of my project works in the year 2004 at Hewlett Packard. HP used CollabNet for most of its projects for collaborative development across HP sites and we used to use the Subversion client Tortoise SVN which integrates with Windows explorer. Back then the tortoise svn was still not stable enough and made the particular working directory (copy of the repo) in windows explorer very slow to navigate. So we mostly used the command line client then. For BaseApp, i chose google code project hosting service as it seems to be the most intuitive and easier to get started with than sourceforge.net. Google code project hosting service provides a issue tracking service and a SCM service. Google also provides free discussion forums for your projects from its Google groups. So, with BaseApp, i am back to using Subversion (and this time around i hope the GUI clients will be helpful and not make me go back to command line tools).

Friday, December 08, 2006

Starting BaseApp

I have decided to start an open source project - BaseApp. The project is hosted on Google Code site. A new project blog is started where project activity will be logged.

Objective is to come up with a foundation application which can be leveraged to build web applications quickly in J2EE 1.4 (in the likeness of AppFuse). Most of the commonly used feature will be made available (like form based authentication support, netbeans project enabled, custom ant build file created etc). A sample application source will be provided which will use the following frameworks/toolkits as reference implementation:
  • Oracle 10g XE (the database i will use for testing)
  • JBoss 4.0.4GA (the Application server)
  • Struts 1.2.9 (the web tier framework)
  • Hibernate 2.x (the presentation tier framework)
  • XDoclet 1.2.3 (the attribute oriented programming support library)
  • EJB 2.1
    • Stateless Session Beans (J2EE 1.4) (synchronous request/response)
    • Message Driven Beans (J2EE 1.4) (asynchronous)
  • JAX-RPC 1.1 (webservice support)

Wednesday, December 06, 2006

Choosing your Linux distro

You can find a good comparison between any two Linux distros at http://polishlinux.org/choose/comparison/. For eg, this url compares the Ubuntu with Fedora core.

EasyUbuntu is an easy to use (duh!) script that gives the Ubuntu user the most commonly requested apps, codecs, and tweaks that are not found in the base distribution - all with a few clicks of your mouse.

Sunday, December 03, 2006

Java vs .NET

I recently attended a presentation talk by a .NET developer in my team at workplace where he talked about the reasons why he thought M$ .NET is better than Java EE. Following were the points raised by him together with my views on them:
  • Java is slow in performance (both on server-side and rich client) as compared to .NET.
I found this blog post which presents some stats which clearly show that Java (JRE 1.4.2) was more performant than CLR (.NET 1.1). But C# IL when compiled to native code using Ngen.exe did significantly improve performace. Here's another interesting article i could find which compares the Java 5.0 with .NET 2.0 (the two latest releases of the competing platforms as of this writing). The summary from the article is as follows:
    1. Selection Sort algorithm implementation : .NET performs faster by 2:1 as compared to Java.
    2. Memory comparison: .NET is using more than twice the amount of memory Java uses to store the same amount of data – 19.9 MB versus a whopping 47.8. Since .NET treats native types – such as double – as objects, that this incurs additional overhead of some form. Java, on the other hand, does not treat native types as objects and therefore can save on this overhead. However, when it comes to real-world object allocation, it appears that .NET is more efficient.
    3. Conclusion: Thus, as we have seen, .NET 2.0 won 2 out of the 3 major tests – clearly besting Java 1.5 in both execution speed and real-world memory efficiency. Java did, however, manage to hold its own in the native types memory comparison by a pretty wide margin. This indicates that on the whole .NET is a more efficient platform, with perhaps at least one area for improvement – native type memory efficiency.
  • The Java Swing UI looks and feels ugly.
Good examples of better looking Swing UIs do exist like Netbeans IDE and that of SWT like Eclipse. Still Java does lack on the UI front hands down to MS .NET Winforms as the later looks, feels and responds better and is easier to program. The only reason why you may at all want to use Swing/SWT is portability across platforms.
  • There are too many options in Java to choose from (like Swing/SWT for UI development, Struts/Tapestry/Velocity etc for Web framework, Spring/EJB/xWorks for business tier, IDEA/Netbeans/Eclipse for IDE) and this requires developers to learn more than one way of doing the same thing.
This is debatable topic as having options to choose from is exactly what standards are meant for. So if you have a J2EE application which complies with the standards then you can easily port the application across multiple J2EE application servers, hence removing the risk of vendor lock-ins. Also, it fosters innovations at multiple quarters and there is no one organization dictating the terms in the best of its own interests.

The reason there are many more Java frameworks out there is simply because Java has been around longer, enough to have several good frameworks mature and spread. Many of those are being ported to .NET and others will rise up.
  • You can only program in Java whereas .NET supports multiple languages to run on its CLR.
Multiple languages can be compiled to produce byte code that runs on JVM. See this list.

In short, .NET has managed to surpass Java VM in performance and the cost involved in procuring the tools for development in .NET is not a factor against MS .NET (as investing in the tools for development is only 20% of the total cost of development). But ...
  1. Java is portable and you can run it on Unix servers (Unix remains the server of choice for production deployments in most cases).
  2. Java EE has matured over time and has more developer mind-share (about 4 million Java developers as in 2004).
  3. There is alot of investment in Java today and many big companies like Sun, IBM, BEA, Oracle has vested interest (tools, AS, support & services) in not letting the technology go to dust.
  4. Sun's open sourcing Java SE (under GPLv2) will enable JDK to be bundled with major Linux distros which in the past have not been able to do so due to licensing issues.
  5. There are more than 200 models of mobile phones which run Java and several wireless providers across the world provide Java content to such Java enabled phones. On the contrary there are only 10 or so Windows mobile phones today (this i read from some site i cannot find out now).
Quoting from a blog post:
.NET had many missing parts that the Java world has filled in its years of existence, but these are being filled and completed even as we speak. Moreover, these are usually fixed in ways compatible with the original Java implementations - moving from JUnit to NUnit or from Spring to Spring.NET (or the other way around) is probably easier than from totally disparate implementations.

In some areas, .NET is still lagging behind. COM+ is the only application server I know of that can run .NET components, and it's often overkill. A more flexible solution for that in the .NET world would be great. The .NET solution biosphere is still not as mature as Java, but what it does, it does very well - often better than the original Java product.

How does Sun make money off of Java?
  1. J2ME royalty earned (by Sun) per Java mobile phone sold (less than $1) remains a cash cow for Sun to date.
  2. Also Sun sells certifications to Java EE application server vendors for their compliance to the Java EE Specs.
  3. Sun also makes money by selling books, certifications and trainings for Java technology.
  4. Sun provides consulting services for Java enterprise application development.
  5. Sun also sells its hardware (server boxes) together with Solaris OS for deployment of Java enterprise applications in production.
By giving its JDK implementation and developer tools for free, Sun wants to increase the mind share for Java platform (and now more so as it has .NET to compete against) among the developer community. Sun gives developers Reference implementations for free to try out the technology and when the developers have got a production ready application then they (or their organization) would want to deploy the application on a supported server host which cuts down on the organizations TCO in the long run. Thats the model in which open source or free software businesses survive in today's software industry.

An interesting article with more statistics concludes that Java is loosing ground to LAMP and .NET for web application development. More and more corporations have adopted .NET since its easier and faster to program in than Java. .NET is gaining on developer mind share too.

I don't know how credible are the stats presented in the articles (i have found on the web and linked to above) or whether someone is funding a malicious propaganda against Java as i donot see how anything can beat free (free IDE, even AS, and you pay for a short-term support and you go live with Java). Of course, PHP has gained ground for building small websites and applications but when the applications are big then Java holds good steed. In my opinion, Java and .NET are both competent platforms for developing enterprise applications and both have their own pros and cons to be considered when a decision is being made on which platform to develop on. BTW, here are a few comments which i liked (by one Mr. Abdul Habra) refuting the claims made in the business week article:
I do not know where to start, look at these statements:

1. LAMP is used more than Java: a more accurate comparison is to compare LAMP against LAMJ or P against J. Java is used widely with LAM components.
2. PHP is used more than Java: Well, HTML is used more than both. Counting all the sites that use Java or PHP is meaningless. It is given that there are more basic, simple, or home pages than there are professional complex site. Simple sites are more likely to be written in PHP. This is similar to saying there is more printed material in the USA Today than for Shakespeare, hence USA Today must be better.
3. Sales Of AJAX books grew more than Java: The term AJAX did not exist two years ago, so selling 10 books compared with 0 books two years ago means that AJAX sales have grown infinitely. The other flaw in this argument is that many of the AJAX frameworks are Java based. This is like saying the sale of JDBC, JMX, … grew more than Java. Look at http://adaptivepath.com/publications/essays/archives/000385.php for the first public article of AJAX, it is dated Feb 18 2005.
4. Google and Yahoo do not use Java: Both are C++ shops. Their usage of AJAX is with C++/Java at the backend. Remember, Google hired Josh Bloch not for his PHP skills.
5. Merrill Lynch & Co ... using just Linux and the Apache server: So what language do they use? The author does not say. Clearly you cannot write programs with Linux and Apache, you need a programming language. This is a meaningless statement.
6. Jupiter Research report showed that 62% of ... .NET, vs. 36% for IBM's WebSphere: This only shows that .Net is used more than WS. It does not count WL, Tomcat, JBoss, ...

In conclusion, this is not new. I have been seeing this since Java became popular. Most of these claims are made by ignorant people or people with hidden agendas.

Popular micro services patterns

Here are some popular Microservice design patterns that a programmer should know: Service Registry  pattern provides a  central location  fo...