use of javax.ejb.TransactionAttribute in project eap-additional-testsuite by jboss-set.
the class SFSB method setupConfig.
@TransactionAttribute(TransactionAttributeType.NEVER)
public void setupConfig() {
// static {
try {
// prepare the configuration
Configuration configuration = new Configuration().setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
configuration.getProperties().put(AvailableSettings.JTA_PLATFORM, JBossAppServerJtaPlatform.class);
configuration.getProperties().put(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta");
configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS");
// fetch the properties
Properties properties = new Properties();
configuration = configuration.configure("hibernate.cfg.xml");
properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}
use of javax.ejb.TransactionAttribute in project hibernate-orm by hibernate.
the class CmtSfStatefulBean method start.
@TransactionAttribute(TransactionAttributeType.NEVER)
public void start() {
try {
Configuration configuration = new Configuration();
configuration = configuration.configure("hibernate.cfg.xml");
configuration.addAnnotatedClass(WildFlyDdlEntity.class);
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
use of javax.ejb.TransactionAttribute in project dataverse by IQSS.
the class HarvesterServiceBean method processRecord.
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Long processRecord(DataverseRequest dataverseRequest, Logger hdLogger, PrintWriter importCleanupLog, OaiHandler oaiHandler, String identifier, MutableBoolean recordErrorOccurred, MutableLong processedSizeThisBatch, List<String> deletedIdentifiers) {
String errMessage = null;
Dataset harvestedDataset = null;
logGetRecord(hdLogger, oaiHandler, identifier);
File tempFile = null;
try {
FastGetRecord record = oaiHandler.runGetRecord(identifier);
errMessage = record.getErrorMessage();
if (errMessage != null) {
hdLogger.log(Level.SEVERE, "Error calling GetRecord - " + errMessage);
} else if (record.isDeleted()) {
hdLogger.info("Deleting harvesting dataset for " + identifier + ", per the OAI server's instructions.");
Dataset dataset = datasetService.getDatasetByHarvestInfo(oaiHandler.getHarvestingClient().getDataverse(), identifier);
if (dataset != null) {
hdLogger.info("Deleting dataset " + dataset.getGlobalId());
deleteHarvestedDataset(dataset, dataverseRequest, hdLogger);
// TODO:
// check the status of that Delete - see if it actually succeeded
deletedIdentifiers.add(identifier);
} else {
hdLogger.info("No dataset found for " + identifier + ", skipping delete. ");
}
} else {
hdLogger.info("Successfully retrieved GetRecord response.");
tempFile = record.getMetadataFile();
PrintWriter cleanupLog;
harvestedDataset = importService.doImportHarvestedDataset(dataverseRequest, oaiHandler.getHarvestingClient(), identifier, oaiHandler.getMetadataPrefix(), record.getMetadataFile(), importCleanupLog);
hdLogger.fine("Harvest Successful for identifier " + identifier);
hdLogger.fine("Size of this record: " + record.getMetadataFile().length());
processedSizeThisBatch.add(record.getMetadataFile().length());
}
} catch (Throwable e) {
logGetRecordException(hdLogger, oaiHandler, identifier, e);
errMessage = "Caught exception while executing GetRecord on " + identifier;
// logException(e, hdLogger);
} finally {
if (tempFile != null) {
// temporary - let's not delete the temp metadata file if anything went wrong, for now:
if (errMessage == null) {
try {
tempFile.delete();
} catch (Throwable t) {
}
;
}
}
}
if (errMessage != null) {
if (recordErrorOccurred != null) {
recordErrorOccurred.setValue(true);
} else {
throw new EJBException(errMessage);
}
}
return harvestedDataset != null ? harvestedDataset.getId() : null;
}
use of javax.ejb.TransactionAttribute in project dataverse by IQSS.
the class IngestMessageBean method onMessage.
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void onMessage(Message message) {
IngestMessage ingestMessage = null;
Long datafile_id = null;
try {
ObjectMessage om = (ObjectMessage) message;
ingestMessage = (IngestMessage) om.getObject();
Iterator iter = ingestMessage.getFileIds().iterator();
datafile_id = null;
// -- L.A. Aug. 13 2014
while (iter.hasNext()) {
datafile_id = (Long) iter.next();
logger.fine("Start ingest job;");
try {
if (ingestService.ingestAsTabular(datafile_id)) {
// Thread.sleep(10000);
logger.fine("Finished ingest job;");
} else {
logger.warning("Error occurred during ingest job!");
}
} catch (Exception ex) {
// ex.printStackTrace();
// TODO:
// this solution is working - but it would be cleaner to instead
// make sure that all the exceptions are interrupted and appropriate
// action taken still on the ingest service side.
// -- L.A. Aug. 13 2014;
logger.info("Unknown exception occurred during ingest (supressed stack trace); re-setting ingest status.");
if (datafile_id != null) {
logger.fine("looking up datafile for id " + datafile_id);
DataFile datafile = datafileService.find(datafile_id);
if (datafile != null) {
datafile.SetIngestProblem();
IngestReport errorReport = new IngestReport();
errorReport.setFailure();
if (ex.getMessage() != null) {
errorReport.setReport("Ingest succeeded, but failed to save the ingested tabular data in the database: " + ex.getMessage());
} else {
errorReport.setReport("Ingest succeeded, but failed to save the ingested tabular data in the database; no further information is available");
}
errorReport.setDataFile(datafile);
datafile.setIngestReport(errorReport);
datafile.setDataTables(null);
logger.info("trying to save datafile and the failed ingest report, id=" + datafile_id);
datafile = datafileService.save(datafile);
Dataset dataset = datafile.getOwner();
if (dataset != null && dataset.getId() != null) {
// logger.info("attempting to remove dataset lock for dataset " + dataset.getId());
// datasetService.removeDatasetLock(dataset.getId());
ingestService.sendFailNotification(dataset.getId());
}
}
}
}
}
// packed into this IngestMessage belong to the same dataset)
if (datafile_id != null) {
DataFile datafile = datafileService.find(datafile_id);
if (datafile != null) {
Dataset dataset = datafile.getOwner();
if (dataset != null && dataset.getId() != null) {
datasetService.removeDatasetLocks(dataset.getId(), DatasetLock.Reason.Ingest);
}
}
}
} catch (JMSException ex) {
// error in getting object from message; can't send e-mail
ex.printStackTrace();
} finally {
// when we're done, go ahead and remove the lock (not yet)
try {
// datasetService.removeDatasetLock( ingestMessage.getDatasetId() );
} catch (Exception ex) {
// application was unable to remove the datasetLock
ex.printStackTrace();
}
}
}
use of javax.ejb.TransactionAttribute in project dataverse by IQSS.
the class ImportServiceBean method handleFile.
@TransactionAttribute(REQUIRES_NEW)
public JsonObjectBuilder handleFile(DataverseRequest dataverseRequest, Dataverse owner, File file, ImportType importType, PrintWriter validationLog, PrintWriter cleanupLog) throws ImportException, IOException {
System.out.println("handling file: " + file.getAbsolutePath());
String ddiXMLToParse;
try {
ddiXMLToParse = new String(Files.readAllBytes(file.toPath()));
JsonObjectBuilder status = doImport(dataverseRequest, owner, ddiXMLToParse, file.getParentFile().getName() + "/" + file.getName(), importType, cleanupLog);
status.add("file", file.getName());
logger.log(Level.INFO, "completed doImport {0}/{1}", new Object[] { file.getParentFile().getName(), file.getName() });
return status;
} catch (ImportException ex) {
String msg = "Import Exception processing file " + file.getParentFile().getName() + "/" + file.getName() + ", msg:" + ex.getMessage();
logger.info(msg);
if (validationLog != null) {
validationLog.println(msg);
}
return Json.createObjectBuilder().add("message", "Import Exception processing file " + file.getParentFile().getName() + "/" + file.getName() + ", msg:" + ex.getMessage());
} catch (IOException e) {
Throwable causedBy = e.getCause();
while (causedBy != null && causedBy.getCause() != null) {
causedBy = causedBy.getCause();
}
String stackLine = "";
if (causedBy != null && causedBy.getStackTrace() != null && causedBy.getStackTrace().length > 0) {
stackLine = causedBy.getStackTrace()[0].toString();
}
String msg = "Unexpected Error in handleFile(), file:" + file.getParentFile().getName() + "/" + file.getName();
if (e.getMessage() != null) {
msg += "message: " + e.getMessage();
}
msg += ", caused by: " + causedBy;
if (causedBy != null && causedBy.getMessage() != null) {
msg += ", caused by message: " + causedBy.getMessage();
}
msg += " at line: " + stackLine;
validationLog.println(msg);
e.printStackTrace();
return Json.createObjectBuilder().add("message", "Unexpected Exception processing file " + file.getParentFile().getName() + "/" + file.getName() + ", msg:" + e.getMessage());
}
}
Aggregations