我在上周的日志中看到以下错误:
<Feb 7> <Warning> <WLW> <000000> <Id=top-level; Method=processes.FTPInboundProcess.subscription(); Failure=com.bea.wli.bpm.runtime.UnhandledProcessException: Unhandled process exception [ServiceException]>
<Feb 7> <Info> <EJB> <BEA-010213> <Message-Driven EJB: AsyncDispatcher's transaction was rolledback. The transaction details are: Xid=BEA1-3C63D2E9CC47D571774C(183265728),Status=Rolled back.
代码如下:
FTPInboundProcess.jpd
package processes;
import com.bea.data.RawData;
import com.bea.jpd.JpdContext;
import com.bea.jpd.JpdContext.ExceptionInfo;
import com.bea.jpd.ProcessDefinition;
import com.bea.wli.eventGenerator.FileEventGeneratorDocument;
import com.bea.wli.eventGenerator.TimerEventGeneratorDocument;
import com.bea.xml.XmlObject;
import com.bea.xml.XmlTokenSource;
import com.integration.exception.AppException;
import com.integration.util.EnvProperties;
import com.integration.util.KeyGenerator;
import com.integration.util.LogParameters;
import com.integration.util.MessageDataOperation;
import com.integration.util.PASLevel;
import com.integration.util.PASLogger;
import com.integration.util.StringEncrypter;
import com.integration.util.Utility;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import ftp.InterfaceDocument.Interface;
import ftp.InterfacesDocument;
import ftp.InterfacesDocument.Factory;
import ftp.InterfacesDocument.Interfaces;
import inbound.IFileAdapter;
import inbound.impl.FTPClientImpl;
import inbound.impl.FileClientImpl;
import inbound.impl.SFTPClientImpl;
import outbound.PostProcess;
public class FTPInboundProcess
implements ProcessDefinition
{
public boolean bIsFtpDeleteSuccess;
public boolean isWriteToLocalDirSuccess;
public String fileArchiveDir;
public boolean isChDirSuccess;
public byte[] ftpData;
public boolean isPutSuccess;
public TimerEventGeneratorDocument timerEventGeneratorDoc;
public FileEventGeneratorDocument fileEventGeneratorDoc;
public RawData inputRawData;
public IFileAdapter ftp;
public static String PROCESS_NAME = "FileXFRI";
public String processLabel;
public long processStartTime;
public long originalStartTime;
public long processId;
public long parentProcessId;
public String key;
public String protocol;
public String documentKey;
public boolean bAppException;
public boolean bMesageInorder;
public boolean bNewMessage;
public String errorStr;
public String sftpkey;
public String fileName;
public int fileCounter;
public String emailUser;
public transient Logger logger;
static final long serialVersionUID = 1L;
public FTPInboundProcess.Callback callback;
public String ftpHostName;
public int ftpPort;
public String ftpUserName;
public String ftpPassword;
public String ftpDir;
public String ftpArchDir;
public String ftpLocalDir;
public String filePattern;
public String isFtpPostActionDeleteRequired;
public String isFtpPostActionArchiveRequired;
public String isEncryptRequired;
public long fileSize;
public String interfaceId;
public String emailYN;
public HashMap dataMap;
public XmlObject inputXML;
public String[] listOfFTPFiles;
public boolean isFTPConnected;
JpdContext context;
int postProcessReturnvalue;
public void subscription(XmlObject x0, TimerEventGeneratorDocument x1)
{
this.inputXML = x0;
this.timerEventGeneratorDoc = x1;
}
void initProcessVariables()
{
this.processStartTime = System.currentTimeMillis();
this.processLabel = "";
this.processId = 0L;
this.postProcessReturnvalue = 0;
this.parentProcessId = 0L;
this.documentKey = "";
this.bAppException = false;
this.errorStr = "";
this.fileSize = 0L;
this.interfaceId = "";
this.emailYN = "";
this.emailUser = "";
this.dataMap = new HashMap();
}
public void init()
throws Exception
{
try
{
this.logger = PASLogger.getLogger("PAS." + PROCESS_NAME);
this.logger.log(PASLevel.FINER, "Timer InputXML :" + this.inputXML.xmlText());
this.logger.log(PASLevel.FINER, "Type::" + this.inputXML.getClass());
initProcessVariables();
String xmlText = this.inputXML.xmlText();
this.logger.log(PASLevel.FINER, "INPUT::" + xmlText);
InterfacesDocument input = InterfacesDocument.Factory.parse(xmlText);
this.interfaceId = input.getInterfaces().getInterfaceArray()[0].getId();
this.logger.log(PASLevel.FINER, "Interface id : " + ((InterfacesDocument)this.inputXML).getInterfaces().getInterfaceArray(0).getId());
this.processId = KeyGenerator.generateKey("PROCESS_ID");
this.documentKey = (PROCESS_NAME + "::FTP::" + this.interfaceId + "::" + this.processId);
this.key = (PROCESS_NAME + "::FTP::" + this.interfaceId + "::" + this.processId);
this.logger.log(PASLevel.FINER, "Parsing Input Document End:" + System.currentTimeMillis());
this.processLabel = ("Key=" + this.key + ",ProcessId=" + this.processId + ",InterfaceId=" + this.interfaceId);
this.processStartTime = System.currentTimeMillis();
MessageDataOperation.insertMessageData(this.processId, this.documentKey, PROCESS_NAME, this.key, this.processStartTime, this.parentProcessId);
updateProcessLabel(this.processLabel);
this.protocol = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".PROTOCOL");
this.ftpHostName = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPHOST");
this.logger.log(PASLevel.FINEST, " ftpHostName :" + this.ftpHostName);
try
{
this.ftpPort = Integer.parseInt(EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".PORT"));
}
catch (Exception e)
{
this.logger.log(PASLevel.WARNING, "FTP Port not defined for the Interface :" + this.interfaceId + " .... using default port");
this.ftpPort = 21;
}
this.logger.log(PASLevel.FINE, " ftpPort :" + this.ftpPort);
this.sftpkey = Utility.nullToStr(EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".SFTPKEY"));
this.logger.log(PASLevel.FINE, " SFTPKEY :" + this.sftpkey);
this.dataMap.put("SFTPKEY", this.sftpkey);
this.ftpUserName = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPUSER");
this.logger.log(PASLevel.FINE, " ftpUserName :" + this.ftpUserName);
this.ftpPassword = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPPASSWORD");
this.logger.log(PASLevel.FINE, " ftpPassword :" + this.ftpPassword);
this.filePattern = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FILEPATTERN");
this.logger.log(PASLevel.FINE, " filePattern :" + this.filePattern);
this.ftpArchDir = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPARCH");
this.logger.log(PASLevel.FINE, " ftpArchDir :" + this.ftpArchDir);
this.ftpDir = Utility.nullToStr(EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPDIR"));
this.ftpLocalDir = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPLOCALDIR");
this.fileArchiveDir = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FILEARCHIVEDIR");
this.isFtpPostActionDeleteRequired = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPPOSTDELETE");
this.isEncryptRequired = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".ENCRYPT");
this.isFtpPostActionArchiveRequired = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".FTPPOSTARCHIVE");
this.logger.log(PASLevel.FINE, " ftpLocalDir :" + this.ftpLocalDir);
this.logger.log(PASLevel.FINE, " isFtpPostActionArchiveRequired :" + this.isFtpPostActionArchiveRequired);
this.logger.log(PASLevel.FINE, " isFtpPostActionDeleteRequired :" + this.isFtpPostActionDeleteRequired);
return;
}
catch (Exception e)
{
e.printStackTrace();
this.logger.log(PASLevel.SYSTEM_ERROR, e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
void updateProcessLabel(String label)
{
this.context.setProcessLabel(this.processLabel);
}
public boolean isAppException()
{
return this.bAppException;
}
public boolean isMessageInorder()
{
return this.bMesageInorder;
}
String getErrorEmailUser(Object[] args)
throws Exception
{
try
{
if ((args == null) || (args.length == 0)) {
return "";
}
this.emailUser = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".EMAIL_USER");
return this.emailUser;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, "ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
}
return "";
}
public void context_onInitialMessageFailure(String methodName, Object[] args)
throws Exception
{
try
{
this.processId = Utility.context_onInitialMessageFailure(PROCESS_NAME, args, this.logger);
String body = "Due to the error the interface file could not be sent. \n";
body = body + "System will retry the file after sometime.";
this.errorStr = "";
sendErrorEmail(body, getErrorEmailUser(args));
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, "ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void globalExceptionHandler()
throws Exception
{
Exception e = null;
try
{
e = this.context.getExceptionInfo().getException();
this.errorStr = e.getMessage();
}
catch (Throwable localThrowable) {}
this.bAppException = Utility.globalExceptionHandler(e, this.logger, PROCESS_NAME, this.processId, this.parentProcessId, "", this.inputRawData.byteValue(), "xml", true);
if (this.bAppException) {
this.processLabel = (this.processLabel + ",AppException , " + e.getClass());
} else {
this.processLabel = (this.processLabel + ",SystemException , " + e.getClass());
}
updateProcessLabel(this.processLabel);
this.logger.log(PASLevel.INFO, "Exception Raised in Process , Process Label:" + this.processLabel);
}
public void systemExceptionProcessing()
throws Exception
{}
public void sendDataErrorEmail()
throws Exception
{
String body = "Due to the error the file could not sent \n\n\n";
body = body + ",Filename=" + this.fileName;
this.emailUser = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".EMAIL_USER");
sendErrorEmail(body, this.emailUser);
}
public void sendErrorEmail(String body, String to)
throws Exception
{
String subject = "";
String cc = "";
String bcc = "";
HashMap map = new HashMap();
try
{
body = body + this.errorStr;
subject = "Due to the error the interface file could not be sent. " + this.key;
if ((to == null) || (to.equals(""))) {
to = Utility.getErrorEmail();
}
Utility.sendEmail(PROCESS_NAME, this.processId, "Business", body, subject, to, "", cc, bcc, "");
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, "ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public boolean isMessageInorder1()
{
return this.bMesageInorder;
}
public void handleAppException()
throws Exception
{}
public void cleanup()
throws Exception
{
this.inputRawData = null;
}
public void setFilesCount()
throws Exception
{
this.fileCounter = 0;
}
public void decrementFileCount()
throws Exception
{
this.fileCounter += 1;
}
public boolean checkFileCounterCondition()
{
return this.fileCounter < this.listOfFTPFiles.length;
}
public void raiseFTPConnectionException()
throws Exception
{
Exception e = new Exception("Error: FTP Connection Failure");
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error: FTP Connection Failure", new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
public boolean isFTPConnected()
{
return this.ftp.isConnected();
}
public boolean checkNoOfFilesReceived()
{
if ((this.listOfFTPFiles != null) && (this.listOfFTPFiles.length > 0)) {
return true;
}
return false;
}
public void sendEmail()
throws Exception
{
String subject = "";
String to = "";
String cc = "";
String bcc = "";
String body = "";
HashMap map = new HashMap();
try
{
this.emailYN = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".EMAIL_YN");
if ((this.emailYN != null) && (!this.emailYN.equals("Y"))) {
return;
}
this.emailUser = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".EMAIL_USER");
body = "Interface has processed the following file succesfully. :Filename:" + this.fileName;
to = this.emailUser;
subject = "Interface has sent the following file succesfully. Key::" + this.key + ":Filename:" + this.fileName;
if ((to == null) || (to.equals("")))
{
this.logger.log(PASLevel.WARNING, "ProcessLabel:" + this.processLabel + ":Error:" + "Email Receipent not specified.", new LogParameters(this.processId, PROCESS_NAME, this.processLabel, null));
to = Utility.getErrorEmail();
}
this.logger.log(PASLevel.FINE, "SCPExtract ... Sending an Email");
Utility.sendEmail(PROCESS_NAME, this.processId, "Business", body, subject, to, "", cc, bcc, "");
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, "ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void createFTPClient()
throws Exception
{
if (this.protocol.equalsIgnoreCase("SFTP"))
{
this.ftp = new SFTPClientImpl();return;
}
if (this.protocol.equalsIgnoreCase("FTP"))
{
this.ftp = new FTPClientImpl();return;
}
this.ftp = new FileClientImpl();
}
public void connect()
throws Exception
{
try
{
if (((this.protocol.equals("FTP")) || (this.protocol.equals("SFTP"))) && ((this.ftpUserName == null) || (this.ftpPassword == null) || (this.ftpHostName == null)))
{
Exception e = new Exception("ftpUserName = null || this.ftpPassword = null || ftpHostName = null");
this.logger.log(PASLevel.SYSTEM_ERROR, e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
this.logger.log(PASLevel.FINE, "Connecting to the server .... :" + this.ftpHostName);
this.logger.log(PASLevel.FINE, "Host:" + this.ftpHostName + ":User:" + this.ftpUserName + ":Password:" + this.ftpPassword);
this.ftp.connect(this.ftpHostName, this.ftpPort, this.ftpUserName, this.ftpPassword, this.dataMap);
this.logger.log(PASLevel.FINE, "Connected to the server:" + this.ftpHostName);
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, "ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void getRemoteFilesList()
throws Exception
{
try
{
this.logger.log(PASLevel.FINE, "Retriving List of Files .... :FtpDir:" + this.ftpDir);
this.logger.log(PASLevel.FINE, "File Pattern .... ::" + this.filePattern);
if (!this.ftpLocalDir.equals("")) {
this.ftp.setLocalDir(this.ftpLocalDir);
}
if (!this.ftpDir.equals("")) {
this.ftp.changeWorkingDirectory(this.ftpDir);
}
ArrayList list = this.ftp.listFiles(this.filePattern);
this.listOfFTPFiles = new String[list.size()];
System.arraycopy(list.toArray(), 0, this.listOfFTPFiles, 0, list.size());
for (int ind = 0; ind < this.listOfFTPFiles.length; ind++) {
this.logger.log(PASLevel.FINE, "List of Files:" + this.listOfFTPFiles[ind]);
}
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, "ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
e.printStackTrace();
throw e;
}
}
public void disconnect()
throws Exception
{
this.logger.log(PASLevel.FINE, "Zero input files ..... Disconnecting ...");
this.ftp.disconnect();
}
public void getFile()
throws Exception
{
try
{
this.fileName = this.listOfFTPFiles[this.fileCounter];
if (this.fileName == null) {
throw new Exception(" FTP fileName is null");
}
ByteArrayOutputStream getFileByteArrayOutputStream = this.ftp.getFile(this.fileName);
this.ftpData = getFileByteArrayOutputStream.toByteArray();
this.logger.log(PASLevel.FINE, "Got File Data ...");
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void backup()
throws Exception
{
try
{
String archiveYN = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".LOCALARCHIVE");
String asciiYN = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".ASCII_YN");
if (archiveYN.equals("Y"))
{
byte[] fileArchData;
if ((asciiYN.equals("Y")) && (this.isEncryptRequired.equals("Y")))
{
StringEncrypter encrypter = new StringEncrypter();
fileArchData = encrypter.encrypt(new String(this.ftpData)).getBytes();
}
else
{
fileArchData = this.ftpData;
}
Utility.createFile(this.fileArchiveDir + "/" + this.interfaceId + "_" + this.processId + "_" + this.fileName, fileArchData);
}
this.logger.log(PASLevel.FINE, "File Archieved ...::" + archiveYN + "::EncryptionYN::" + this.isEncryptRequired);
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void disconnect1()
throws Exception
{
try
{
this.ftp.disconnect();
return;
}
catch (Throwable localThrowable) {}
}
public void disconnect2()
throws Exception
{
try
{
this.ftp.disconnect();
return;
}
catch (Throwable localThrowable) {}
}
public void doPostProcess()
throws Exception
{
try
{
String sapPostProcessClass = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".POSTPROCESS");
sapPostProcessClass = "washpost.pas.outbound.impl." + sapPostProcessClass;
Map fileMap = new HashMap();
this.logger.log(PASLevel.FINE, "PostProcess ::" + sapPostProcessClass);
if (!sapPostProcessClass.equals(""))
{
Class c = Class.forName(sapPostProcessClass);
PostProcess postProcess = (PostProcess)c.newInstance();
String passByRefFlag = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".REFERENCE_YN");
byte[] tempFtpData = this.ftpData;
if ((passByRefFlag != null) && (passByRefFlag.equalsIgnoreCase("Y")))
{
String localDir = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".LOCALDIR");
String localFileName = localDir + System.getProperty("file.separator") + this.fileName;
Utility.createFile(localFileName, this.ftpData);
tempFtpData = new byte[0];
}
this.postProcessReturnvalue = postProcess.doUpload(tempFtpData, this.fileName, this.interfaceId, this.processId, fileMap);
this.logger.log(PASLevel.FINE, "***** PostProcess Return::" + this.postProcessReturnvalue);
return;
}
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
this.postProcessReturnvalue = -1;
this.errorStr = e.getMessage();
throw e;
}
}
public void writeFileToExceptionDir()
throws Exception
{
String exceptionDirPath = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".EXCEPTION_DIR_PATH");
try
{
Utility.createFile(exceptionDirPath + "/" + this.fileName, this.ftpData);
String message = "Error while performing post process :: " + this.fileName + ", File is stored in Exception Directory. ";
message = message = "::ErrorMessage::" + this.errorStr;
performSendErrorEmail(message);
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void writeFileToInputDir()
throws Exception
{
String inputDirPath = EnvProperties.getProperty(PROCESS_NAME + "." + this.interfaceId + ".INPUT_DIR_PATH");
try
{
String completeFileName = this.interfaceId + "." + this.fileName;
Utility.createFile(inputDirPath + "/" + completeFileName, this.ftpData);
String message = "Interface has saved the file: " + completeFileName + " to input Directory ";
performSendErrorEmail(message);
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void updateLog()
throws Exception
{
try
{
this.processLabel = (this.processLabel + ",FilesProcessed=" + this.fileCounter);
updateProcessLabel(this.processLabel);
MessageDataOperation.updateMessageSentData(this.processId, "Y");
this.logger.log(PASLevel.INFO, "Process Completed, Process Label:" + this.processLabel);
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
public void updateLog1()
throws Exception
{
try
{
this.processLabel += ",FilesProcessed=0";
updateProcessLabel(this.processLabel);
MessageDataOperation.updateMessageSentData(this.processId, "Y");
this.logger.log(PASLevel.INFO, "Process Completed, Process Label:" + this.processLabel);
return;
}
catch (Exception e)
{
this.logger.log(PASLevel.SYSTEM_ERROR, ":ProcessLabel:" + this.processLabel + ":Error:" + e.getMessage(), new LogParameters(this.processId, PROCESS_NAME, this.processLabel, e));
throw e;
}
}
}
此代码使用 FTP 计时器甚至生成器每天启动交易。问题是,当计时器触发它吐出该错误并且同时事务正在执行时。我确实尝试了多个 try/catch 块,但到目前为止无法获得任何其他信息。自从服务器中断以来,这种情况就一直在发生。任何人都可以建议