最近工作上遇到一个奇怪的技术问题,记录下。
我们服务器是多节点部署的,一共是4台服务器,是通过apache转发到每台服务器的(负载均衡),每台服务器的架构都是一样的,都是用weblogic作为服务器端的,项目应用是用SSH架构。
问题就出在5,7.8节点的服务器都没有问题,就6节点的服务器出了问题(假设4台服务器部署在内网的5,6,7,8节点上)
每次访问到6节点就挂了,后来查看错误日志,错误日志如下:
2013-09-05 18:47:57,848 ERROR [[ACTIVE] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)'] action.ActionServlet (ActionServlet.java:1034) - Parsing error pr ocessing resource path /WEB-INF/struts-cfg/struts-config-user.xml, /WEB-INF/struts-cfg/struts-config-centrex.xml java.net.UnknownHostException: struts.apache.org at java.net.InetAddress.getAllByName0(InetAddress.java:1184) at java.net.InetAddress.getAllByName(InetAddress.java:1110) at java.net.InetAddress.getAllByName(InetAddress.java:1046) at weblogic.net.http.HttpClient.openServer(HttpClient.java:309) at weblogic.net.http.HttpClient.openServer(HttpClient.java:425) at weblogic.net.http.HttpClient.New(HttpClient.java:252) at weblogic.net.http.HttpURLConnection.getHttpClient(HttpURLConnection.java:228) at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:450) at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:37) at org.apache.commons.digester.Digester.createInputSourceFromURL(Digester.java:1938) at org.apache.commons.digester.Digester.resolveEntity(Digester.java:1615) at weblogic.xml.jaxp.ChainingEntityResolver.resolveEntity(ChainingEntityResolver.java:87) at weblogic.xml.jaxp.ChainingEntityResolver.resolveEntity(ChainingEntityResolver.java:87) at com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEntity(EntityResolverWrapper.java:107) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntityAsPerStax(XMLEntityManager.java:1017) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1189) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1087) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1000) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:133) at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:173) at org.apache.commons.digester.Digester.parse(Digester.java:1745) at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1006) at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470) at javax.servlet.GenericServlet.init(GenericServlet.java:241) at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64) at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58) at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539) at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1981) at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1955) at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1874) at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154) at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200) at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27) at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212) at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44) at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161) at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844) at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253) at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68) 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)
开始一直以为是6节点上的服务器解析struts-config.xml配置文件的路径出错了(因为它的报错提示也确实是提示这个错,误导啊),换了struts-config.xml配置文件的路径,还是这个错,基本上可以排除不是路径问题了。
网上查了下资料,有些说是:
struts-config.xml 的头声明不对,说是要把
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
换成
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
就可以了。
试了一下,还是不行。
折腾了一天,该排除的都排除了,根据经验,只能把问题定位在jar包冲突上了,后来看了看lib下的struts包:
-rw-r--r-- 1 weblogic app 438203 8月 19 18:28 struts.jar
-rw-r--r-- 1 weblogic app 328896 8月 19 18:28 struts-core-1.3.8.jar
-rw-r--r-- 1 weblogic app 39644 8月 19 18:28 struts-extras-1.3.8.jar
-rw-r--r-- 1 weblogic app 251521 8月 19 18:28 struts-taglib-1.3.8.jar
-rw-r--r-- 1 weblogic app 119653 8月 19 18:28 struts-tiles-1.3.8.jar
我记得struts.jar 和 struts-core-1.3.8.jar 包起的作用是一样了,会不会因为服务器加载jar包的顺序不一样,导致只加载了一个,而这个却不能找到struts-config.xml的路径? 于是把struts.jar重命名了,如下:
-rw-r--r-- 1 weblogic app 438203 8月 19 18:28 struts.jar.zk
-rw-r--r-- 1 weblogic app 328896 8月 19 18:28 struts-core-1.3.8.jar
-rw-r--r-- 1 weblogic app 39644 8月 19 18:28 struts-extras-1.3.8.jar
-rw-r--r-- 1 weblogic app 251521 8月 19 18:28 struts-taglib-1.3.8.jar
-rw-r--r-- 1 weblogic app 119653 8月 19 18:28 struts-tiles-1.3.8.jar
然后重启了weblogic服务器,不报错了,浏览器访问也ok了。果然是jar包冲突问题。是因为weblogic加载jar包的顺序不一样导致的。
但是一直想不明白的是5,7,8节点为什么就可以? 四台服务器的配置都是一模一样的。待求解。