Java中有一个代码块(循环),该代码块使用User Transaction验证交易。 用户Transaction对象在循环之前声明。此方法用于验证某些内容。 它工作正常,但现在经常出现问题,例如:如果用户传递四个值,则三个已成功验证工作正常,而其中一个失败 屏幕上没有任何显示。 验证了日志,并显示如下。我正在使用ejb Hiberante Persistence,并已部署在JBoss中。
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)
代码:以下代码是有状态会话bean的Bean类:
public Collection<Acknowledgement> goodTransfer(String destLoc,
String destUT, Collection objectList, boolean getDetails,
boolean valid, boolean commit, String userId, String pass)
throws Exception {
List<Acknowledgement> 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<Acknowledgement>(1);
Acknowledgement ack = new AmcAcknowledgement(false,
e);
acks.add(ack);
}
else {
throw new Exception(Exception.MISSING_VLUES);
}
return acks; }
请对此提供帮助