A Techno Blog, mainly about Java

JPOX – gotchas

I was having a problem in JPOX when I relocated some JPOX code into an new package. It would enhance just fine but when i went to invoke the code, it continued to refer to the old location. I described this here. The main thing I was not awrae of is that when you persist your data, there is this table called JPOX_TABLES which keeps track of the class to table mapping. This is where the problem was. By simply changing the row in JPOX_TABLES to point to the new class location, the problem went away.
In the JPOX runtime confg information page, it has an entry for the parameter org.jpox.autoStartMechanism. It allows JPOX to read in from some source the classes that it was persisting the previous time. By setting it to none, its starts from scratch each time.
//properties.setProperty(“org.jpox.autoStartMechanism”, “None”);
that I undersatnd what is happening, i’ll leave the option alone which defaults to previous time configuration.

The next problem I encountered was related to using the jpox-1.1.0-alpha-2.jar or something. I was getting an exception when reading data in as noted here.
The error says : method getFetchPlan()Ljavax/jdo/FetchPlan; not found
Th news group mentions to take jdo.jar out of the classpath and it should work fine. I removed the file from WEB-INF/lib rebuilt the project, re-enhanced and it worked.

Following is the code I used to query the database with JPOX and parse the collection:

Transaction tx=pm.currentTransaction();
Extent e=pm.getExtent(app.SAT.class,true);
Query q=pm.newQuery(e, “autonomic_score
q.setOrdering(“autonomic_score ascending”);
Collection c=(Collection)q.execute();
Iterator iter = c.iterator();
SAT sa;
while (iter.hasNext())
sa =(SAT);

System.out.println (“Done”);

finally {pm.close();}

August 31, 2004 Posted by | JDO | Leave a comment


This site is by a retired IBMer who gives his take on displaying content.

August 30, 2004 Posted by | Web Design | 3 Comments

Second Struts Example

LogonForm (which extends ActionForm):
– getters/setters methods
– validate ((ActionMapping mapping,HttpServletRequest request) method
– reset(ActionMapping mapping,HttpServletRequest request) method

August 30, 2004 Posted by | Struts | 1 Comment

Apache Taglibs (JSTL)

In creating a dynamic project in eclipse (File -> New Project -> Web -> Dynamic web project) it gives you the option of adding struts support and taglibs support.

The Jakarta Taglibs is a free, open-source implementation of tag libraries developed under the Jakarta project at the Apache Software.

The web.xml file looks like this for struts and taglibs setup:

<?xml version=”1.0″ encoding=”UTF-8″?>
&lt!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN” “”&gt;

<web-app id=”WebApp” >
<display-name>its</display-name >


<taglib-uri></taglib-uri >

August 24, 2004 Posted by | Servlets & JSP | 1 Comment

Patterns 101

Design patterns are recurring solutions to problems in object-oriented design.

[ Patterns Home Page]

Java design patterns tutorial from IBM developer works. Note that I had to enter a user id and password to get access to the tutorial.

[Huston Patterns page]

Lucent Patterns page

SOA patterns

software class patterns

Try Java Blue Prints,
session facade

Noticed the Pet store demo on this page.

August 24, 2004 Posted by | Patterns & UML | Leave a comment

Eclipse on Linux

So eclipse can now be had on linux. I thought this was already the case. News of this here and here.
I guess this quote explains the change: “Previously, developers had to download the SDK and runtime separately. “Now, we’ve made it much simpler. You can get both of them at the same time”

August 23, 2004 Posted by | SW Tools | Leave a comment

MVC roles

Model (Databases, JavaBeans)
– Stores the application’s state
– Provides access to the application’s data as well as the business rules for modifying the data (accessors and business methods).
– Notifies view when state is changed

View (jsp, html)
– renders the content of the model
– access data from model and decide how to present it
– forward user input to controller

Controller (Servlets)
– defines application behavior
– it processes user input and maps them into actions to be performed by the model
– selects views to be rendered

August 23, 2004 Posted by | Patterns & UML | 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

First Struts Example

Using WSAD 5.1.1 for the Struts register example.
Note that I had to apply this fix to WSAD due to an error I was having with the EAR files.
In WASD I create a blank struts web project (with struts 1.0.2) and imported the WAR example file.
Some of the files in the WEB-INF to know about:


Lets start out with the register.jsp file:

<%@ taglib uri=”/WEB-INF/struts-form.tld” prefix=”form” %>
<form:form action=””>

enter password:<form:password property=”password1″/>
re-enter password:
<form:submit value=”Register”/>

The key thing here is that the jsp makes use of the struts form tag library, and submits the data to

Now lets take a look first at the web.xml and then the struts-config.xml file:

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN””&gt;

The key thing to note here is its using the web-app_2_2.dtd. Now on to the struts config file:

<?xml version=”1.0″ encoding=”ISO-8859-1″ ? >

<!DOCTYPE struts-config PUBLIC
“-//Apache Software Foundation//DTD Struts Configuration 1.0//EN””&gt;
<form-bean name=”registerForm” type=”app.RegisterForm”/>
<action path=”/register”
<forward name=”success” path=”/success.html”/>
<forward name=”failure” path=”/failure.html”/>

So, from the config xml file, its using the struts-config_1_0.dtd, specifies a form bean of
app.RegisterForm, specifies an action of app.RegisterAction, and contains two forwards of
success and failure.

So, in the java resources side of the project, we have a resources folder and a package called
app. One class in the app folder is the RegisterAction mentioned above, lets take a look:

package app;
import org.apache.struts.action.*;
import javax.servlet.http.*;
public class RegisterAction extends Action {
public ActionForward perform (ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
// (1) Cast the form to the RegisterForm
RegisterForm rf = (RegisterForm) form;
String username = rf.getUsername();
String password1 = rf.getPassword1();

String password2 = rf.getPassword2();

// (2) Apply business logic
if (password1.equals(password2)) {

try {
// (3) Return ActionForward for success
return mapping.findForward(“success”);
} catch (UserDirectoryException e) {
return mapping.findForward(“failure”);
// (4) Return ActionForward for failure
return mapping.findForward(“failure”);

So in this RegisterAction class (which inherits from the Action class),
we have method perform. On of the parms to the method is the ActionForm
which I’ll show you in just a sec. We cast the ActionForm parm as RegisterForm which
was specified in the struts config file. Lets go to that RegisteForm class now.

package app;
import org.apache.struts.action.*;
public class RegisterForm extends ActionForm {
protected String username;
protected String password1;
protected String password2;
public String getUsername () {return this.username;};
public String getPassword1() {return this.password1;};
public String getPassword2() {return this.password2;};
public void setUsername (String username) {this.username = username;};
public void setPassword1(String password) {this.password1 = password;};
public void setPassword2(String password) {this.password2 = password;};


package app;
import java.util.Enumeration;
import java.util.Properties;
public class UserDirectory {
private static final String UserDirectoryFile = “resources/”;
private static final String UserDirectoryHeader = “${user}=${password}”;
private static UserDirectory userDirectory = null;
private static Properties p;
private UserDirectory() throws UserDirectoryException { i = null;
p = null;
i = this.getClass().getClassLoader().
if (null==i) {
throw new UserDirectoryException();
else {
try {
p = new Properties();
catch ( e) {
p = null;
throw new UserDirectoryException();
finally {
i = null;
} // end else
} // end UserDirectory
public static UserDirectory getInstance() throws
UserDirectoryException {
if (null==userDirectory) {
userDirectory = new UserDirectory();
return userDirectory;
public String fixId(String userId) {
return userId.toUpperCase();
public boolean isValidPassword(String userId, String password) {
// no null passwords
if (null==password) return false;
// conform userId to uppercase
String _userId = fixId(userId);
// no passwords for non-users
if (!isUserExist(_userId)) return false;
// does password match user’s password
return (password.equals(getPassword(_userId)));
public boolean isUserExist(String userId) {
// no null users
if (null==userId) return false;
// if not null, it’s a user
return !(null==p.getProperty(userId));
public String getPassword(String userId) {
return p.getProperty(userId);
public Enumeration getUserIds() {
return p.propertyNames();
public void setUser(String userId, String password) throws
UserDirectoryException {
// no nulls
if ((null==userId) || (null==password)) {
throw new UserDirectoryException();
try {
// conform userId to uppercase when stored
p.put(fixId(userId), password);
String o = this.getClass().getClassLoader().getResource(UserDirectoryFile).getFile(); FileOutputStream(o), UserDirectoryHeader);
catch (IOException e) {
throw new UserDirectoryException();

August 16, 2004 Posted by | Struts | 2 Comments

BAM, kick it up a notch

IBM Readies Software for Real-Time Reports withBAM.

August 13, 2004 Posted by | SW Tools | Leave a comment

Another JPOX experience

It appears Matt Raible liked using JPOX .

I like JPOX as well. It is pretty easy to get going with this JDO product. The documentation has alot of usefull information. The main problem I had using JPOX is when I renamed the class / table, the presistence manager was for some reason was complaining about the old class name even though I enhanced the class with the new name.

August 13, 2004 Posted by | JDO | Leave a comment


JavaServer Pages Standard Tag Library (JSTL)

It says the the jwsdp kit which I downlaoded recently includes JSTL. Since the Web Services Pack supports a JSP 2.0 container and makes all JSTL jar files globally available to all web applications, you are all set to immediately take advantage of JSTL 1.1. In the JSTL lib folder within jwsdp their is a jstl.jar file.

The constituent tag libraries of Standard Taglib are as follows:

1. Core <c:tagname … >

2. XML processing <x:tagname … >

3. I18N capable formatting <fmt:tagname … >

4. Database access (SQL) <sql:tagname … >

5. EL Functions fn:fnname …

August 11, 2004 Posted by | Servlets & JSP | Leave a comment

Servlets – reference info

Introduction to servlets

JSP Expression  <%= expression %> Expression is evaluated and placed in output.

JSP Scriptlet  <% code %> Code is inserted in service method.

JSP Declaration <%! code %> Code is inserted in body of servlet class, outside of service method.

JSP page Directive <%@ page att="val" %>  Directions to the servlet engine about general setup.

Implicit objects:

  • import="package.class"
  • contentType="MIME-Type"
  • isThreadSafe="true|false"
  • session="true|false"
  • buffer="sizekb|none"
  • autoflush="true|false"
  • extends="package.class"
  • info="message"
  • errorPage="url"
  • isErrorPage="true|false"
  • language="java"

JSP comment <%– comment –%> Comment; ignored when JSP page is translated into servlet.

Several local variables are automatically declared by JSP:

  • request – javax.servlet.http.HttpServletRequest
  • response –  javax.servlet.http.HttpServletResponse
  • session – javax.servlet.http.HttpSession
  • config – javax.servlet.SErveltConfig
  • application – javax.servlet.ServletContext
  • out – javax.servlet.jsp.JspWriter

JavaServer Pages (JSP) technology provides you with a simple way to
build and maintain web pages with dynamically generated content.

JSP technology allows you to change the code that deals with the
dynamic content of a web page while leaving the HTML that deals
with the static content unchanged.

Your JSP page includes both standard HTML or XML tags and
special JSP tags.

JSP technology supports both standard and user-defined JSP tags.

JSP 101
A beginners guide.

JSP tutorial starts from simple examples and progresses to complex concepts.

Java Server Pages
Tutorial based on Sun Core Servlets and JSP book.
Servlet section is here.

Two key HTTP Request methods:

GET – Get a file and return its contents. In the context of a servlet, means send some dynamic content to the user as html.

POST – Used to send data to the server. It happens usually when you type some information into a html form and click the submit button.   

HTTP Responses:

Contains the HTTP version followed by a numeric 3 digit status code, and its associated textual phrase (for debugging purposes).
1xx :Informational – request recieved, continuing process
2xx : Success – action was successfully recieved, understood, and accepted.
3xx : Redirection: further action needed to complete the request.
4xx : Client Error – request contains bad syntax or cannot be fulfilled.
5xx: Server Error – sever failed to fulfill an apparently valid request.

/servlet/ part of the client URL.

javax.servlet package – Contains the Servlet interface.

Most servlets extend either GenericServlet or HttpServlet and override some or all of their methods with appropriate customized behaviors:

javax.servlet.GenericServlet- Defines a generic, protocol-independent servlet. It implements the Servlet and ServletConfig interfaces.To write a generic servlet, you need only override the abstract service method.

javax.servlet.http.HttpServlet – Web based servlets typically extend class HttpServlet class and must override at least one method, usually one of these:

  • void init( servletConfig config ) – this method is automatically called once during the servlet’s execution cycle to initialize the servlet.
  • void service( ServletRequest request, ServletResponse response ) – this is the first method called on every servlet to respond to a client request
  • void destroy() – this cleanup method is called when servlet is terminated by the server on which it is executing.
  • String get ServletInfo() – this method is defined by a servlet programmer to return String containing servlet information such as the servlet’s author and version.
  • doGet( ServletRequest request, ServletResponse response ), responds to an HTTP Get requests from a client, gets (or retrieves) information from the server (e.g., an HTML document or an image).
  • doPost( ServletRequest request, ServletResponse response ), respond to a HTTP Post requests from a client, a post request posts (or sends) data to the server (i.e., to send the server information from a HTML form in which the client enters data) so it can search the internet or query a database. 

The arguments HttpServletRequest and HttpServletResponse:

javax.servlet.http  (HttpServletRequest Interface) – Extends the ServletRequest interface:
getParameter – Returns the value of a request parameter. For HTTP servlets, parameters are contained in the query string or posted form data.
getAttribute – Returns the value of the named attribute as an Object.
setAttribute – Stores an attribute in this request.

javax.servlet.http  (HttpServletResponse Interface) – Extends the ServletResponse interface:
setContentType – Sets the content type of the response being sent to the client. The content type may include the type of character encoding used, for example, text/html;
Requests between servlets
jsp fwd action

August 11, 2004 Posted by | Servlets & JSP | Leave a comment

James on C#

James Gosling interview:

EA I’m curious about your opinion of some of the other languages that in some sense overlap Java. Notably, C#.

JG They did such a job of copying Java, it’s hard to criticize them. Imitation is the sincerest form of flattery.

August 10, 2004 Posted by | Patterns & UML | Leave a comment

On Demand

New Page 1

Service Oriented Enterprise
Patterns for SOA

Sam says

SOA Services Oriented Architectures – encapsulates software into service interfaces
are invoked by message passing. The preferred method of building
SOA is web services.

  • Architecture that leverages standards to represent software assets as services

  • Provides a standard way of representing and intercating with software assets
  • Used externally to integrate with apps outside of the enterprise
  • Service exposes only its interfaces to the rest of the system

Component Based Development (CBDI)

Main components in a SOA world are service providers and service requestors.

  • provider has some piece of code that performs a function that can be invoked
    across a network
  • requestor needs a piece of code that performs that function and has access
    to the provider’s network

Some implementations use a registry of services to help requestors find

  • Find: The requestor searches the known/trusted providers, or a registry, for a service description.
  • Bind: The requestor uses the service description to acess the provider and its
  • Publish: Providers publish their services to the registry so requestors can find

e-biz on demand operating environment

  • business processes: enable for web services
  • integrated end-to-end: use web services to integrate your data with your partnets, suppliers,
    customers, and so forth
  • respond with speed: use high level tools and languages to model and change your business processes quickly

Web services are functional elements deployed on a node on a network and
accessed over the Internet. A  Web service could be a piece of data
(such as the weather), a document (such as a credit report), or a file
of transactions (such as orders placed via an online marketplace), among
other things. 

Web services let companies bridge communications
gaps?between software written in different programming languages,
developed by different vendors or running on different operating

What make some functionality a web service is the "how" not the "what". 

IBM’s definition of web services: anything described by WSDL, services
are discoverable, and communicate using XML messages across industry standard

Web services are based on a set of standards:

SOAP (Simple Object
Access Protocol
): is an XML document format used to send information between endpoints.
A SOAP envelope can include a header (which contains metadata), and must
include a body (which contains the data). [1] [2] [3]







WSDL (Web Services Descripton
): A WSDL document describes the interface to a web service – the "how"

and "where" of a web service. It makes it possible for a requestor
to invoke a service after it has been discovered. The requestor uses WSDL
to learn what arguments are required for invoking the Web service. The
developers of the functional component use WSDL to define the metadata
describing the web service.   

UDDI  (Universal Description, Discovery and
): Used for service discovery and service publication. Clients of Web services
used UDDI to discover where the web services reside. Web services providers
use UDDI to publish their Web services.  

SOAP, WSDL, and UDDI are all based on


Services Primer

Services Guide



WebServices Zone

News on Web Services

August 9, 2004 Posted by | SOA | Leave a comment

Triangle Sports Radio

After years of the Buzz, now Triangle’s 1090 AM now has a solid new sports radio station. You know what competition does, it makes the products better. Stay tuned..

The station’s 3-7 show features Billy Packer’s son Mark Packer, who is known as the Packman.

For those who enjoy triangle sports, also check out Dave Sez. or my retired ncaa web site.

August 9, 2004 Posted by | Sports | Leave a comment

Using Struts

I started looking at struts recently.
I started off by downlaoding jdk1.4 and tomcat.
Make sure for some reason that your classpath has not only the location of the jdk bins, but also the tools jar file:
After extracting the tomcat zip file, I went to the the bin folder withinn the tomcat directory (c:/apache/jakarta-tomcat-5.0.27), clicked the startup bat file, and then in my web browser invoked the default url: http://localhost:8080/ and the tomcat home page is presented.
Next, it is on to the Apache Struts page. I went to the same apache downloads page and got the Struts 1.1 zip file.
The Struts zip file was extracted to c:/apache/jakarta-struts-1.1. In that folder there is a webapps folder with several war files. I will place the war files in the webapps folder in the tomcat folder. After placing the war files in the tomcat webapps folder, i noticed that new folders corresponding to the war files are created in the webapps folder. Also, you can grab the (war files) examples from Struts in action.

August 8, 2004 Posted by | Struts | 1 Comment

Java Server Faces

JSF – Its focus is in the V of an MVC architecture. Bill Dudney has a book out on JSF. Here is a link that takes you to article on JSF also authored by Dudney.

Redbook that combines JSF with SDO is here.

JSF presentation

Core JSF

One experience


August 7, 2004 Posted by | CommonJ, JSF | Leave a comment

JPOX keys

In running JPOX,
for the class element within the xml file, you have to specify a value for the identity-type attribute.
default is identity-type=datastorewhere you leave the aissignment of the IDs to JPOX.
The other choice is identity-type=applicationwhere the developer manages the specification of this identity.
Generating of unique ids for datastore identity is a mandatory.
The generation choices are via the database, JPOX provided poid routines, and user customized poid routines.

To configure a datastore identity class to use SequenceTablePoidGenerator you simply add :
<class name=”myclass” … >
<datastore-identity strategy=”factory” factory-class=”org.jpox.poid.SequenceTablePoidGenerator”/>


To configure a datastore identity class to use Auto-Increment (supported for db2) you simply add :
<class name=”myclass” … >
<datastore-identity strategy=”autoincrement”/>


August 5, 2004 Posted by | JDO | 1 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


JAXB is now available as part of the Java Web Services developer pack from Sun. While JAXB was in Beta, you could download Sun’s implemementation of JAXB seperately . It appears that is not the case anymore. Here is my page on sun. I have posted some messages to the various Sun forums on the problem I am having using JAXB. Here is an article on user feedback with JAXB. I may look into other JAXB implementations. Specifically, Apache’s open source JAXME2. Another one is XMLBeans.

I chose JAXME.

JAXME Manual
Featured article on JAXME

How to download: go to jaxme download page and scroll to bottom for distributions (src or bin).

I grabbed the two example files (build.xml and xsd file) from the article and placed them inside the new jaxme directory that was just created when the binaries tar file was extracted.

Edit the build file to set where the jar files are located (lib).
Invoke ‘ant generate’ and the neccesary files get generated in the generated folder.
As well as generating the source code, its creates two files (configuartion.xml and

XML file (schema instance):

< ?xml version=”1.0″ encoding=”UTF-8″? >
<stu:Student xmlns:stu=”;
xmlns:xsi=”; >
<stu:firstName>stu:firstName</stu:firstName >
<stu:lastName>stu:lastName</stu:lastName >
<stu:name>stu:name</stu:name >
<stu:street>stu:street</stu:street >
<stu:city>stu:city</stu:city >
<stu:state>stu:state</stu:state >
</stu:address >

Read XML:


import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.xml.sax.InputSource;

public class Main {

public static Student getAddress(InputSource pSource)
throws JAXBException {
JAXBContext context =
Unmarshaller unmarshaller = context.createUnmarshaller();
return (Student) unmarshaller.unmarshal(pSource);
public static void main(String[] args) throws Exception {
File f = new File(“src/student.xml”);
InputSource isource = new InputSource(new FileInputStream(f));
Student student = getAddress(isource);

August 4, 2004 Posted by | XML | Leave a comment

CVS with WSAD for apache

CVS > CVS Repositories from the Show View dialog
New > Repository Location
host name =
path = /home/cvspublic
userid = anoncvs
click finish, should be connected

August 4, 2004 Posted by | SW Tools | Leave a comment

More web tools for eclipse

So IBM has added Derby to Eclipse. I believe cloudscape comes with IBMs Portal project. In the Hibernate developers notebook, they use hsqldb as their database.

August 4, 2004 Posted by | SW Tools | Leave a comment

TV Humor

I watched Trading Spouses and The Last Comic Standing. Pretty funny.

August 3, 2004 Posted by | Television | Leave a comment

Enterprise Sevice Bus in news

ESB – one messaging fabric choice for underlying an SOA.

August 3, 2004 Posted by | SOA | 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

Evel Knievel

Evel story& movie on TNT.

August 1, 2004 Posted by | Television | Leave a comment