A Techno Blog, mainly about Java

Java Reporting – The world’s most powerful and widely used embeddable Java reporting library for report designers and developers. [getting started]

prompt> cd \program files
prompt> cd jasperreports-<ver>\demo\samples
prompt> dir
prompt> cd barbecue
prompt> ant –p
prompt> ant  javac
– Compiles the java source files of the test application
prompt> ant compile
– Compiles the XML report design and produces the .jasper file
prompt> ant fill
– Fills the compiled report design with data and produces the .jrprint file.
prompt> ant viewDesign – iReport gives administrators and report designers total control over the contents as well as the look and feel of every report

Jasper reports includes some nice samples and tutorials:

August 28, 2011 Posted by | J2EE, Open Source, SW Tools, XML | Leave a comment

Exception Scenarios

Its been a while since I chimed in on the topic of Exceptions:

Checked : (java.lang.Exception). This type of exception represents useful information about the operation of a legally specified request that the caller may have had no control over and that the caller needs to be informed about. With checked exceptions, Java language forces us to document all the anticipated ways in which control might exit a method:

Unchecked : (java.lang.RuntimeException). These are exceptions that occur as a result of programming errors that the program could not be expected to catch.

Now, it is time to talk about the Exception Handling capabilities with DAOs in the Spring Framework


SQL Exception Translatorsql exception can be translated to a DataAccessException using the translate method

ex1, ex2, ex3 , ex4

The method HibernateDaoSupport :: convertHibernateAccessException – convert the given HibernateException to an appropriate exception from the org.springframework.dao hierarchy.

