Saturday, February 18, 2017

JDB is your friend

We had recently an issue with an XML parser failing to parse a temporary file that was immediately deleted after.
How to stop execution before the file gets deleted?
I am using jdb and I have created a simple test case

Start WebLogic with
set JAVA_OPTIONS=-agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n %JAVA_OPTIONS%

I deploy a small webapp with:

class com.pierre.MyCounter

package com.pierre;
public class MyCounter {
       static int count = 0;
       public static String getCountAsString() {
             return String.valueOf(count++);

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ page import="com.pierre.*"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here bla</title>
The count is:
I hope you are happy.


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="" xmlns:xsi="">

Then run from a command line :
jdb -attach jdbconn

run your case once to make sure the MyCounter class has already been loaded, then run


to check if the MyCounter is there, then run this to set a breakpoint:

stop at com.pierre.MyCounter:6

next time you run the jsp, the breakpoint is hit and execution stops

No comments: