This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

sagar chandgude
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17309
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!