启动 Tomcat 时出错 - 外部参数实体“%[dtd];””标记后有字符
我遇到了一个我无法弄清楚的错误。
基本上,正在运行的 Web 应用程序没有任何变化(除了可能涌入的数据)。而且它突然就死了。
访问该站点时,我看到 HTTP Status 500 错误,并出现 NullPointerException。我认为原因是我的本地主机日志中出现了先前的错误;
严重:Servlet 抛出 load() 异常 javax.servlet.UnavailableException:org.xml.sax.SAXParseException:外部参数实体“%[dtd];”标记后有字符。 在 org.apache.struts.action.ActionServlet.init(ActionServlet.java:402) 在 javax.servlet.GenericServlet.init(GenericServlet.java:212) 在 org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) 在 org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993) 在 org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149) 在 org.apache.catalina.core.StandardContext.start(StandardContext.java:4458) 在 org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) 在 org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) 在 org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) 在 org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630) 在 org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556) 在 org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491) 在 org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206) 在 org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314) 在 org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 在 org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) 在 org.apache.catalina.core.StandardHost.start(StandardHost.java:722) 在 org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 在 org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) 在 org.apache.catalina.core.StandardService.start(StandardService.java:516) 在 org.apache.catalina.core.StandardServer.start(StandardServer.java:710) 在 org.apache.catalina.startup.Catalina.start(Catalina.java:583) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) 在 org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
这让我觉得我的 struts-config.xml 有问题,但这在大约 2 年内没有发生任何变化并且一直工作正常。
有什么想法吗?
I am having an error which I cannot figure out.
Basically, NOTHING has changed on the web app that is running (apart from maybe an influx of data). And it has suddenly died.
When going to the site, I see a HTTP Status 500 error, with a NullPointerException. I think the reason for this, is the previous error in my localhost log;
SEVERE: Servlet threw load() exception
javax.servlet.UnavailableException: org.xml.sax.SAXParseException: External parameter entity "%[dtd];" has characters after markup.
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
It made me think something is wrong with my struts-config.xml, but this hasnt changed at all in about 2 years and has been working fine.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
struts-config.xml
文件引用位于 jakarta.apache.org 站点中的远程 DTD。虽然位置有效,但解析器尝试下载和使用 DTD 的尝试可能会失败,这可能是由于代理过滤了传出流量并返回 DTD 的无效内容。您可以下载 DTD 并将其托管在您自己的环境中,并让
struts-config.xml
文件使用这个新位置,如下所示:其中
example-org.com
指的是本地网络服务器。您还可以使用文件 URI 来引用本地目录上托管的 DTD:
当您将
struts-config_1_2.dtd
文件放在/tmp
中时,这将起作用。 Tomcat主机目录;您需要确保 Tomcat 可以读取此文件。Your
struts-config.xml
file refers to a remote DTD located in the jakarta.apache.org site. While the location is valid, it might be the case that attempts to download and use the DTD by the parser have failed, presumably due to a proxy that filters outgoing traffic and returns invalid content for a DTD.You could download the DTD and host it in your own environment, and have the
struts-config.xml
file use this new location, as demonstrated below:where
example-org.com
refers to a local web server.You can also use file URIs instead, to refer to the DTD hosted on a local directory:
which would work when you place the
struts-config_1_2.dtd
file in the/tmp
directory of the Tomcat host; you'll need to ensure that Tomcat can read this file.就我而言,[错误]外部参数实体“%(null);”标记后有字符缺少“!”在 ATTLIST 标记的开头。
这是提供的 DTD 架构中的拼写错误。
我有这个:
解决方案是添加“!”简单地:
In my case the [ERROR] External parameter entity "%(null);" has characters after markup was cased by a missing "!" at the beginning of the ATTLIST tag.
It was a typo in the provided DTD schema.
I had this:
and the solution was adding the "!" simply: