Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

Posts Tagged ‘AOP

The prefix “tx” for element “tx:advice” is not bound

with one comment

The prefix “tx” for element “tx:advice” is not bound

I was updating my code, to add in DB data insertion into 1 of my action class.
hit the above error “The prefix “tx” for element “tx:advice” is not bound”
From the error message, i think its complaining the missing of to define the schema location.
So, I add the schema location, and restart the tomcat…. eh, same error again?!
OK, i did a google and found out that, I not only missed to define the schema location;
I also forget to defind the “tx” header. (something like “tablib” in jsp).
So, I add in the following line “xmlns:xsi=”” and test again.
Wow, its working now!

Lessons Learned:
The root cause of this error is missing the “xmlns:tx” being defined in applicationContext.xml

Final applicationContext.xml header:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""


Written by Alfred

October 17, 2008 at 17:58

Posted in Java, Spring

Tagged with , ,

No Hibernate Session bound to thread

with one comment

I hit an error “No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here” while I’m doing unit testing in an application that combining Spring Batch and Hibernate. This problem exists when I try to do some data insertion at the Spring Batch Listener.

The root of this problem occurred is because there is NO hibernate session at the Spring Batch Listener level. How come?!?! Its because the AOP pointcut I defined and use throughout the application is at the Batch JobRepository
<aop:advisor pointcut="execution(* org.springframework.batch.core..*Repository+.*(..))"
advice-ref="txAdvice" />

But the Batch Listener is not under the same / child package of the JobRepository. The Listener is under org.springframework.batch.core.StepExecutionListener. To ease the configuration, I add in another pointcut at my business package
The AOP pointcut I added is:
<aop:advisor pointcut="execution(*"
advice-ref="txAdvice" />

Lessons Learned:
1. Identified where is the point cuts, is that the existing pointcut is enough for me?

Written by Alfred

April 23, 2008 at 10:40

Posted in Java

Tagged with , , ,