SessionFactoryUtils : 
public static DataAccessException convertHibernateAccessException(HibernateException ex) {
		if (ex instanceof JDBCConnectionException) {
			return new DataAccessResourceFailureException(ex.getMessage(), ex);
		if (ex instanceof SQLGrammarException) {
			return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex);
		if (ex instanceof DataException) {
			return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex);
		if (ex instanceof LockAcquisitionException) {
			return new CannotAcquireLockException(ex.getMessage(), ex);
		if (ex instanceof ConstraintViolationException) {
			return new DataIntegrityViolationException(ex.getMessage(), ex);
		if (ex instanceof JDBCException) {
			return new HibernateJdbcException((JDBCException) ex);
		if (ex instanceof PropertyValueException) {
			return new DataIntegrityViolationException(ex.getMessage(), ex);
		if (ex instanceof PersistentObjectException) {
			return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
		if (ex instanceof TransientObjectException) {
			return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
		if (ex instanceof ObjectDeletedException) {
			return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
		if (ex instanceof QueryException) {
			return new HibernateQueryException((QueryException) ex);
		if (ex instanceof UnresolvableObjectException) {
			return new HibernateObjectRetrievalFailureException((UnresolvableObjectException) ex);
		if (ex instanceof WrongClassException) {
			return new HibernateObjectRetrievalFailureException((WrongClassException) ex);
		if (ex instanceof NonUniqueResultException) {
			return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1);
		if (ex instanceof StaleObjectStateException) {
			return new HibernateOptimisticLockingFailureException((StaleObjectStateException) ex);
		if (ex instanceof StaleStateException) {
			return new HibernateOptimisticLockingFailureException((StaleStateException) ex);

		// fallback
		return new HibernateSystemException(ex);

Hibernate Template

September 13, 2008 Posted by | Hibernate & ORM, J2EE, Open Source | 1 Comment

Testing through Spring with rollbacks

If you download the spring framework with dependencies, one of the modules included is the spring-test.

– Convenient jar file combining all standard modules (except for the test module and the Spring MVC support)
– Also includes the AOP Alliance interfaces (as a convenience)!
– Does not include contents of spring-aspects.jar, spring-test.jar and spring-webmvc*.jar!

– Contents: test context framework, JUnit support, JNDI mocks, Servlet API mocks, Portlet API mocks
– Dependencies: spring-core, (spring-context, spring-jdbc, spring-web, JUnit, Servlet API, Portlet API)

As the spring documentation mentions, for unit testing transactional systems you can achieve rollback of your tests pretty easily:

Typically you will extend the subclass, AbstractTransactionalDataSourceSpringContextTests. This class also requires that a DataSource bean definition – again, with any name – be present in the application context. It creates a JdbcTemplate instance variable, that is useful for convenient querying, and provides handy methods to delete the contents of selected tables (remember that the transaction will roll back by default, so this is safe to do).

This problem was identified with MySql.

Nice article here on spring test

This link tells us about the spring testing method calls

AbstractTransactionalDataSourceSpringContextTests superclass
provides the following services:

Injects test dependencies, meaning that we don't need to
perform application context lookups. Injection uses
autowiring by type.

Executes each test method in its own transaction, which is
automatically rolled back by default. This means that even 
if tests insert or otherwise change database state, there
is no need for a teardown or cleanup script.

If you want a transaction to commit--unusual, but useful 
if you want a particular test to populate the database,
for example--you can call the setComplete() method inherited
from AbstractTransactionalSpringContextTests. This will cause
the transaction to commit instead of roll back.

There is also convenient ability to end a transaction before
the test case ends, through calling the endTransaction() method.
This will roll back the transaction by default, and commit it
only if setComplete() had previously been called.

Provides useful inherited protected fields, such as a JdbcTemplate
that can be used to verify database state after test operations,
or verify the results of queries performed by application code.
An ApplicationContext is also inherited, and can be used for
explicit lookup if necessary.

All the Spring Test Life Cycle Methods


  • getConfigLocations
  • setDataSource
  • setTransactionManager
  • onSetUpBeforeTransaction
  • onSetUpInTransaction
  • onTearDownInTransaction
  • endTransaction
  • onTearDownAfterTransaction

example scenario:

Now onto the 2.5 way of testing:

org.springframework.test.context – Spring TestContext Framework which provides annotation-driven unit and integration testing support that is agnostic of the actual testing framework in use.

Spring 2.5 continues this rich and convenient testing framework, while now removing the requirement that your unit tests extend Spring framework tests. Instead of subclassing, it uses java annotations.

Related links:

August 24, 2008 Posted by | IoC, J2EE | 1 Comment

Spring Web Flow Beginner – Part Two

As a total beginner to Spring Web Flow, the main thing I have noticed in going through the material is that there is quite a difference between the 1.x and the new release 2.0.

Web Flow | Spring Web Flow Forum

There seems to be in package org.springframework.webflow.action a FlowAction and a FlowExecutor class. As well, the ExternalContext class which is credited to allowing WF to be decoupled from Servlet API .

I do not see a FlowAction or FlowExecutor in org.spring.webflow.action package like in webflow 1.

Instead, lets look at what we have from the example Spring Flow 2.0 Example application.

To use annotations for the transactions within the example, we do the following:

  1. Put an tag tx:annotation-driven in the spring config file
  2. Put @Transactional annotation in the services classes

@Transactional – The @Transactional annotation may be placed before an interface definition, a method on an interface, a class definition, or a public method on a class. However, please note that the mere presence of the @Transactional annotation is not enough to actually turn on the transactional behavior.

You can actually omit the ‘transaction-manager’ attribute in the <tx:annotation-driven/> tag if the bean name of the PlatformTransactionManager that you want to wire in has the name ‘transactionManager’.

<!– Instructs Spring to perfrom declarative transaction managemenet on annotated classes –>

<!– Drives transactions using local JPA APIs –>
<bean id=”transactionManager” class=”org.springframework.orm.jpa.JpaTransactionManager”/>

The LocalContainerEntityManagerFactoryBean can be configured with all Persistent Unit information like is done here.

@PersistenceUnit – annotated on EntityManagerFactory instances are thread-safe

<!– Creates a EntityManagerFactory for use with the Hibernate JPA provider and a simple in-memory data source populated with test data –>
<bean id=”entityManagerFactory” class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean”>
<property name=”jpaVendorAdapter”>
<bean class=”org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter”/>

<!– Deploys a in-memory datasource –>
<bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>
<property name=”driverClassName” value=”org.hsqldb.jdbcDriver”/>
<property name=”url” value=”jdbc:hsqldb:mem:tutorialSwf”/>
<property name=”username” value=”sa”/>
<property name=”password” value=””/>

<!– Activates annotation-based bean configuration –>

Mapping URLs to Handlers – maps request URLs to handlers. A simple way to create URL mapping rules is to define one as follows:

<!– Maps request URIs to controllers –>
<bean class=”org.springframework.web.servlet.handler.SimpleUrlHandlerMapping”>
<property name=”mappings”>
<prop key=”/f/*”>flowController</prop>
<property name=”defaultHandler”>
<!– Selects view names to render based on the request URI: e.g. /main selects “main” –>
<bean class=”org.springframework.web.servlet.mvc.UrlFilenameViewController”/>

The Flow Handler manages executions of a single flow definition. Above the handler selects view based on the URI in a default handler. To Implement one, extend AbstractFlowHandler.

Flow Controller – The FlowHandler MVC integration approach, you define one handler per flow. This is overkill in the cases where default flow handling rules are sufficient. Web controller for the Spring web MVC framework that routes incoming requests to one or more managed web flows. Requests into the web flow system are managed using a configurable ServletFlowExecutionManager.

<!– Handles requests mapped to the Spring Web Flow system –>
<bean id=”flowController” class=”org.springframework.webflow.mvc.servlet.FlowController“/>

The flow executor is the core Web Flow configuration element. Flow execution listeners are also defined in the flow executor.

<!– Executes flows: the central entry point into the Spring Web Flow system –>
<webflow:flow-executor id=”flowExecutor”>
<webflow:listener ref=”jpaFlowExecutionListener”/>

FlowRegistry – placed where you register your flows

flow-builder-services attribute – customize the services used to build the flows in a registry…When the tag is defined, you only need to reference the services you want to customize.

<!– The registry of executable flow definitions –>
<webflow:flow-registry id=”flowRegistry” flow-builder-services=”facesFlowBuilderServices”>
<webflow:flow-location-pattern value=”/WEB-INF/flows/**/*.xml”/>

flow scoped persistence context – provides isolation of intermediate edits by only committing changes to the database at the end of flow execution. This pattern is often used in conjunction with an optimistic locking strategy to protect the integrity of data modified in parallel by multiple users.

@PersistenceContext – annotated on EntityManager instances are not thread safe

<flow xmlns=”; xmlns:xsi=”;

configure the correct FlowExecutionListener in this case for JPA

<!– Installs a listener that manages JPA persistence contexts for flows that require them –>
<bean id=”jpaFlowExecutionListener” class=”org.springframework.webflow.persistence.JpaFlowExecutionListener”>
<constructor-arg ref=”entityManagerFactory”/>
<constructor-arg ref=”transactionManager”/>

Here is how they handle the view:

<!– Maps logical view names to Facelet templates (e.g. ‘search’ to ‘/WEB-INF/search.xhtml’ –>
<bean id=”faceletsViewResolver” class=”org.springframework.web.servlet.view.UrlBasedViewResolver”>
<property name=”viewClass” value=”org.springframework.faces.mvc.JsfView”/>
<property name=”prefix” value=”/WEB-INF/”/>
<property name=”suffix” value=”.xhtml”/>

Or a simple ViewResolver

July 19, 2008 Posted by | J2EE | 3 Comments

Spring Web Flow Beginner

As part my learnings of what is new with the Spring Framework, I found a nice Spring Flow 2.0 Example (with JSF and JPA).

The Spring Web Flow 2.0.2 release ( by Erwin Vervaet and Keith Donald ) comes as a separate download from the basic Spring functionality in 2.5.5.

On the Spring Web Flow (SWF) vision from 1.x to 2.x :

“[in 1.0] the SWF controller engine cared for one half of the web request lifecycle; the half related to request processing, often called the action phase. The other half, the render phase, was pushed off on the caller: either Spring MVC, Struts, or JSF front controllers
The downside of this approach is it makes it difficult to apply application control logic during the view rendering phase
Beginning with Web Flow 2.0 M2, the entire web request lifecycle is now under the control of Spring Web Flow, including the view rendering phase.
the ability for the SWF engine to communicate with external systems and conversational contexts over HTTP (embedding the proper flow execution callback URL in the redirect that is sent to the external system)”

Reference Guide 2.x

Also, note that getting these Spring Flow 2.x reference sample projects are easy to get a hold of. In the download of Web Flow is a projects/build-spring-webflow directory where you can run ant. It will build Web Flow along with the .war files for the sample projects (ant 1.7 and Java 5 are required to build).

There is a Struts2  plugin for Spring Web Flow called  struts2webflow

As far as further examples than the ones above, I found some web flow 2.x examples at this site spring by example.

Spring flow 1.0 showed that it could  easily integrate with struts. These  sample (1.x) applications can also be found on Java Passion Site. A good 1.x reference is the  Practical ntroduction . All the samples projects are Spring IDE projects that importable into Eclipse (see springide or plugin central for spring ide).

Here in the 1.x struts example:

Our first action in the jsp is as follows:

<A href=””>Birth Date</A>

This action in the struts config says:

<action path=”/flowAction” name=”actionForm” scope=”request” type=”org.springframework.webflow.executor.struts.FlowAction”/>

We also bind to the Action Form:

<form-bean name=”actionForm” type=”org.springframework.web.struts.SpringBindingActionForm”/>

In the webflow-config.xml we define the flow registry:
<flow:executor id=”flowExecutor” registry-ref=”flowRegistry”/>
<!– Creates the registry of flow definitions for this application –>
<flow:registry id=”flowRegistry”>
<flow:location path=”/WEB-INF/birthdate.xml”/>
<flow:location path=”/WEB-INF/birthdate-alternate.xml”/>

Start State : the first state in the flow

<start-state idref=”enterBirthdate” />

View State: selects a view to render

<view-state id=”enterBirthdate” view=”birthdateForm”>

When the execution of the flow starts, enter the enterBirthdate state. Then select the birthdateForm view for display to the user, and pause the flow of execution until a user event happens.

Render Action: initializes the form object.

<action bean=”formAction” method=”setupForm” />

For view state, above Initializes the backing “form object” by invoking the setupForm method for formAction.

Note that the action was defined in the webflow-config.xml (instance of spring-webflow-config-1.0.xsd)

<bean id=”formAction” class=”org.springframework.webflow.samples.birthdate.BirthDateFormAction” />

Transition: Each View state must define a transition that leads to another state

<transition on=”submit” to=”processBirthdateFormSubmit” />

Action state: logic that needs to be executed in context of the request, once executed the result flow is returned which the flow may respond to.

<action-state id=”processBirthdateFormSubmit”>
<action bean=”formAction” method=”bindAndValidate”>
<attribute name=”validatorMethod” value=”validateBirthdateForm” />

transition on=”success” to=”enterCardInformation” />
<transition on=”error” to=”enterBirthdate” />


Related Links for Basic info on JSF:

July 13, 2008 Posted by | J2EE | 22 Comments

JPA Examples

jpa spec jsr 317

open jpa manual

In an applicationserver, EntityManager instances are typically injected, rendering the EntityManagerFactory unnecessary.


  • Persistence : contains static helper methods to obtain EntityManagerFactory
    instances in a vendor-neutral fashion.
  • EntityManagerFactory: is a factory for Entity-Manager
  • EntityManager: is the primary JPA interface used by applications.Each EntityManager manages a set of persistent objects, and has APIs to insert new objects and delete existing ones. EntityManagers also act as factories for Query instances.
  • Entity: persistent objects that represent datastore records.
  • Query: Query interface is implemented by each JPA vendor to find persistent objects that
    meet certain criteria. JPA standardizes support for queries using both the Java Persistence Query Language (JPQL) and the Structured Query Language (SQL). You obtain Query instances from an EntityManager.

JPA uses a version field in your entities to detect concurrent modifications to the same datastore record. When the JPA runtime detects an attempt to concurrently modify the same record, it throws an exception to the transaction attempting to commit last. This prevents overwriting the previous commit with stale data.

private int version;

JPA introduces another form of object identity, called entity identity or persistent identity. Entity identity tests whether two persistent objects represent the same state in the datastore.

May 11, 2008 Posted by | Hibernate & ORM, J2EE | Leave a comment

web 2.0 conference

In Raleigh, I got a chance to attend IBM’s technical briefing on web 2.0 .

For now, will just list various bits of info that I will organize later.

QEDWiki (Quick and easy design) . Assembly : “QEDWiki is a unique Wiki framework in that it provides both Web users and developers with a single Web application framework for hosting and developing a broad range of Web 2.0 applications.”

Damia . Feeds: “provides easy-to-use tools that developers and IT users alike can use to quickly assemble data feeds from the Internet and a variety of enterprise data sources. The benefits of this service include the ability to aggregate and transform a wide variety of data or content feeds, which can be used in enterprise mashups.”

Mashup Hub. Tag : “Mashup Hub provides two broad areas of support: feed generation for enterprise data sources and a catalog of feeds and user interface (UI) widgets.”

Info 2.0

Many eyes

Baby name wizard

second life

strike iron

gold corp



September 14, 2007 Posted by | AJAX, Blogging, J2EE, NC, Open Source, SOA, Web/Tech | Leave a comment

Design choices and Tools roundup

softarc – the anti- experienced Coding Architect

Using NetBeans Open Source Toolbox , and More Netbeans

You are doing more modeling than you think

July 2, 2007 Posted by | J2EE, SW Tools | 1 Comment

Its here: Sun’s Java Platform on Open Source

OPEN JDK:"Santa Clara-based Sun said it is making nearly all of Java’s source
code — excluding small pockets of code that aren’t owned by Sun —
available under the GNU General Public License. The same type of
license also covers the distribution of the core, or kernel, of the
popular open-source operating system Linux" [q&a]

Why its good : "Java under the GPL means that they can now much more readily cross-leverage each other"

Sutor: "The most widely used license is the GNU General Public License (GPL).
While it is hard to quantify, it appears likely that approximately 70%
of all open source projects use the GPL. Code that uses the GPL is
referred to as “free software.”By its nature, the GPL makes new code that incorporates older GPLed
code also use the GPL. That is, the GPL is somewhat self-propagating as
code that uses it is picked up and re-used elsewhere. This is exactly
as the authors intended.The GNU/Linux operating systems use the GPL. You cannot charge
others for a license to use GPLed software and you must make your
source code available.

Another commonly used license is from the Apache Software
. This is an open source license that does allow direct use
of the source code within commercial products. Unlike the GPL, the Apache License
allows “defensive termination”: if you sue someone because you claim
that the software infringes on one of your patents, then you lose the
right to freely use the patents of others that are implemented in the

In other words, you stop having the right to use the software if you
are trying to stop others from using it. Much of the open source
software that implements the standards of the World Wide Web is covered
under the Apache license."


Details of what is available:

The first pieces of source code are available today:


* Java HotSpot technology (JVM)
* Java programming language compiler (javac)
* JavaHelp software
* Sun’s feature phone Java ME implementation
* Java ME testing and compatibility kit framework

Later in 2006, Sun will release these pieces:


* An advanced operating system phone implementation
* The framework for the Java Device Test Suite

Finally, in the first quarter of 2007 the move to free software will be completed as Sun provides these pieces under the GPL:


* A buildable Java SE Development Kit (JDK)
* Project GlassFish (in addition to CDDL)

Duke  Open Sourced.

IBM’s take is one of dissapointment  but one    opinion: "What IBM holds back for its clients only gives it an advantage over
everyone else, especially among the large accounts that can afford its
overhead.The Apache license accepts this reality. The GPL does not. Behind
IBM’s mild complaint is a scream of pain, an acknowledgement that Sun
has cleverly kicked it in the shins."


November 13, 2006 Posted by | J2EE | Leave a comment

framework fungo

October 23, 2006 Posted by | J2EE | Leave a comment

Java Tour

October 20, 2006 Posted by | J2EE | Leave a comment

java tips

September 18, 2006 Posted by | J2EE | Leave a comment

Day 1 Blogs

The Aquarium NetBeans Day Roundup

Why Not?


More Netbeans


May 15, 2006 Posted by | J2EE | Leave a comment

Java One 2006

Java One is early this year. Last year  it was in June.

Here is a rundown of some of the blogs I will be following.

Bruce Snyder
Inside Scoop

May 15, 2006 Posted by | J2EE | Leave a comment – Just keep talking!!

Link: – Just keep talking!!.



February 6, 2006 Posted by | J2EE | Leave a comment

Tomcat 5 contexts definition

In Tomcat 5 , you can define your JNDI  connections in context.xml  and place the file in the /META-INF directory. Alternatively, you can name your context whatever you want by placing your project folder in the webapps directory, and placing a corresponding xml file in \conf\Catalina directory.

For example, I place myfirstapp folder in webapps directory and create myfirstapp.xml inside C:\java\javatools\jakarta-tomcat-5.5.7\conf\Catalina\

The xml file looks as follows:


    Context configuration file

    $Id: cm.xml,v 1.0 2004/12/21 17:03:34 remm Exp $


<Context docBase="C:\java\javatools\jakarta-tomcat-5.5.7\webapps\myfirstapp\"
         privileged="true" antiResourceLocking="false" antiJARLocking="false">

  <!– Link to the user database we will get roles from –>
  <ResourceLink name="users" global="UserDatabase"

  <Resource name="jdbc/database" auth="Container"
              type="javax.sql.DataSource" driverClassName=""
              username="app" password="app1" maxActive="20" maxIdle="10"


<Resource name="otherds" auth="Container"
                type="javax.sql.DataSource" driverClassName=""
                username="app" password="app1" maxActive="20" maxIdle="10"
              defaultTransactionIsolation="1" />


<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false">
      <Store className="org.apache.catalina.session.FileStore"/>


Continue reading

January 23, 2006 Posted by | J2EE | Leave a comment

Fault Tolerant J2EE

Clustering – multiple application server instances acting as one instance to its clients.

Overview from BEA , and How it works

migrate – move them from one server to another within a cluster.

transient object data – Any object created using a developer-written constructor that
does not involve the persistence environment

approaches to clustering Java applications

link: In clustering environment, be aware that updating your local cache is only seen by your JVM unless  the data is synch’d across all the JVMs.

Serialize session data.

January 20, 2006 Posted by | J2EE | 1 Comment

JavaHotSpot Technology

Link: Java Virtual Machine Technology.

January 20, 2006 Posted by | J2EE | Leave a comment


cglib [], a library that lets you do metaclass programming efficiently in Java; it’s similar to java.lang.reflect.Proxy, but more flexible and compiled to bytecode. Cglib is commonly used to create decorators — for example, Hibernate uses it to generate proxies, to transparently track whether persistent objects have changed in memory and must be re-saved to the database — but there are other uses, such as mimicking the mixin pattern. [via ask slashdot] java bytecode manipulation framework. It can be used to dynamically generate stub classes or other proxy classes, directly in binary form, or to dynamically modify classes at load time,

ASM Toolkit for Bytecode Manipulation

ASM & CGLIB working Togther: Article

An Experience: "Hibernate 3.0 relies on CGLIB 2.x, which relies on ASM 1.x, which is API-incompatible with ASM 2.x, so my app experiences an unrecoverable error during context initialization."

How IBatis uses CGLIB: "If you want to enable CGLIB 2.0 bytecode enhancement to improve lazy loading and reflection performance."

January 2, 2006 Posted by | J2EE | Leave a comment

J2EE Matrix


I was reading
through the application assembly & deployment chapter in the j2ee
spec for 1.3 . It goes over the packaging makeup of a J2EE applications
which are composed of one or more J2EE components and one J2EE
deplyment descriptor.

I believe J2EE1.3 corresponds to servlets 2.3

If you are interested in 1.4 spec, it can be found here:



January 2, 2006 Posted by | J2EE | Leave a comment


extremecomponents sf page  forum

The eXtremeComponents are a series of open source jsp custom tags that render advanced displays, such as tables and trees. The primary tag is called the eXtremeTable and is used to display data in a table format.
The eXtremeComponents uses the  Apache License Version 2.0 open source license.

The version I am using is extremecomponents-1.0.1-M3. That jar along with prequsite jars , plus the tld (which goes in WEB-INF), should get you running. There is a test.jsp which requires you copying the includes images to the images/test folder.

<%@ taglib uri="/WEB-INF/extremecomponents.tld" prefix="ec" %>

I am getting this error  with eclipse in jstl code: ‘The method getContextPath() is undefined for the type ServletRequest


Entry about refactoring in the pagination/limit corner ( here).

category: j2ee pagination.

December 27, 2005 Posted by | J2EE | Leave a comment


I have used log4j beginning in 2003. Back then I was told, dont use println, use log4j

The version i am working with is 1.2.13 and can be found here.

For recent issues, I guess check mailing list.

Some reasons to like log4j which incluedes mention of an eclipse plugin.

Examples [1] [2] [3]

December 26, 2005 Posted by | J2EE | Leave a comment

Best Practices for Software Development

Link: Best Practices for Software Development.

December 23, 2005 Posted by | J2EE | Leave a comment

link dump

You said AJAX . [l]

How about UML

JBOSS has issues?

Java news


Need a conversion?

whats in that jar

lost that number

October 14, 2005 Posted by | J2EE | Leave a comment

Java theory and practice: Urban performance legends, revisited

Link: Java theory and practice: Urban performance legends, revisited.

October 11, 2005 Posted by | J2EE | Leave a comment

Serial version

Link: developerWorks : Blogs : Bobby Woolf.

October 11, 2005 Posted by | J2EE | Leave a comment

Why do developers need an Enterprise Service Bus?

Link: Why do developers need an Enterprise Service Bus?.

September 25, 2005 Posted by | J2EE | Leave a comment

Design is not coding, coding is not design

Link: Design is not coding, coding is not design.

September 13, 2005 Posted by | J2EE | Leave a comment

JNDI URL from tomcat 5 definition

J2EE Resources
The J2EE standard provides a standard set of elements in the /WEB-INF/web.xml file to reference resources.

Tomcat 5.5
entries in per-web-application InitialContext are configured in the elements that can be specified in either $CATALINA_HOME/conf/server.xml or, preferably, the per-web-application context XML file (either META-INF/context.xml).  example

Tomcat 5.5
separate namespace of global resources for the entire server. These are configured in the element of $CATALINA_HOME/conf/server.xml.

getting up and running with tomcat 5.5

Hibernate 3 and Tomcat

JNDI DataSource  how to 5.5

Some 5.0 Tomcat examples and back some even more

db forums thread

Hibernate says this, or using Hibernate with Tomcat [2] and JNDI , 3.X

Google on topic

July 27, 2005 Posted by | J2EE | Leave a comment


JSK 1.5 (Tiger) download

I am interested in learning about annotations : "eliminates the need for maintaining "side files" that must be kept up to date with changes in source files. Instead the information can be maintained in the source files".

Have seen annotations before (i.e. @depracated). The release 5.0 platform has a general purpose annotation (also known as metadata) facility that permits you to define and use your own annotation types.

Annotation type declarations are similar to normal interface declarations. An at-sign (@) precedes the interface keyword. Each method declaration defines an element of the annotation type. Method declarations must not have any parameters or a throws clause. Return types are restricted to primitives, String, Class, enums, annotations, and arrays of the preceding types. Methods can have default values. Here is an example annotation type declaration:

 * Describes the Request-For-Enhancement(RFE) that led
 * to the presence of the annotated API element.
public @interface RequestForEnhancement {
    int    id();
    String synopsis();
    String engineer() default "[unassigned]"; 
    String date();    default "[unimplemented]";

An annotation is a special kind of modifier, and can be used anywhere that other modifiers (such as public, static, or final) can be used. By convention, annotations precede other modifiers. Annotations consist of an at-sign (@) followed by an annotation type and a parenthesized list of element-value pairs. The values must be compile-time constants. Here is a method declaration with an annotation corresponding to the annotation type declared above:

    id       = 2868724,
    synopsis = "Enable time-travel",
    engineer = "Mr. Peabody",
    date     = "4/1/3007"

I believe Hibernate 3 now has this feature so that you can define mappings in source code rather than XML mapping file

Continue reading

July 17, 2005 Posted by | J2EE | Leave a comment

Collection versus Iterator

Link: Collection versus Iterator.

July 15, 2005 Posted by | J2EE | Leave a comment

link blast 7/8

spring experience

July 8, 2005 Posted by | J2EE | Leave a comment


Arron Johnson talks about Dates here


example of how I deal with dates:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

Date time = new Date();
String date = sdf.format(time);

GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime (new Date());
int hour = calendar.get(calendar.HOUR_OF_DAY);
int minute = calendar.get(calendar.MINUTE);
int dayOfWeek = calendar.get(calendar.DAY_OF_WEEK);
int dayOfMonth = calendar.get(calendar.DAY_OF_MONTH);
int month = calendar.get(calendar.MONTH);

July 1, 2005 Posted by | J2EE | Leave a comment

Being there without being there (IV)

Blogging Roller comments about his talk

Peter Pilgrim’s writeup

BeJug Day 3

javaone weblogs

I’ll have to read this one

Lastly: "The 2005 JavaOne conference multimedia technical sessions, will be available for free to Sun Developer Network (SDN) members. Membership to SDN is free to all developers."

July 1, 2005 Posted by | J2EE | Leave a comment

Java Naming changes

J2SE, J2ME and J2EE Naming conventions have changed

Drop the 2. So, SE, EE and ME

Single digit version: Java SE 6

The new naming conventions only apply to new versions. Existing versions remain.

June 30, 2005 Posted by | J2EE | Leave a comment

Being there without being there (III)

David Geary talk : "wresling match crossover with JSF, Shale, Wicket, Tapestry and WebWork being represented." [more quotes]

More on Web Framework Smackdown face off [java lobby]

Java EE : "J2EE is now Java EE"

MIT course work that was mentioned in the Java talk : "MIT Open CourseWare"

JSF source of Spring Pet Clinic

BeJug Day 3 summary

Wicket from Day 2

Oracle to provide reference implementation of EJB3

Peter Pilgrim

June 29, 2005 Posted by | J2EE | Leave a comment

Being there without being there (II)

Scott sings: "Kim Polese Q&A "

Tim Bray summary from Sun Planet

ULC: The second day started with a key note by Sun’s CEO Scott McNealy. While he was quite funny, the content of his talk did not reveal where Sun positions Java within its business plan next to the hardware sector and others.

Sun Microsystems is stepping away from an effort to sell the Linux operating system for desktop computers, the server and software company’s top software executive said Tuesday.

Nice blogging here : " Achieving great file I/O performance in Java (BEA Engineer Gregory Brail )…  The Spring Framework: An introduction to lightweight J2EE Architecture (Rod Johnoson, Juergen Heller)… SOA is a journey!” …BEA WebLogic Server 9.0, brought by BEAs Sr. Product Marketing Manager Gary McBride"

Struts to JSF : "I can’t say I agree with this approach, I’m of the school, based on testing this stuff that you either go for complete migration or you leave well alone and leave Struts Apps in Struts."

Amazon JavaOne : " site to learn the APIs … good use of Alexa data… way to tell the amazon value of a book…  Amazon Products Feed. "

Joe on puzzle "Josh Block and Neil Gafter gave what was in my opinion the most interesting talk of JavaOne, day 1 on coding puzzles"

Kasia coverage


June 28, 2005 Posted by | J2EE | Leave a comment

Being there without being there (I)

Java One Online

Feeds on Java One


Blogger guy opening session  notes : "The entire IBM middleware suite will be available for Solaris 10…Sun Java App Server now open source project, known as GlassfishJava Creator 2.0 and a cool new AJAX component they’ve cooked up…"

Vin Man Day 1 : "Next up was Yasushi Nishimura, the director of Panasonic USA and he talked about the Blu-ray disk which is the next big-thing in storage. Blu-ray DVD holds about 50 GB on a single disc with a potential of up to 200 GB. The Blu-ray disc standards bodies will use Java, as the standard for the interactivity menus and so all players will ship with a Java VM built into it. All menus and playback is controlled by Java and additional functions like in-movie menus, extras, etc are also all controlled by Java."

FOSS – free open source software

Sun and IBM extend their longstanding Java licensing agreement for 11 more years, and IBM pledges to offer WebSphere and its entire IBM middleware stack on Solaris.

Java One Ebay : "15 billion web services calls a year…Ebay web services: started XML, SOAP, REST…Resources: Forums: Roadmap: community codebase:"

Sun opening more from the vault : "Java System Application Server Platform Edition 9.0 and the Java System Enterprise Service Bus (ESB) "

CDDL – Common Development and Distribution License

Gupta notes

Experiences with the 1.5 Language Features Category

BEA and Open Source : "We are excited that BEA is embracing the grass-roots innovation that is happening in the Spring community as a response to the pain that developers face today. BEA’s support for Spring is important to our goal of helping developers spend less and less time dealing with the unnecessary complexity that is often associated with J2EE."

JSF interest

Net Beans Day – Sun’s IDE Creator 2

Sun buys

Photos &  People making contact  & Bloggers meet

Good Morning… From Bruce Snyder : "Java Birthday"

Debu Panda scoop

June 28, 2005 Posted by | J2EE | Leave a comment

Transactions methodoloy

A transaction that is isolated means that the transaction in progress is invisible to other transactions until the transaction has been committed. SQL92 supports four different isolation levels. Hopwever the measning of the different isolation levels differ between databases.

I am working on an web application that uses DB2 and sets a transaction isolation level as follows: transactionIsolationLevel of READ_UNCOMMITTED
– the data is visible as soon as it is written to the table. Basically, data is visible by other transactions even if commit() has not been invoked. This mode provides basic transaction support, but dirty reads , nonrepeatable reads, and phantom reads are all possible. Note that the Oracle database does not support this mode.

  • Dirty reads: A transaction reads a row in a database table containing uncommitted changes from another transaction.
  • Nonrepeatable reads: A transaction reads a row in a database table, a second transaction changes the same row and the first transaction rereads the row and gets a different value.
  • Phantom reads: A transaction re-executes a query, returning a set of rows that satisfies a search condition and finds that another committed transaction has inserted additional rows that satisfy the condition.
  • Locking – we do optimistic.This allows concurrent access to the data, but must implement a stratgey for competing updates (an update must be rejected if the data to be updated has changed since the prospective updater last read it).

    for updates: for the row you plan to update, save the data asoociated with the primary key as ‘the original’  , then when you enter the update method, you check to see if the row has been updated by checking ‘the original’ bean data for the entry, and doing a lookup on the data in the database using the primary key from ‘the original’ data. if its finds data based on the originals primary key, the data is the one you stored away as original, and has not been updated. However, if it does not find the entry based on ‘the original’ primary key, means it no longer exists. Next, we continue on with other update checks by seeing if any of the data for the current entry has been changed by someone else since we saved out ‘the original’. If any of the data has changed, we don’t allow the update. Furthermore, you might check if the changes you are making don’t duplicate an existing entry in the table.

    for inserts: you might check if the entry you are adding don’t duplicate an existing entry in the table.

    for deletes: it pretty much similar to updates except you dont have to check field by field on the entry to see if it has been changed by someone else. All you are checking here is if the entry still exists. You might have a check to disallow certain entries from being deleted.

    Link: programmer to programmer

    May 31, 2005 Posted by | J2EE | Leave a comment


    I found this newsletter on Java [RSS feed] : "a newsletter for people who are highly proficient in Java. This newsletter is not for the uninitiated".

    I think I have decided to do the certification thing after about five years in the java world. Not sure where I will start, but some sites I will check out are:

    Or, I could try this free Sun JAVA test

    May 26, 2005 Posted by | J2EE | Leave a comment


    Should we do the validation on client or on the server.

    Anything web or browser specific should be done on the client.

    Otherwise, we should do it on the server side.

    Typically, Business Objects can be called from non-web entities. Therefore, having validation there is a good idea.

    May 3, 2005 Posted by | J2EE | Leave a comment

    Forward versus redirect



    • forward is performed internally by the servlet
    • the browser is completely unaware that it has taken place, so its original URL remains intact
    • any browser reload will simple repeat the original request, with the original URL


    • redirect is a two step process, where the web application instructs the browser to fetch a second URL, which differs from the original
    • a browser reload of the second URL will not repeat the original request, but will rather fetch the second URL
    • redirect is always slower than a forward, since it requires a second browser request
    • beans placed in the original request scope are not available to the second request

    May 3, 2005 Posted by | J2EE | Leave a comment

    StringBuffer and String

    Link: AlwaysUseStringBufferMisconception

    Webpshere Best Practices: "String concatenation is the textbook bad practice that illustrates the adverse performance impact of creating large numbers of temporary Java objects. Because Strings are immutable objects, String concatenation results in temporary object creation that increases Java garbage collection and consequently CPU utilization as well. The textbook solution is to use java.lang.StringBuffer instead of string concatenation."

    Take from the The Server Side

    Being immutable means that that once Strings are created they can not be changed.  Operations that appear to modify String objects actually generate completely new ones.

    The creation of new String objects occurrs for:

    • overlaoded mathematical operations
    • concat
    • replace
    • substring
    • trim


    April 4, 2005 Posted by | J2EE | Leave a comment

    WAS Central

    Link: websphere central

    Portlets with MVC

    March 10, 2005 Posted by | J2EE | Leave a comment


    Link: jGuru’s Weblog: “Why do we use getters and setters? “

    January 25, 2005 Posted by | J2EE | Leave a comment

    more Javoloplis

    blog with tapestry, etc

    blog called plog

    December 29, 2004 Posted by | J2EE | Leave a comment

    Exception Fever

    Exceptions Best Practices

    Checked :  Java introduced availability of this kind of exception (java.lang.Exception). This type of excpetion represents useful information about the operation of a legally specified request that the caller may have had no control over and that the caller needs to be informed about [problems] [Challenges with Checked Exceptions ]With checked exceptions, Java language forces us to document all the anticipated ways in which control might exit a method:

    1. Java classes must declare any checked exceptions they throw in the method signature
    2. any method that calls a method that throws a checked exception of type E must either catch E or must also be declared to throw E

    Unchecked : runtime exceptions (java.lang.RuntimeException). These are exceptions that occur as a result of programming errors or that the program could not be expected to catch (dereferencing a null pointer, falling off the end of an array, dividing by zero, and so on).

    Recently, several well-regarded experts, including Bruce Eckel and Rod Johnson, have publicly stated checked exceptions have become a significant source of problems for many large projects.

    December 18, 2004 Posted by | J2EE | 4 Comments

    Javapolis 2004


    In Blogs


    Maven & Eclipse

    December 13, 2004 Posted by | J2EE | Leave a comment

    JDK 5.0 atomic

    atomic variable classes in java.util.concurrent

    November 29, 2004 Posted by | J2EE | Leave a comment

    Mastering J2EE Application Development Series

    J2EE Application Development Series

    Ted Neward: Slicing and Dicing J2EE

    November 13, 2004 Posted by | J2EE | Leave a comment

    Inside Scoop on J2EE

    Link to article by Monson-Haefel on future of J2EE.

    November 10, 2004 Posted by | J2EE | Leave a comment

    IBM and some Oracle

    zSeries – Mainframe Servers

    iSeries – Midrange Servers

    pSeries – UNIX Servers
    xSeries – Intel Processor-based

    IBM Infocenter

    IBM Tech Briefings


    Html Cross

    Html Colors Map


    Programmer Resource

    Oracle Blogger

    November 5, 2004 Posted by | J2EE | Leave a comment

    Junit and Java1.5 examples


    October 22, 2004 Posted by | J2EE | Leave a comment

    datasource in web.xml with JNDI

    In the past I would establish a connection to a database like this:

    Class.forName (Driver_string).newInstance ();
    connection = DriverManager.getConnection (“jdbc:db2://localhost/qms”, user_name, “user_password”);

    However, it is not a good idea to code such information in the application’s source code. They are all likely to change over time. Here on page 8 I learned you can use the web.xml to specify the datasource.

    October 22, 2004 Posted by | J2EE | 11 Comments

    JDK 5

    I saw the O’Reilly “A Developers notebook” on JDK 5.0, but have not picked it up yet. In the meantime I came across an other experience part 1 and part 2

    September 22, 2004 Posted by | J2EE | Leave a comment

    An Introduction to Java Map Collection Classes

    An Introduction to Java Map Collection Classes – jsr 166

    Hashtables and hashmaps

    api presentation

    September 17, 2004 Posted by | J2EE | Leave a comment

    Link Blast 2

    Ebay developer page

    Amis Technology Center blog

    Integrating struts with jsf

    Eclipse plugin for Cloudscape

    Java Threads

    Thread deadlocks discussed on Artima blog

    Java Memory leaks

    JavaOne Online

    September 10, 2004 Posted by | J2EE | Leave a comment

    Paging in J2EE

    Or known as Page Iterator.

    [article] : Pagination is a key part of Web site design, both from the UI perspective (to manage limited screen real estate) and from the server perspective (to process large result sets efficiently, without causing resource spikes or servicing delays).

    The Pager Tag Library is the easy and flexible way to implement paging of large data sets in JavaServer Pages (JSP).

    threads : Page by Page iterator does not solve DB bottlenecks?, Paging in JSP, J2EE + data caching and iterating page by page

    New one

    September 7, 2004 Posted by | J2EE | Leave a comment

    Java Tutorials


    Exadel Java Topics

    JDO, Struts, Java 1.5 etc.

    September 1, 2004 Posted by | Hibernate & ORM, J2EE, JDO, Struts | Leave a comment

    LinkBlast 1

    Inversion of Control (IOc) with Struts

    More on CommonJ project which includes SDO

    Portals at line 56, or read history on portals, or see blog with portlets

    More Faces commentary – greimblog

    IBM Rational Rose Technical Developer
    Code versioning – Subversion

    UML class

    Hashtable example and more

    Java Workshop site – code project

    Lastly, framework jungle.

    August 17, 2004 Posted by | J2EE | Leave a comment

    Online Books & Course Material

    Sun J2EE Online Course
    ServerSide PDF Book
    Hibernate in Action sample chapters
    MIT OpenCouseWare
    classes on Java

    August 5, 2004 Posted by | J2EE | Leave a comment

    Online Books & Course Material

    Sun J2EE Online Course
    ServerSide PDF Book
    Hibernate in Action sample chapters
    MIT OpenCouseWare
    classes on Java

    August 5, 2004 Posted by | J2EE | Leave a comment

    Jakarta Commons HTTPClient

    HTTPCLIENT: “Although the package provides basic functionality for accessing resources via HTTP, it doesn’t provide the full flexibility or functionality needed by many applications. The Jakarta Commons HttpClient component seeks to fill this void by providing an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations.”
    Here is the user guide.

    Now, we have an article to go along with this post.

    August 3, 2004 Posted by | J2EE | 1 Comment

    Download Guide, etc

    Did you say download?
    Here is one nice buncha links for Java.

    Eclipse Plugins by category

    JDKs, dont forget the IBM Linux JDK

    July 17, 2004 Posted by | J2EE | Leave a comment