【解决】Caused by: org.apache.tiles.definition.DefinitionsFactoryException: I/O

申明

本篇博客为转载!楼主只是在原来的基础上进行了一点修改!原文地址,再次感谢原作者!

问题描述

使用springmvc tiles模板框架的时候出现如下错误

Caused by: org.apache.tiles.definition.DefinitionsFactoryException: I/O Error reading definitions.     at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:273)     at org.apache.tiles.definition.UrlDefinitionsFactory.readDefinitions(UrlDefinitionsFactory.java:286)     at org.apache.tiles.definition.UrlDefinitionsFactory.init(UrlDefinitionsFactory.java:130)     at org.apache.tiles.impl.BasicTilesContainer.initializeDefinitionsFactory(BasicTilesContainer.java:406)     at org.apache.tiles.impl.BasicTilesContainer.init(BasicTilesContainer.java:130)     at org.apache.tiles.factory.TilesContainerFactory.initializeContainer(TilesContainerFactory.java:232)     at org.apache.tiles.factory.TilesContainerFactory.createTilesContainer(TilesContainerFactory.java:198)     at org.apache.tiles.factory.TilesContainerFactory.createContainer(TilesContainerFactory.java:163)     at org.apache.tiles.web.startup.TilesListener.createContainer(TilesListener.java:90)     at org.apache.struts2.tiles.StrutsTilesListener.createContainer(StrutsTilesListener.java:68)     at org.apache.tiles.web.startup.TilesListener.contextInitialized(TilesListener.java:57)     ... 15 more Caused by: java.net.SocketException: Connection reset     at java.net.SocketInputStream.read(Unknown Source)     at java.io.BufferedInputStream.fill(Unknown Source)     at java.io.BufferedInputStream.read1(Unknown Source)     at java.io.BufferedInputStream.read(Unknown Source)     at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)     at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)     at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)     at org.apache.commons.digester.Digester.createInputSourceFromURL(Digester.java:2072)     at org.apache.commons.digester.Digester.resolveEntity(Digester.java:1725)     at com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEntity(Unknown Source)     at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntityAsPerStax(Unknown Source)     at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)     at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)     at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)     at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)     at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)     at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)     at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)     at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)     at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)     at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)     at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)     at org.apache.commons.digester.Digester.parse(Digester.java:1887)     at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:267)

解决办法

1、替换tilesContext.xml文件头(配置tiles的文件)

原来:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">

把上面的替换成下面的,原来使用的是tiles 2.1 dtd文件修改成3.0问题解决

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
       "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">

2、把.dtd文件下载下来 放到tilesContext.xml同级目录 不需要网上验证语法规则
下载地址 http://tiles.apache.org/dtds/tiles-config_3_0.dtd,tilesContext.xml头文件内容如下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
       "tiles-config_3_0.dtd">  //修改路径

注意:楼主第一种办法没解决!因为最终原因是不能访问http://tiles.apache.org/dtds/tiles-config_3_0.dtd,从网盘下载dtd文件并修改路径才解决!但是我是放到src同级目录下!若是别的路径,则改为src/../..dtd
如果apache访问不了 请到原作者的网盘中下载,http://pan.baidu.com/s/1mgBNSPM

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值