Tuesday, 24 January 2012

WebSphere Commerce Logging

For method entry and exits, instead of the syntax below:

·        LOGGER.entering(CLASSNAME, METHOD_NAME);
·        LOGGER.exiting(CLASSNAME, METHOD_NAME);

instead of things like:

·       LOGGER.logp(Level.INFO,CLASSNAME, METHODNAME,"entering");

For exception logging:
  //You can put any detailed description you need and don’t forgert to use SEVERE or a least WARN
LOGGER.log(Level.SEVERE,"Exception caused by "+e.getMessage(), e);

instead of:


·         e.printStackTrace();

General comment:

It is recommended to surround all level with an if statement as shown in the two examples below:

if(LOGGER.isLoggable(WsLevel.FINE)){
   LOGGER.logp(Level.FINE, CLASSNAME, METHOD_NAME, "Test1: "+test2);
}
if(LOGGER.isLoggable(WsLevel.FINEST)){
  LOGGER.logp(Level.FINEST, CLASSNAME, METHOD_NAME, "Test2: "+test2);
}


Instead of just
  LOGGER.logp(Level.FINE, CLASSNAME, METHOD_NAME, "Test1: "+test1);
 LOGGER.logp(Level.FINEST, CLASSNAME, METHOD_NAME, "Test2: "+test2);

to preserve memory during normal operation and avoid filling the String pool with objects which will not be used.

There is no need to do so with SEVERE (INFO and WARN) too as it is used with exceptions most of the time and is always enabled.


Monday, 6 June 2011

WebSphere bad major version at offset=6

Problem:
The error message below showed up while trying to access a Servlet deployed on WebSphere 6.1.
Error 500: bad major version at offset=6 

Resolution:
The web project was set to target runtime of WebSphere Application Server 7.0 which uses JDK 6.0 while WebSphere 6.1 requires JDK 5.0. To resolve the problem, you have one of two options:
  • Change the target runtime to WebSphere Application Server 6.1 or
  • Follow the following the steps (useful if you don't have WebSphere 6.1 test environment):
    1. Open project properties in Rational application developer
    2. Change compiler compliance level to 1.5 as shown in figure 1
    3. Go to project facets and change Java from 6.0 to 5.0 as shown in figure 2
Figure 1
Figure 2