我正在开发一个Java应用程序,负责从服务中获取请求中的数据。请求采用xml的形式。我的Java类从xml获取值并将它们存储在数据库中。 Java类还负责将数据记录到简单文本(.txt)文件中。我已经使用String Builder实现了这一点。另一个信息是该类以消息的形式接收请求。我已经使用JMS来实现这一点。
好的,就是说,当我在一个简单的独立weblogic服务器上部署它时,我的班级工作正常,但我也有一个集群环境,我想在其中部署我的应用程序。我的集群环境有两台服务器和一台负载均衡器。当我在集群中部署它时,它会成功部署。但是一旦我运行任何服务消息就开始堆积起来。我已经对此进行了研究,每个wensite都说重启服务器,清除缓存,确保你的数据源名称和jar文件名不相同。我已经完成了所有这些。问题依然存在。这是我添加的一段代码,之后消息堆积起来
public static void createLogFile(DAO db, Connection conn, String msg_guid, String serviceNameDB, String operationXML, String service_nameXML ){
StringBuilder sb = new StringBuilder();
String filepath = db.returnFilePath();
String destfilepath = db.returnDestFilePath();
String data_source = db.returnDataSource();
String line_seperator=System.getProperty("line.separator");
String instance;
String inst = data_source.substring(data_source.indexOf("-")+1, data_source.length());
if(inst.endsWith("R")){
instance = "IGL62R";
}
else if(inst.endsWith("P")){
instance = "IGL60P";
}
else{
instance = inst;
}
String report_index_data =
"select MSG_GUID, REPORT_MODE, OSB_REPORT_INDEX_ID, MSG_STATUS, SERVICE_REQUEST_ID, REQUEST_MESSAGE_TIMESTAMP, RESPONSE_MESSAGE_TIMESTAMP, TRX_SOURCE, REQUEST_MESSAGE_DATA_ID, INDEX1, INDEX2, INDEX3, INDEX4 from OSB_REPORT_INDEX where MSG_GUID='" +
msg_guid +
"' and REPORT_MODE='A' and MSG_STATUS!='P' and MSG_STATUS!='N'";
ResultSet rs = db.selectQuery(report_index_data, conn);
try {
while (rs.next()) {
sb.append("Instance=");
sb.append(instance);
sb.append(" ServiceID=");
sb.append(rs.getString("SERVICE_REQUEST_ID"));
sb.append(" ServiceNAME=");
sb.append(serviceNameDB);
sb.append(" OperationNAME=");
sb.append(operationXML);
sb.append(" InboundServiceNAME=");
sb.append(service_nameXML);
sb.append(" OSBReportDetailid=");
sb.append(rs.getString("REQUEST_MESSAGE_DATA_ID"));
sb.append(" OSBReportIndexid=");
sb.append(rs.getString("OSB_REPORT_INDEX_ID"));
sb.append(" GUID=");
sb.append(rs.getString("MSG_GUID"));
sb.append(" TransactionStart=");
sb.append(rs.getString("REQUEST_MESSAGE_TIMESTAMP"));
sb.append(" TransactionEnd=");
sb.append(rs.getString("RESPONSE_MESSAGE_TIMESTAMP"));
sb.append(" SourceName=");
sb.append(rs.getString("TRX_SOURCE"));
sb.append(" Status=");
sb.append(rs.getString("MSG_STATUS"));
sb.append(" Index1=");
sb.append(rs.getString("INDEX1"));
sb.append(" Index2=");
sb.append(rs.getString("INDEX2"));
sb.append(" Index3=");
sb.append(rs.getString("INDEX3"));
sb.append(" Index4=");
sb.append(rs.getString("INDEX4"));
sb.append(line_seperator);
try {
String filename =
new SimpleDateFormat("ddMMyy").format(new Date());
File file = new File(filepath + "/SplunkOADC" + filename + ".txt");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter(bw);
out.println(sb.toString());
sb.setLength(0);
sb.trimToSize();
out.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
rs.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
File folder = new File(filepath);
listFilesForFolder(folder, destfilepath);
}
public static void listFilesForFolder(File folder, String destfilepath) {
for (File fileEntry : folder.listFiles()) {
if (fileEntry.isDirectory()) {
listFilesForFolder(fileEntry, destfilepath);
}
else{
long diff = new Date().getTime() - fileEntry.lastModified();
if(diff > 48*60*60*1000){
File dir = new File(destfilepath);
boolean success = fileEntry.renameTo(new File(dir, fileEntry.getName()));
if (!success) {
// File was not successfully moved to archive folder
}
}
}
}
}
在我清除缓存和所有内容之前,我收到了此错误
####<20-Nov-2014 10:45:20 o'clock GMT> <Error> <JMX> <uknwsaviv229.via.novonet> <UAT_nws229_OSB2> <[ACTIVE] ExecuteThread: '60' for queue: 'weblogic.kernel.Default (sel
f-tuning)'> <<WLS Kernel>> <> <> <1416480320470> <BEA-149500> <An exception occurred while registering the MBean null.
java.lang.IllegalArgumentException: Registered more than one instance with the same objectName : com.bea:ServerRuntime=UAT_nws229_OSB2,Name=weblogic.wsee.mdb.DispatchPo
licy@NUProcessOSBReportDataParser-IGL68D@null,WorkManagerRuntime=weblogic.wsee.mdb.DispatchPolicy,ApplicationRuntime=NUProcessOSBReportDataParser-IGL68D,Type=RequestCla
ssRuntime new:weblogic.work.RequestClassRuntimeMBeanImpl@78da78da existing weblogic.work.RequestClassRuntimeMBeanImpl@3ca03ca
at weblogic.management.jmx.ObjectNameManagerBase.registerObject(ObjectNameManagerBase.java:168)
at weblogic.management.mbeanservers.internal.WLSObjectNameManager.lookupObjectName(WLSObjectNameManager.java:131)
at weblogic.management.jmx.modelmbean.WLSModelMBeanFactory.registerWLSModelMBean(WLSModelMBeanFactory.java:87)
at weblogic.management.mbeanservers.internal.RuntimeMBeanAgent$1.registered(RuntimeMBeanAgent.java:104)
at weblogic.management.provider.core.RegistrationManagerBase.invokeRegistrationHandlers(RegistrationManagerBase.java:180)
at weblogic.management.provider.core.RegistrationManagerBase.register(RegistrationManagerBase.java:110)
at weblogic.management.runtime.RuntimeMBeanDelegate.register(RuntimeMBeanDelegate.java:317)
at weblogic.management.runtime.RuntimeMBeanDelegate.<init>(RuntimeMBeanDelegate.java:255)
at weblogic.management.runtime.RuntimeMBeanDelegate.<init>(RuntimeMBeanDelegate.java:215)
at weblogic.work.RequestClassRuntimeMBeanImpl.<init>(RequestClassRuntimeMBeanImpl.java:32)
at weblogic.work.WorkManagerRuntimeMBeanImpl.getRequestClassRuntime(WorkManagerRuntimeMBeanImpl.java:86)
at weblogic.work.WorkManagerRuntimeMBeanImpl.getWorkManagerRuntime(WorkManagerRuntimeMBeanImpl.java:61)
at weblogic.work.WorkManagerCollection.addWorkManagerRuntime(WorkManagerCollection.java:774)
at weblogic.work.WorkManagerCollection.addWorkManager(WorkManagerCollection.java:805)
at weblogic.work.WorkManagerCollection.configureWorkManagerService(WorkManagerCollection.java:216)
at weblogic.work.WorkManagerCollection.initialize(WorkManagerCollection.java:169)
at weblogic.application.internal.flow.WorkManagerFlow.prepare(WorkManagerFlow.java:45)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:648)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:59)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.createAndPrepareContainer(RedeployOperation.java:104)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.doPrepare(RedeployOperation.java:128)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)