aspose file tools
The moose likes Spring and the fly likes usertransaction.begin(); gets java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "usertransaction.begin(); gets java.lang.NullPointerException" Watch "usertransaction.begin(); gets java.lang.NullPointerException" New topic

usertransaction.begin(); gets java.lang.NullPointerException

sagar chandgude

Joined: Nov 09, 2010
Posts: 5
Our applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<bean id="WASTranMgr" class="" factory-method="getUOWManager"/>
<bean id="transactionManager"
<property name="uowManager" ref="WASTranMgr"/>
<property name="autodetectUserTransaction" value="false"/>

<bean id="sender" class="test.Sender"/>
<property name="txManager" >
<ref bean="transactionManager"/>

<bean id="receiver" class="test.Receiver"/>

& our code that is having actual call to begin()

private static JtaTransactionManager txManager;

public JtaTransactionManager getTxManager() {
return txManager;

public void setTxManager(JtaTransactionManager txManager) {
this.txManager = txManager;
static UserTransaction usertransaction =null;
private static BeanFactory beanFactory =null;
public static void main(String[] args) throws SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SystemException, NotSupportedException {
// TODO Auto-generated method stub
beanFactory = new XmlBeanFactory(new ClassPathResource("/test/applicationContext.xml"));
Sender s=(Sender)beanFactory.getBean("sender");

UserTransaction usertransaction = s.getTxManager().getUserTransaction();
catch(Exception e){
System.out.println("**EXCEPTION IS ***"+e);



when we run we get the

Exception in thread "main" java.lang.NullPointerException

Websphere version is
RAD version 7.5.4
We have tried with 2.0 as well 2.5
but still facing the Exception
Any suggetion would be greatly appreciated

Thanks in Advance ***********
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17260

What does

<property name="autodetectUserTransaction" value="false"/>

in your TransactionManager bean do?

Looks like it won't automatically give you a UserTransaction. What happens if you set it to "true"

I am not familiar with that property and what it does, which is why I am asking. It just sticks out to me.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
rocket mass heater kickstarter
subject: usertransaction.begin(); gets java.lang.NullPointerException