问题
I am working on a Java Application that is responsible for getting data from the request from a service. The request is in the form of an xml. My Java class takes the value from the xml and stores them in the database. The Java class is also responsible for logging the data into simple text(.txt) files. I have acheived that using String Builder. Another info is that the class recieves requests in the form of messages. I have used JMS to achieve that.
Ok, that being said, my class is working fine when I'm deploying it in a simple stand alone weblogic server, but I also have a clustered environment in which I want to deploy my application. My clustered environment has two servers and one load balancer. When I deploy it in the cluster, it gets deployed successfully. But as soon as I run any service messages start getting piled up. I have done my research on this and every wensite says to restart the server, clear cache, make sure your data source name and jar file name are not same. I have done all that. The problem still exists. Here is the piece of code that I have added after which the messages are getting piled up
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
}
}
}
}
}
Before I cleard my cache and everything, I was getting this error
####<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)
来源:https://stackoverflow.com/questions/27055310/application-not-working-on-a-clustered-environment