DWR一个让人很不解的问题,希望高手能帮帮忙,谢谢了!!!

雨中的海 2011-07-26 09:00:58
昨天在用dom4j解析DWR.xml配置文件时,抛出如下异常:
Connection timed out: connect Nested exception: Connection timed out: connect
org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.dom4j.io.SAXReader.read(SAXReader.java:321)
at com.bf.common.pxvp.util.AutoCreateFile.createDwrDemoXml(AutoCreateFile.java:159)
at com.bf.common.pxvp.util.AutoCreateFileMain.createFile(AutoCreateFileMain.java:26)
at com.bf.common.pxvp.util.AutoCreateFileMain.main(AutoCreateFileMain.java:14)
Nested exception:
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
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 org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.dom4j.io.SAXReader.read(SAXReader.java:321)
at com.bf.common.pxvp.util.AutoCreateFile.createDwrDemoXml(AutoCreateFile.java:159)
at com.bf.common.pxvp.util.AutoCreateFileMain.createFile(AutoCreateFileMain.java:26)
at com.bf.common.pxvp.util.AutoCreateFileMain.main(AutoCreateFileMain.java:14)
Nested exception: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
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 org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.dom4j.io.SAXReader.read(SAXReader.java:321)
at com.bf.common.pxvp.util.AutoCreateFile.createDwrDemoXml(AutoCreateFile.java:159)
at com.bf.common.pxvp.util.AutoCreateFileMain.createFile(AutoCreateFileMain.java:26)
at com.bf.common.pxvp.util.AutoCreateFileMain.main(AutoCreateFileMain.java:14)
dwr.xml文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">

<dwr>
<allow>
<create creator="spring" javascript="UserService">
<param name="beanName" value="userService"/>
</create>
<create creator="spring" javascript="PxvpService">
<param name="beanName" value="pxvpService"/>
</create>
</allow>
</dwr>

java代码如下:

public void createDwrDemoXml(String dirName, String modelName) {
System.out.println("AutoCreateFile.creatDwrDemoXml()...");
System.out.println("file is:"+System.getProperty("user.dir") + "\\WebRoot\\WEB-INF\\DWR-DEMO.xml");
try {
Document doc = new SAXReader().read(System.getProperty("user.dir") + "\\WebRoot\\WEB-INF\\DWR-DEMO.xml"); //指定xml文件

Element root = (Element)doc.getRootElement().selectSingleNode("/dwr/allow"); //获取根节点
List<Element> elementsList = root.elements(); //获取allow节点下的所有节点
for(Element element:elementsList){ //判断节点是否添加过
if((element.attributeValue("javascript").equals(modelName + "Service"))){
element.detach(); //删除已存在节点
break;
}
}
Element newRoot = root.addElement("create"); //添加一个新的节点
newRoot.addAttribute("creator", "spring"); //向节点添加属性及属性值
newRoot.addAttribute("javascript", modelName + "Service");
Element inteRoot = newRoot.addElement("param"); //添加新节点的子节点
inteRoot.addAttribute("name", "beanName");
inteRoot.addAttribute("value", modelName.toLowerCase() + "Service");
xmlWriter(doc,System.getProperty("user.dir") + "\\WebRoot\\WEB-INF\\DWR-DEMO.xml");
System.out.println(doc.asXML());
} catch (DocumentException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}


希望各位大鸟能帮帮忙,小弟在此谢过了!!!
...全文
8231 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
雨中的海 2011-07-28
回复
雨中的海 2011-07-27
各位大鸟帮帮忙啊,谢谢了!
回复
雨中的海 2011-07-26
啊啊啊啊 啊,要沉了啊!!自己顶一下,高手帮帮忙啊!
回复
雨中的海 2011-07-26
[Quote=引用 1 楼 zwj6612 的回复:]
createDwrDemoXml

为什么要写这个啊
[/Quote]
这是个方法名,我要用java代码写dwr.xml文件,然后就这样命名了,嘿嘿。有什么不规范的地方,还请大哥多多指教
回复
zwj6612 2011-07-26
createDwrDemoXml

为什么要写这个啊
回复
lsw645645645 2011-07-26
不懂,帮顶啦
回复
相关推荐
发帖
Ajax
创建于2007-09-28

5.2w+

社区成员

Web 开发 Ajax
申请成为版主
帖子事件
创建了帖子
2011-07-26 09:00
社区公告
暂无公告