cktechnical
Tuesday, March 22, 2005
 
SQL30020N - Execution failed because of a Distributed Protocol Error

The following error showed up in our logs for our Electronic Approval System. Whenever this error hits we get a deadlock on our table (pbba.bbab10t) that causes users to be unable to approve documents. This is a very frustrating error. It has been very tough to track.

The error is as follows:

COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL30020N Execution failed because of a Distributed Protocol Error that will affect the successful execution of subsequent commands and SQL statements: Reason Code "1232". SQLSTATE=58009

1232
The command could not be completed because of a permanent error. In most cases, the server will be in the process of an abend.

SQL30020N
Execution failed because of a Distributed Protocol Error that will affect the successful execution of subsequent commands and SQL statements: Reason Code "".
Explanation: A system error occurred that prevented successful execution of the current environment command or SQL statement, as well as any subsequent commands or SQL statements.
The command or statement cannot be processed. The current transaction is rolled back and the application is disconnected from the remote database.
User Response: Record the message number (SQLCODE) and the reason code. Record all error information from the SQLCA, if possible. Attempt to connect the remote database and rerun the application.
If sufficient memory resources exist and the problem continues, invoke the Independent Trace Facility at the operating system command prompt. Refer to the Independent Trace Facility in the Troubleshooting Guide for information on how to use this facility.

The Line of code that was executed before this Exception was thrown is the following:
[3/22/05 14:56:52:391 CST] 9c75565 SystemErr R at webapr.db.DBApprovalController.getCriteriaOrder(DBApprovalController.java(Compiled Code))
[3/22/05 14:56:52:391 CST] 9c75565 SystemErr R at webapr.ApprovalController.isCriterionMatchForSigner(ApprovalController.java(Compiled Code))
[3/22/05 14:56:52:391 CST] 9c75565 SystemErr R at webapr.ApprovalController.createUnitWaitingItems(ApprovalController.java(Compiled Code))
[3/22/05 14:56:52:391 CST] 9c75565 SystemErr R at webapr.ApprovalController.updateWaitingItems(ApprovalController.java(Compiled Code))
[3/22/05 14:56:52:391 CST] 9c75565 SystemErr R at webapr.docvalidation.ValidationPageBean.checkUpdateWaitingItems(ValidationPageBean.java:351)
[3/22/05 14:56:52:391 CST] 9c75565 SystemErr R at webapr.docvalidation.ValidationPageBean.processRequest(ValidationPageBean.java:200)

Later I got the following error log:
[3/22/05 15:23:57:234 CST] 815d565 SystemErr R COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0913N Unsuccessful execution caused by deadlock or timeout. Reason code "00C9008E". SQLSTATE=57033
[3/22/05 15:23:57:234 CST] 815d565 SystemErr R at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java:261)[3/22/05 15:23:57:234 CST] 815d565 SystemErr R at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java(Inlined Compiled Code))[3/22/05 15:23:57:234 CST] 815d565 SystemErr R at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExceptionGenerator.java(Compiled Code))[3/22/05 15:23:57:234 CST] 815d565 SystemErr R at COM.ibm.db2.jdbc.app.DB2Statement.execute2(DB2Statement.java(Compiled Code))[3/22/05 15:23:57:234 CST] 815d565 SystemErr R at COM.ibm.db2.jdbc.app.DB2Statement.executeQuery(DB2Statement.java(Compiled Code))[3/22/05 15:23:57:250 CST] 815d565 SystemErr R at edu.uga.busfin.dfs.db.DBAccess.query(DBAccess.java(Compiled Code))[3/22/05 15:23:57:250 CST] 815d565 SystemErr R at webapr.db.DBApprovalController.getCurrentApprovalGroupLevel(DBApprovalController.java:46)[3/22/05 15:23:57:250 CST] 815d565 SystemErr R at webapr.ApprovalController.updateWaitingItems(ApprovalController.java(Compiled Code))[3/22/05 15:23:57:250 CST] 815d565 SystemErr R at webapr.docvalidation.ValidationPageBean.checkUpdateWaitingItems(ValidationPageBean.java:351)[3/22/05 15:23:57:250 CST] 815d565 SystemErr R at webapr.docvalidation.ValidationPageBean.processRequest(ValidationPageBean.java:200)

...
I feel like the error must be the fact that the following sequence of events happens in this old code...

