在使用datanucleus for JDO的应用程序中,我们得到以下异常: 引起:java.lang.NullPointerException at org.datanucleus.ExecutionContextPool.checkOut(ExecutionContextPool.java:97) at org.datanucleus.PersistenceNucleusContextImpl.getExecutionContext(PersistenceNucleusContextImpl.java:1130) 在org.datanucleus.api.jdo.JDOPersistenceManager。(JDOPersistenceManager.java:143) 在org.datanucleus.api.jdo.JDOPersistenceManagerFactory.newPM(JDOPersistenceManagerFactory.java:853) 在org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManager(JDOPersistenceManagerFactory.java:832) 在org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManager(JDOPersistenceManagerFactory.java:813)
我的代码是:
public class OrderRequestQueueProcessor implements Processor {
private static final Logger logger = LoggerFactory
.getLogger(OrderRequestQueueProcessor.class);
private OrderServiceImpl orderService;
private PersistenceManagerFactory pmf;
private ProvisioningErrorMessageServiceImpl provisioningErrorMessageService;
private NotificationServiceImpl notificationService;
private OrderLineService orderLineService;
@Override
public void process(final Exchange exchange) throws Exception {
long startTime = System.currentTimeMillis();
logger.debug("started");
PersistenceManager persistenceManager = null;
Message messageIn = null;
Order order = new Order();
OrderRequestQueueProcessorAE orderRequestQueueProcessorAE = null;
try {
persistenceManager = this.pmf.getPersistenceManager();
messageIn = exchange.getIn();
logger.trace("pm in processor:" + persistenceManager);
String orderQueueProcessorStr = String.valueOf(messageIn.getBody());
logger.debug("orderQueueProcessorStr="+orderQueueProcessorStr);
orderRequestQueueProcessorAE = new ObjectXMLConverter<OrderRequestQueueProcessorAE>()
.convertXMLtoObject(
OrderRequestQueueProcessorAE.class,
orderQueueProcessorStr,
Boolean.valueOf(DBProperties
.getProperties(ProvisioningDBConstants.IS_COMPRESS)));
String channelid = orderRequestQueueProcessorAE.getChannelid();
if (logger.isDebugEnabled()) {
logger.debug("initcorrelationid of OrderRequestQueueProcessor::"
+ orderRequestQueueProcessorAE.getInitcorrelationid());
}
/* MSISDN: It can be 9-12 digit in length */
String regex = DBProperties
.getProperties(ProvisioningDBConstants.MSISDN_REGEX);
String msisdnForRequest = orderRequestQueueProcessorAE.getMsisdn();
if (null != msisdnForRequest) {
if (!(msisdnForRequest.matches(regex))) {
throw new ProvisioningValidationException(
ProvisioningExceptionConstants.INVALID_MSISDN_FORMAT);
}
} else {
throw new ProvisioningValidationException(
ProvisioningExceptionConstants.ENTER_MSISDN);
}
// convert MSISDN to 9 digit
String msisdn = this.convertTolength(msisdnForRequest);
orderRequestQueueProcessorAE.setMsisdn(msisdn);
// validate request parameter(username,password,msisdn)
this.validate(orderRequestQueueProcessorAE, persistenceManager);
// create Order Number for future reference
// generate a new order
// create Order without subscription type and opco
order = this.orderService.createOrderNumber(messageIn.getHeaders(),
persistenceManager, orderRequestQueueProcessorAE);
orderRequestQueueProcessorAE
.setErrorResponseXmlResourcePath("/errorResponse.xml");
// If request is from Schedular validate InstalledBase parameter in
// exchange
if (channelid
.equalsIgnoreCase(DBProperties
.getProperties(ProvisioningDBConstants.CHANNEL_SCHEDULER_CODE))) {
if (null != messageIn
.getHeader(ProvisioningDBConstants.INSTALLED_BASE_ID)) {
long installedbaseid = exchange.getIn().getHeader(
ProvisioningDBConstants.INSTALLED_BASE_ID,
Long.class);
orderRequestQueueProcessorAE
.setInstalledbaseid(installedbaseid);
} else {
logger.error("installedbaseid not found");
throw new ProvisioningEngineException(
ProvisioningExceptionConstants.INSTALLED_BASE_ID_NOT_FOUND);
}
}
orderLineService.process(orderRequestQueueProcessorAE, exchange,
persistenceManager, order);
} catch (final ProvisioningValidationException ve) {
logger.error("Error in OrderRequestQueueProcessor\t", ve);
validationFailureNotification(orderRequestQueueProcessorAE,
persistenceManager, ve, exchange);
} catch (final ProvisioningException de) {
logger.error("Error in OrderRequestQueueProcessor\t", de);
orderService.updateFailureOrder(order, exchange, de.getMessage(),
orderRequestQueueProcessorAE, persistenceManager);
} catch (final Exception e) {
logger.error("Error in OrderRequestQueueProcessor\t", e);
orderService.updateFailureOrder(order, exchange,
ProvisioningExceptionConstants.GENERIC_ERROR_MSG,
orderRequestQueueProcessorAE, persistenceManager);
} finally {
if (persistenceManager != null) {
persistenceManager.close();
}
}
long endTime = System.currentTimeMillis();
logger.debug("Time Take(MillSeconds):" + (endTime - startTime));
logger.debug("finished");
}
我正在使用datanucleus 4.0.0版本。 我们没有得到和db错误代码。请帮忙