情景:
项目使用了struts2框架,部署到tomcat中,而tomcat所在机器没有联网(处于公司安全方面的原因),所以启动tomcat时,报错:
tomcat Unable to load configuration. - Class: java.net.SocketInputStream
因为struts配置文件如下:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation/DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
如上所示,它会 去http://struts.apache.org/dtds/struts-2.3.dtd下载dtd文件,但是没有联网,所以就报上述错误(标红的)了。
为了解决这个问题,就使用了本地的dtd文件,范例:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation/DTD Struts Configuration 2.1.7//EN" "./com/tdr/mbs/endpoint/dtd/struts-2.3.dtd">
后来项目部署到其他tomcat时,报错:
Caused by: no protocol dtd - Class: java.net.URL
详细报错信息:
Unable to load configuration. - Class: java.net.URL File: URL.java Method: <init> Line: 567 - java/net/URL.java:567:-1 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 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:593) 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:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: Unable to load file:/D:/个人资料/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/endpoint/WEB-INF/classes/struts.xml - Class: java.net.URL File: URL.java Method: <init> Line: 567 - java/net/URL.java:567:-1 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:954) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:163) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:130) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:209) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) ... 22 more Caused by: no protocol: ./com/a//endpoint/dtd/struts-2.3.dtd - Class: java.net.URL File: URL.java Method: <init> Line: 567 - java/net/URL.java:567:-1 at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:949) ... 26 more Caused by: java.net.MalformedURLException: no protocol: ./com/a//endpoint/dtd/struts-2.3.dtd at java.net.URL.<init>(URL.java:567) at java.net.URL.<init>(URL.java:464) at java.net.URL.<init>(URL.java:413) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:395) at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:113) ... 27 more
上网查了半天,发现这是tomcat的一个bug。
出现的场景:
<!--[if !supportLists]-->(1) <!--[endif]-->tomcat 的安装目录中有中文字符;
struts.xml中没有使用网络上的dtd文件,而是使用的本地的dtd文件
问题原因:tomcat 安装目录中有中文字符。
解决方法:把tomcat的安装目录拷贝到无中文字符的路径中。
后记:后来我使用eclipse运行项目,也报相同的错误,因为我eclipse的工作空间(workspace)是:
D:\个人资料\eclipse\workspace
我的eclipse的工作空间的路径中包含中文字符。
报错信息:
Caused by: Unable to load file:/D:/个人资料/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/endpoint/WEB-INF/classes/struts.xml - Class: java.net.URL
File: URL.java
Method: <init>
Line: 567 - java/net/URL.java:567:-1
也就是说eclipse把项目部署到了 D:/个人资料/eclipse/workspace/.metadata/ 中
解决方法:修改eclipse的工作区间(没办法了,一定要保证项目部署的路径中没有中文字符)
相关推荐
Caused by: java.net.UnknownHostException: openapi.alipay.com
"java.net.SocketException Connection reset 解决方法" 在 Java 编程中,SocketException 是一种常见的异常,特别是在网络编程中。Conexion reset by peer 是一种特殊的 SocketException,它发生在客户端和服务器...
jdk 17需要 新增 配置 如下 jvm参数 --add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
主要介绍了java.net.ConnectException: Connection refused问题解决办法的相关资料,需要的朋友可以参考下
Flink-1.11.2与Hadoop3集成JAR包,放到flink安装包的lib目录下,可以避免Caused by: org.apache.flink.core.fs.UnsupportedFileSystemSchemeException: Hadoop is not in the classpath/dependencies.这个报错,实现...
Java中的`java.net.SocketException: Connection reset`是一个常见的网络编程错误,通常表示在TCP/IP通信过程中,连接突然中断。这个异常可能在客户端或服务器端发生,通常与数据传输的异常中断有关。 首先,我们来...
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory 需要jar log4j-1.2.16.jar slf4j-api-1.6.1.jar slf4j-log4j12-1.6.1.jar
Caused by: java.sql.SQLException: java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver at com.trs.gateway.commons.hive.HiveFeature.getConnection(HiveFeature.java:57) at ...
Yes No No Yes No History 2018-04-16: Version 8.045a: Changed package metadata to include proper dependencies and restrictions 2018-02-08: Version 8.045: Support for more NIC models and VLAN tags ...
kettle之Caused by: java.lang.ClassNotFoundException: org.pentaho.metastore.api.IMetaStore错误
Causedby: java.lang.ClassNotFoundException: org.jdesktop.swingworker.SwingWorker at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged...
解决webMagic0.7.3 出现javax.net.ssl.SSLException: Received fatal alert: protocol_version的问题-附件资源
Caused by: java.sql.SQLException: java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver at com.trs.gateway.commons.hive.HiveFeature.getConnection(HiveFeature.java:57) at ...
Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java...
PyQt5-5.12.3-5.12.9-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl linux离线安装包 需要的下载 PyQt5-5.12.3-5.12.9-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl linux离线安装包 需要的下载
然而,当你遇到“javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair”的错误时,这意味着在建立SSL/TLS连接时,Diffie-Hellman(DH)密钥交换算法遇到了问题。DH是一种非对称...
Caused by: java.util.jar.JarException: file:/opt/code/signal-Server-master/target/TextSecureServer-1.87.jar has unsigned entries - org/whispersystems/dispatch/DispatchManager$4.class at javax.crypto....
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure的一个解决方案-附件资源
在Java应用程序运行过程中,"java.lang.OutOfMemoryError: PermGen space"错误是常见的一个问题,尤其是在使用Tomcat这样的Java应用服务器时。这个错误表明应用程序在 PermGen 区域(Permanent Generation)耗尽了...