Snippet from ValidationPageBean:
public void processRequest(Object objReqRes){
Object [] objArr = (Object[])objReqRes;
HttpServletRequest request = (HttpServletRequest)objArr[0];
HttpServletResponse response = (HttpServletResponse)objArr[1];
this.request = request;
context = request.getSession().getServletContext();
con = DBUtil.getSysConnection(context); //ESTABLISHES A CONNECTION
...
// Place all of the logic within a try{} so that we may rollback
// the entire transaction if we get an error in our messages object.
try{ (191)
con.setAutoCommit(false); // sets the auto commit to false


Snippet from ApprovalController:
public boolean updateWaitingItems(Document document) {
this.conn = DBUtil.getSysConnection(context); // ESTABLISHES ITS OWN CONNECTION!!!
this.db = new DBApprovalController(this);
setDebug();
this.document = document;
this.groupLevel = db.getCurrentApprovalGroupLevel(conn, document);

My best guess on this error is that the connection that is set to autoCommit(false) in the ValidationPageBean should be used in the ApprovalController object that the ValidationPageBean creates in its checkUpdateWaitingItems method:

private void checkUpdateWaitingItems(ServletContext context, Document document, String validationCode){
if(document.getDocHead().getHeaderElecApprCode().equals("P")){
if(wasDocumentChanged(document, validationCode)){
this.appCon = new ApprovalController(context, this.user);
this.appCon.setConn(con);
if(!this.appCon.updateWaitingItems(document)){
this.appCon.appendMessages(this.messages);
}
}
}
}

Well, after much investigation I found out what the error was. Seems some legacy code was creating a nice little infinite loop when it was comparing units on a document versus units in our tracking table. So, I completely scrapped the old updateWaitingItems logic in the ApprovalController and replaced it with some testable code that works much faster, is more intuitive, and much easier to maintain.
This issue has been resolved and has been moved into our production environment before another user steps into an infinite loop by making changes to a document and submitting it to the approval system.


Thursday, March 17, 2005
 
Websphere Server 5.1 Tweaking
Article that describes how to instantiate the Tivoli Performance Monitor to view the activity on a Websphere Server.
Tivoli Performance Monitor

I still need to figure out what is eating up the memory on our server.
 
Webspher Error: No WebApplicationContext found: no ContextLoaderListener registered?
I was getting the following error when I added a brand new application to the Webpher production machine. The problem is the following: For Servlet 2.2 containers and Servlet 2.3 ones that do not initalize listeners before servlets, use ContextLoaderServlet. See the latter's Javadoc for details. IBM Websphere Application Server 5.1.1 operates its container at Servlet 2.3 and thus the listener is not registered before the servlets and therefore I get errors.
More Here
I fixed this error by changing the following in the web.xml file:

**this used to be the way we started the ContextLoaderListner for Spring but this stopped working.

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

the servlet method below works fine on the Webspher production server... I need to find out why the listner is not working.
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

[3/17/05 15:33:47:422 CST] 715abdb4 WebGroup E
SRVE0026E: [Servlet Error]-[action]:
java.lang.IllegalStateException: No WebApplicationContext
found: no ContextLoaderListener registered?
at org.springframework.web.context.support.WebApplicationContextU
tils.getRequiredWebApplicationContext
(WebApplicationContextUtils.java:69)
at edu.uga.busfin.budamd.web.ElectronicApprovalBaseDispatchAction
.setServlet(ElectronicApprovalBaseDispatchAction.java:35)
at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:297)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:220)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119) at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

Thursday, March 10, 2005
 
JasperReports Installation and Setup in WebSphere Studio 5.1.1
Wow!

I love JasperReports!

Alright, I had to download JasperAssistant and JasperReports version 0.6.4 and iText-1.2.jar to get everything running.

Since I am using WSAD 5.1.1 I needed to install JasperAssistant like so:
1. I downloaded JasperAssistant_1.5.1_Eclipse2.1.3.zip
2. I unzipped the .zip file and found a features folder and a plugins folder.
3. I placed plugins/com.jasperassistant.designer_1.5.1 into the c:/program files/ibm/websphere studio/eclipse/plugins folder.
4. I placed the features/com.jasperassistant.designer_1.5.1 into the c:/program files/ibm/websphere studio/eclipse/features folder.
5. I started up Websphere Studio 5.1.1 and whaddayaknow JasperAssistant's Welcome screen appeared.

Then I simply created a DataSource that implements JRDataSource and added a constructor that recieves a List of objects. (in this case County objects)

The class that I needed to create looks like the following:

public class WorkCountyDataSource implements JRDataSource{

public WorkCountyDataSource(List list){
this.data = list;
}

private List data;
private int index;

/* (non-Javadoc)
* @see net.sf.jasperreports.engine.JRDataSource#next()
*/
public boolean next() throws JRException {
index ++;
return (index < data.size());
}

/* (non-Javadoc)
* @see net.sf.jasperreports.engine.JRDataSource#getFieldValue(net.sf.jasperreports.engine.JRField)
*/
public Object getFieldValue(JRField field) throws JRException {
County county = (County) data.get(index);
Object value = null;
try{
Object [] args = { };
Class [] paramTypes = { };
Class countyClass = county.getClass();
Method getMethod = countyClass.getMethod(field.getName(), paramTypes);
value = getMethod.invoke(county, args);

}
catch(Exception e){
throw new JRException(e.getMessage());
}
return value;
}

}
My WorkCountyReportAction class looks like the following:

public ActionForward unspecified(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception{

// Get the userid out of the session
String userId = getUser(request.getSession());
if(StringUtils.isEmpty(userId)){
return mapping.findForward("logoff");
}

BudgetDevelopmentManager mgr = (BudgetDevelopmentManager) getBean("budgetDevelopmentManager");

List workCounties = mgr.getWorkCounties();

Map parameterMap = new HashMap();
parameterMap.put("countyId", "Something Crazy");

WorkCountyDataSource workCountyDataSource = new WorkCountyDataSource(workCounties);

response.setContentType("application/pdf");
try {
JasperRunManager.runReportToPdfStream(
getClass().getClassLoader().getResourceAsStream(
"/WEB-INF/reports/workCounty.jasper"),
response.getOutputStream(),
parameterMap,
workCountyDataSource
);
} catch (Exception e) {
e.printStackTrace(System.out);
}

// return to the page that invoked this action
return null;
}



JasperAssistant:
http://www.jasperassistant.com/installation.html
http://www.jasperassistant.com/download.html

iText:
http://www.lowagie.com/iText/download.html

JasperReports:
http://jasperreports.sourceforge.net/
http://sourceforge.net/projects/jasperreports


Powered by Blogger