spring callable not working - spring

I am trying to implement long polling using spring,here is the sample code
Here is the code for my async method:
#RequestMapping(value= "failed.html" ,method = RequestMethod.POST)
protected Callable<String> callable(#ModelAttribute("user") Message user1, BindingResult bindingResult){
return new Callable<String>() {
#Override
public String call() throws Exception {
System.out.println("call--------->");
Thread.sleep(2000);
return "success";
}
};
}
Here is the callablecontroller-servlet.xml:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<bean id= "viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"><value></value></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="callable" class="spring.controller.CallableController">
</bean>
However "call------------" is never printed in the console and it displays failed.jsp instead of success.jsp. Any help would be appreciated.

My first suspicion is about the arguments to the callable method.
Try adding a ExceptionHandler to your controller class as follows, to know whats going wrong:
#ExceptionHandler
#ResponseBody
public String handleException(IllegalStateException ex) {
System.out.println("Exception --------->");
return "Handled exception: " + ex.getMessage();
}

Related

No bean named '##' is defined serverless framework Spring

I have this problem, I'm working with Spring, Hibernate, JPA and serverless framework.
When I invoke the class form the console I got this error "
"errorMessage": "No bean named 'wizardDao' is defined",
"errorType": "org.springframework.beans.factory.NoSuchBeanDefinitionException",
"stackTrace": [
"org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:694)",
"org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168)",
"org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281)",
"org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)",
"org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)",
"com.serverless.dao.Handler.handleRequest(Handler.java:30)",
"com.serverless.dao.Handler.handleRequest(Handler.java:17)"
but if I prove the class in Eclipse with I main class there's not problema. I don't know what is going wrong
this is my applicationContext
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd">
<context:component-scan base-package="com.serverless" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="Things-serverless" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<task:scheduler id="taskScheduler" />
<task:executor id="taskExecutor" pool-size="1" />
<task:annotation-driven executor="taskExecutor"
scheduler="taskScheduler" />
<!-- <bean id="serviceBean" class="com.serverless.test" /> -->
</beans>
this is my dao class
#Component
public class WizardDao extends ForwardedMessageDao {
private static final long serialVersionUID = 5302145657830590489L;
/**
* Get all wizards from data base.
*
* #param
* #return List of wizards
*/
#SuppressWarnings("unchecked")
public List<Wizard> getAllWizards() {
Query query = getEmf().createQuery("FROM Wizard");
System.out.println("aqui ");
return (List<Wizard>) query.getResultList();
}
}
and this is my handdler class
#Service
#Transactional
public class Handler implements RequestHandler<Map<String, Object>, ApiGatewayResponse> {
private static final Logger LOG = Logger.getLogger(Handler.class);
#Autowired
private WizardDao wizardDao;
#Override
public ApiGatewayResponse handleRequest(Map<String, Object> input, Context context) {
BasicConfigurator.configure();
Map<String, Wizard> response = new HashMap<>();
Response responseBody = new Response("start", response);
try {
wizardDao = Application.getBean(WizardDao.class);
List<Wizard> listWizard = wizardDao.getAllWizards();
for (Wizard wizard : listWizard) {
response.put("" + wizard.getIdWizard(), wizard);
}
responseBody.setInput(response);
} catch (Exception e) {
responseBody.setMessage("Fail: " + e.getMessage());
}
LOG.info("received: " + input);
return ApiGatewayResponse.builder().setStatusCode(200).setObjectBody(responseBody)
.setHeaders(Collections.singletonMap("fur", "this sheep")).build();
}
}
and this is my entityManager Class
public class EntityManagerDao implements Serializable {
private static final long serialVersionUID = -6969245506190987187L;
#PersistenceContext(unitName = "Things-serverless")
private EntityManager em;
/**
* #return the em
*/
public EntityManager getEmf() {
return em;
}
}

Connect to hbase from remote machine

I have VM where habse is installed.
IP:192.168.20.10
I want to try to connect to hbase from my desktop:
Here is what I am trying>
public static void main(String[] args) throws IOException {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/hbase-beans.xml", HBaseConnection.class);
context.registerShutdownHook();
UserRepository userRepository = context.getBean(UserRepository.class);
List<User> users = userRepository.findAll();
System.out.println("Number of users = " + users.size());
System.out.println(users);
}
public List<User> findAll() {
return hbaseTemplate.find(tableName, "cfInfo", new RowMapper<User>() {
public User mapRow(Result result, int rowNum) throws Exception {
return new User(Bytes.toString(result.getValue(CF_INFO, qUser)),
Bytes.toString(result.getValue(CF_INFO, qEmail)),
Bytes.toString(result.getValue(CF_INFO, qPassword))
);
}
});
}
And this is my bean.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:hadoop="http://www.springframework.org/schema/hadoop" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<context:component-scan base-package="com.hbase.dao"/>
<context:component-scan base-package="com.hbase.object"/>
<hadoop:configuration id="hadoopConfiguration">fs.default.name=hdfs://192.168.20.10:9000</hadoop:configuration>
<hadoop:hbase-configuration configuration-ref="hadoopConfiguration" zk-port="2181" zk-quorum="192.168.20.10"></hadoop:hbase-configuration>
<bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
<property name="configuration" ref="hbaseConfiguration" />
</bean>
</beans>
This code works fine when I run directly in remote machine.When I am running same code from my windows machine by providing ip of hbase .,it doesnot return any value.
Configure your windows machine C:\Windows\System32\drivers\etc\hosts
file to resolve your HBase cluster node details. Recommended Make sure
DNS configuration is right!. i.e. addresses of all
nodes(Regionservers) of HBase Cluster is resolved from windows
machine.

migrate hibernateTemplate to JPA 2 (executeWithNativeSession - doInHibernate)

I am migrating my code from hibernate 3 (that is using hibernate template) to JPA 2. My project is using Spring as well.
Current project is using hibernatetempate as
hibernateTemplate.executeWithNativeSession(new HibernateCallback<Object>() {
#Override
public Object doInHibernate(Session session) throws SQLException {
Query query = session.getNamedQuery("updateToProcessed");
query.setParameter("Id", id);
return query.executeUpdate();
}
});
updateToProcessed is a simple update hql query. Please help to let me know how to convert it to JPA (to use entityManager)
I tried using
Query query = entityManager.createNamedQuery("updateToProcessed");
query.setParameter("Id", id);
query.executeUpdate();
Complete method is
#Override
public void updateAllBatchDetails(final String id) {
Query query = entityManager.createNamedQuery("updateToProcessed");
query.setParameter("Id", id);
query.executeUpdate();
}
But I am getting error as:
Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:333)
at com.sun.proxy.$Proxy143.executeUpdate(Unknown Source)
I have configured transactionManager in applicationContext.xml like
I was expecting this answer and I have already configured that in applicationContext.xml but still I am getting that error
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
But somehow #Transactional is working that I don't want to use.
This is the applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:component-scan base-package="com.batch"/>
<context:annotation-config/>
<context:spring-configured/>
<context:property-placeholder location="classpath:batch.properties"/>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
<aop:aspectj-autoproxy/>
<import resource="classpath:core/applicationContext.xml"/>
<import resource="classpath:spring/applicationContext-resources.xml"/>
<import resource="classpath:spring/applicationContext-batch.xml"/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistenceUnitName="default"
p:jpaVendorAdapter-ref="jpaVendorAdapter"
p:dataSource-ref="dataSource" />
<bean id="batchProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"
p:location="classpath:batch.properties"/>
</beans>
To execute a bulk update you should do like below:
final String updateQuery = "update Person p SET p.name = 'Other Name'";
final int update = entityManager.createQuery(updateQuery).executeUpdate();
System.out.println("updated rows " + update);
Spring will handle the commit for you. [=
Edit: Caused by: javax.persistence.TransactionRequiredException
Have you configured the Transaction? To execute a update you must open a transaction.
With Spring you could use the annotation #Transactional in the method.
For this problem use a Tasklet where you execute your query.
Configure a step using a TaskletStep and you can set 'transaction manager' as well as 'transaction attributes' and errors should go away.

404 Error on using Spring AOP Logging

I was trying to add AOP logger to the existing Spring(v3.1.3) application. Below is the code for the same.
Application launches successfully and am able to login. But, once the flow reaches the Controller that's specified in the ApplicationLogger.java, am getting 404 error in the screen and unfortunately aint getting any error trace in the console. Not getting any clue.
Kindly help me out to find where i have gone wrong.
TIA,
Arun
SERVLET.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" >
<context:annotation-config />
<mvc:annotation-driven />
<!-- Enables the caching through annotations -->
<cache:annotation-driven />
<aop:aspectj-autoproxy />
<bean id="appLogger"
class="com.pmc.crm.risk.util.ApplicationLogger" />
.
.
.
ApplicationLogger.java
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
#Aspect
public class ApplicationLogger
{
/**
* Log method entry.
*
* #param joinPoint
*/
#Before("execution(* com.pmc.crm.risk.mvc.controller.SearchController.loadParamSearch(..))")
public void logEntry(final JoinPoint joinPoint)
{
System.out.println("*--*-*-*-* LOG ENTRY -*-*-*");
log("Entering method " + joinPoint.getSignature().getName() + "...");
}
/**
* Log method exit.
*
* #param joinPoint
*/
#After("execution(* com.pmc.crm.risk.mvc.controller.SearchController.loadParamSearch(..))")
public void logExit(final JoinPoint joinPoint)
{
System.out.println("*--*-*-*-* LOG EXIT -*-*-*");
log("Exiting method " + joinPoint.getSignature().getName() + ".");
}
SEARCHCONTROLLER.java
package com.pmc.crm.risk.mvc.controller;
import ....
#Controller
public class SearchController extends AbstractPolicyController{
private static final Logger LOG = Logger.getLogger(SearchController.class);
#RequestMapping(value = "/loadParamSearch.htm", method = RequestMethod.GET)
public ModelAndView loadParamSearch(HttpServletRequest request, HttpServletResponse response,ModelMap model) throws Exception{
try
{
System.out.println("...");
}
.
.
AbstractPolicyController was actually implementing an interface and servlet couldnt inject a proxy for the same (Investigating on the reason.) On removing the 'implements interfaceName' it worked good. Anyone who know the reason may pls let me know.

Using tx:annotation-driven prevents Autowiring a bean

I'm developing a module on an OSGi application, using Spring MVC and Virgo Webserver.
On my module I have a Controller, that access a Manager, which has a list of handlers that are responsible for handling report generation.
Everything was doing fine until I had to call a transactional method from an external service. Since none of my classes were transactional I had to add the references to the transation manager and annotation-driven. Then, my Manager stopped being notified.
I understand that when using annotation-driven all my beans must implement a public interface in order for the proxying mechanism to work. And as far as I know, all the classes are (one of them wasn't, but then I changed it).
My configuration files are:
bundle-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:annotation-config />
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="reportManager" class="reportmodule.manager.impl.ReportManagerImpl"/>
<bean id="mvpepReportHandler" class="reportmodule.manager.impl.MVPEPReportHandler"/>
<bean id="reportConfigDao" class="reportmodule.repository.impl.ReportConfigurationHibernateDAOImpl"/>
<bean id="oSGIChangeReportHandler" class="reportmodule.osgi.impl.OSGIChangeReportHandlerImpl"/>
<bean id="reportController"
class="reportmodule.controller.impl.ReportControllerImpl"/>
<bean id="reportControllerHandlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>/module/reportController/**=reportController</value>
</property>
<property name="alwaysUseFullPath" value="true"></property>
</bean>
</beans>
and my bundle-osgi.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:osgi-compendium="http://www.springframework.org/schema/osgi-compendium"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium-1.2.xsd">
<osgi:reference id="transactionManager" interface="org.springframework.transaction.PlatformTransactionManager" />
<osgi:reference id="sessionFactory" interface="org.hibernate.SessionFactory" />
<osgi:reference id="smaCoreUtilService" interface="core.util.service.SmaCoreUtilService" />
<osgi:service ref="reportControllerHandlerMapping"
interface="org.springframework.web.servlet.HandlerMapping"
context-class-loader="service-provider"
auto-export="interfaces"/>
<osgi:service interface="reportmodule.api.manager.ReportManager" ref="reportManager" auto-export="interfaces"/>
<osgi:service interface="reportmodule.api.manager.ReportHandler" ref="mvpepReportHandler" auto-export="interfaces"/>
<osgi:service interface="reportmodule.repository.ReportConfigurationDAO" ref="reportConfigDao" auto-export="interfaces"/>
<osgi:service interface="reportmodule.osgi.OSGIChangeReportHandler" ref="oSGIChangeReportHandler" auto-export="interfaces"/>
<osgi:list cardinality="0..N" id="reportHandler" interface="reportmodule.api.manager.ReportHandler" greedy-proxying="true">
<osgi:listener ref="oSGIChangeReportHandler" bind-method="register" unbind-method="unregister"/>
</osgi:list>
</beans>
So, after all the services are being published the oSGIChangeReportHandler.register is called (I'm able to debbug it):
#Service(value="oSGIChangeReportHandler")
public class OSGIChangeReportHandlerImpl implements OSGIChangeReportHandler {
private ReportManager reportManager;
/**
* #param reportManager the reportManager to set
*/
#Autowired
public void setReportManager(ReportManager reportManager) {
this.reportManager = reportManager;
}
#SuppressWarnings("rawtypes")
public void register(ReportHandler reportHandler, Map properties) {
reportManager.addReportHandler(reportHandler);
}
#SuppressWarnings("rawtypes")
public void unregister(ReportHandler reportHandler, Map properties) {
reportManager.removeReportHandler(reportHandler);
}
}
And although the debugger shows Proxies for both the reportManager and reportHandler on the register method, the debugger does not halts on the ReportManagerImpl.addReportHandler method:
#Service(value="reportManager")
#Transactional(propagation = Propagation.MANDATORY, rollbackFor = Exception.class)
public class ReportManagerImpl implements ReportManager {
private ReportConfigurationDAO reportConfigurationDAO;
private ArrayList<ReportHandler> reportHandlers = new ArrayList<ReportHandler>();
/**
* #param reportConfigurationDAO the reportConfigurationDAO to set
*/
#Autowired
public void setReportConfigurationDAO(ReportConfigurationDAO reportConfigurationDAO) {
this.reportConfigurationDAO = reportConfigurationDAO;
}
#Override
#Transactional
public InputStream gerarRelatorio(ReportRequest repoReq) throws NegocioException {
// Generates the report...
}
/* (non-Javadoc)
* #see reportmodule.api.manager.ReportManager#addReportHandler(reportmodule.api.manager.ReportHandler)
*/
#Override
public void addReportHandler(ReportHandler handler) {
if (handler != null) {
this.reportHandlers.add(handler);
}
}
/* (non-Javadoc)
* #see reportmodule.api.manager.ReportManager#removeReportHandler(reportmodule.api.manager.ReportHandler)
*/
#Override
public void removeReportHandler(ReportHandler handler) {
if (handler != null) {
this.reportHandlers.remove(handler);
}
}
}
I must stress that when I remove the tx:annotation-driven tag from the bundle-context.xml file, everything works fine (the handler is properly added to the list during startup).
So, what am I missing here?
Problem solved!
As you can see on my code above, I was defining the beans both via XML and Annotation, thus every bean was duplicated in runtime. Then, when I added the tx:annotation-driven tag the application begun intercepting the wrong bean. It was indeed notifying a bean, but an orphan bean.
HereĀ“s an example working with tx. Look this line:
xmlns:tx="http://www.springframework.org/schema/tx"
and this on schemaLocation:
http://www.springframework.org/schema/tx/spring-tx.xsd
Source:
http://www.springbyexample.org/examples/hibernate-transaction-annotation-config.html

Resources