title: Exception throws during the User Transaction begin method
body: <p>There is a block of code in Java (a loop) which uses User Transaction for validating the transaction. 
  The user Transaction object is declared before the loop.This  method is used to validate certain things.
  It is working fine but now frequently getting issue For eg: if the user pass four values three got successfully validated  working fine and one of them got failed 
  and nothing shows in the screen. 
          Verified the logs and it shows the as below. I am using ejb Hiberante Persistence and deployed in JBoss.</p>
  
  <pre><code>     Unexpected exception occurred
  java.lang.NullPointerException
      at ut.begin(); 
      at sun.reflect.GeneratedMethodAccessor389.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
      at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72)
      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:76)
      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:62)
      at sun.reflect.GeneratedMethodAccessor289.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) 
  </code></pre>
  
  <p>Code:  The below code is Bean class of stateful session bean:</p>
  
  <pre><code>public Collection&lt;Acknowledgement&gt; goodTransfer(String destLoc,
          String destUT, Collection objectList, boolean getDetails,
          boolean valid, boolean commit, String userId, String pass)
          throws Exception {
  
      List&lt;Acknowledgement&gt; acks = null;
  
      if (objectList != null) {
          try {
              ut.begin();
      if (valida) {
                  try {
                      acks = GoodUtils.getInstance().validate(userId,
                          destLoc, destUT, objectList,
                          userName, password);
                  } catch(GoodException e) {
                      log.error("Transfer failed", e);
                      acks = new ArrayList&lt;Acknowledgement&gt;(1);
                      Acknowledgement ack = new AmcAcknowledgement(false,
                          e);
  
                      acks.add(ack);
                  }
       else {
          throw new Exception(Exception.MISSING_VLUES);
      }
  
  
      return acks;        }
  </code></pre>
  
  <p>Please help on this</p>