Hi,
JBOSS Version = jboss-4.0.3SP1.
In
JSP Page i'm using custom taglib to manage the transaction
<demo:transaction>
CRUD Operations going here and I'm using CMP Beans for that
</demo:transaction>
and the tag class is TransactionTag which is explained here
import java.util.Collection;
import java.util.Vector;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.TryCatchFinally;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
public class TransactionTag extends BodyTagSupport implements TryCatchFinally {
private static UserTransaction transaction = null;
private static Collection activeThreads = null;
public TransactionTag() {
super();
}
public void setPageContext(PageContext pageContext) {
super.setPageContext(pageContext);
if (transaction == null) {
try {
Context context = (Context)getInitialContextStatic();
transaction = (UserTransaction) context.lookup("UserTransaction");
activeThreads = new Vector();
} catch (Exception e) {
throw new CascadingRuntimeException(e);
}
}
}
public int doStartTag() throws JspException {
try {
if (transaction.getStatus() != Status.STATUS_ACTIVE) {
activeThreads.add(Thread.currentThread());
transaction.begin();
}
} catch (Exception e) {
throw new JspException(e.getMessage(), e);
}
return EVAL_PAGE;
}
public void doCatch(Throwable t) throws Throwable {
if (activeThreads.contains(Thread.currentThread())) {
activeThreads.remove(Thread.currentThread());
if (transaction.getStatus() == Status.STATUS_ACTIVE) {
try {
transaction.rollback();
} catch (Exception e) {
}
}
}
throw t;
}
public void doFinally() {
if (activeThreads.contains(Thread.currentThread())) {
activeThreads.remove(Thread.currentThread());
try {
transaction.commit();
} catch (Exception e) {
try {
transaction.rollback();
} catch (Exception e1) {
}
throw new CascadingRuntimeException(e);
}
}
}
public void removeThread() {
if (activeThreads.contains(Thread.currentThread())) {
activeThreads.remove(Thread.currentThread());
}
}
public InitialContext getInitialContextStatic() {
Hashtable hashTable = new Hashtable();
hashTable.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
hashTable.put(Context.PROVIDER_URL, "jnp://localhost:1099");
hashTable.put(Context.URL_PKG_PREFIXES, "org.jboss.naming
rg.jnp.interfaces");
return new InitialContext(hashTable);
}
}
When i run the jsp page the contents between the demo:transaction tag is not executing properly. I am getting blank page and without any error. Is this because of Usertransaction or some other issue.
It is working fine with weblogic 8.1
Is that any usertransaction configuration that i'm missing.
Thanks in advance