关于HTTP Status 404 - Servlet action is not available的问题
自己在虚拟机里开发一个小系统,做练手用,平时都运行好好的,最近一两个星期都没动了,今天兴致一来,想写点东西。启动tomcat,能访问到登陆页面,但是输入正确的用户名和密码,点击登陆之后,浏览器上报出异常:HTTP Status 404 - Servlet action is not available 。
而tomcat日志则是这样的异常信息:
- Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
-Initializing,config='org.apache.struts.action.ActionResources',returnNull=true
-Parsingerrorprocessingresourcepath
java.net.UnknownHostException:struts.apache.org
atjava.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
atjava.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
atjava.net.Socket.connect(Socket.java:579)
atjava.net.Socket.connect(Socket.java:528)
atsun.net.NetworkClient.doConnect(NetworkClient.java:180)
atsun.net.www.http.HttpClient.openServer(HttpClient.java:388)
atsun.net.www.http.HttpClient.openServer(HttpClient.java:483)
atsun.net.www.http.HttpClient.<init>(HttpClient.java:213)
atsun.net.www.http.HttpClient.New(HttpClient.java:300)
atsun.net.www.http.HttpClient.New(HttpClient.java:316)
atsun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:992)
atsun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:928)
atsun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:846)
atsun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1296)
atjava.net.URL.openStream(URL.java:1035)
atorg.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(UnknownSource)
atorg.apache.xerces.impl.XMLEntityManager.startEntity(UnknownSource)
atorg.apache.xerces.impl.XMLEntityManager.startDTDEntity(UnknownSource)
atorg.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(UnknownSource)
atorg.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(UnknownSource)
atorg.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(UnknownSource)
atorg.apache.xerces.parsers.XML11Configuration.parse(UnknownSource)
atorg.apache.xerces.parsers.DTDConfiguration.parse(UnknownSource)
atorg.apache.xerces.parsers.XMLParser.parse(UnknownSource)
atorg.apache.xerces.parsers.AbstractSAXParser.parse(UnknownSource)
atorg.apache.commons.digester.Digester.parse(Digester.java:1548)
atorg.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1006)
atorg.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)
atorg.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
atjavax.servlet.GenericServlet.init(GenericServlet.java:212)
atorg.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
atorg.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
atorg.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
atorg.apache.catalina.core.StandardHost.start(StandardHost.java:722)
atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
atorg.apache.catalina.core.StandardService.start(StandardService.java:516)
atorg.apache.catalina.core.StandardServer.start(StandardServer.java:710)
atorg.apache.catalina.startup.Catalina.start(Catalina.java:583)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
atjava.lang.reflect.Method.invoke(Method.java:601)
atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
……经过调试,问题定位在struts-config.xml配置文件里的dtd校验:<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">这里有问题。
开发所在的虚拟机了确实是不能联网,怀疑是不是不能下载dtd文件的原因,于是就手动下载后,放到struts-config.xml同一目录下,重启tomcat后,再登陆,问题依然,无计可施,索性把:<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">这一行给删了,重启登陆,这次却意外的成功了。
这到底是什么原因呢,引入的包绝对没动过,代码也不会有问题,因为之前一直都能运行,删除了那句校验后也能正常运行,这句校验语句到底是怎么回事?没有头绪。