2007年12月13日星期四

sun-web.xml之痛

去年开发的系统,突然出现了问题,问了原来的开发的成员,说时间太久忘了,只要找我,其实我也差不多忘了。

错误主要是在显示系统中详细信息和保存项目的时候,很快就定位是iplanet端数据库连接池配置问题。

于是,让DBA检查,将密码重新设置,没有成功。
让DBA发过来日志有如下错误,可能是sun-web.xml文件有问题,是不是UNIX下字符出现错误,将我本机的这个文件发过去给DBA,没有成功。

WEB0120: XML error parsing deployment descriptor [/~~~~~~~~/wwwroot/WEB-INF/sun-web.xml]
Failed to create the XML-DOM Document. Check your XML to make sure it is correct.
java.net.ConnectException: 连接超时 at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376) at org.apache.crimson.parser.Parser2.externalParameterEntity(Parser2.java:3064) at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1347) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:656)


最后,重新考虑这个日志的时候,忽略了“java.net.ConnectException: 连接超时 ” 这个错误。怎么会网络访问,重新检查sun-web.xml,发现DOCTYPE节点,其声明的dtd文件是指向http://www.sun.com/的,可能这就是问题所在。以前从来没有注意这个问题,对于DOCTYPE,PUBLIC指定DTD文件是在系统之外,需远程访问;如果是SYSTEM,就在本地找寻dtd文件。虽然在我机器上将网络断开,没有重现这个错误,但是比较肯定系统就是遇到这个问题。将这个节点去掉,将sun-web.xml发给系统管理员,果然成功了!


<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">

另外,将系统迁移到iplanet的时候,磕磕碰碰,花费了以整体的时间,记录下来以备忘。

1)Iplanet的版本。
从sun的官方网站下载要注册,我原来有帐户但是忘了,于是从别的地方下载了一个。本来是要6.1版本的,下来发现是6.0的,这就是后面很多错误的根源。
部署完成之后,访问系统的时候,总是出现如下错误:
“"No WebApplicationContext found: no ContextLoaderListener registered"”
在web.xml中增加如下内容,可以Iplanet可以成功启动。

<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>



但是访问系统的时候,出现Servlet 2.2中不支持setCharacterEncoding() 错误。乖乖,原来IPlanet只支持Servlet 2.2,而我需要的是2.3版本。于是从Sun上下载了6.1颁布,不需要在web.xml增加上述那段,部署成功。

2)数据库连接池的建立
在Iplanet端建立了连接池,出现总是找不到驱动程序的错误,而实际上classes2.jar已经在WEB-INF/lib路径下。最后在JVM Path Settings中将JDBC的路径直接出入,解决这个问题。








3)Iplanet程序的部署。


首先是将Web程序打包成war。但是Iplanet部署war文件的时候有大小限制,可以先不降lib目录打包,待部署完成再拷贝过去。
部署应用。其对应的路径为:
Administration Server > MyServer > vsclass1 > WebApplication。
其中MyServer是系统默认建立的服务器,vsclass1是系统默认建立的虚拟class。可以同时管理n个服务器,一个服务器上又可以建立n个vsclass1,一个vsclass可以对应多个WebApplication。所以,从左到右都是1:n的关系。为什么会有vsclass1的概念呢? 这是因为对于某些Web Application,其配置可能绝大部分相同,所以可以统一在vsclass层次定义就可,这些Web Applications共享这些设置。这个设计应该是为哪些提供hosting服务的机构设定的吧。但是看看现在hosting,绝大部分都在使用LAMP。
然后就是在vsclass层建立,数据库链接池和JDBC的Resource。
最后别忘了将lib拷贝到Web Application的WEB-INF目录下。


总结,
1) 最初发现问题的时候,虽然大概定位,但是没有再深究问题的根本,再加上时差的问题,问题解决效率不高。
2) 没有模拟服务器环境,而开始只在Tomcat上测试,而sun-web.xml在Tomcat环境下是不需要的,对问题的重现带来困难。
3) 在定位sun-web.xml文件的错误之后,没有静下心来研究文档结构,而是意味怀疑字符问题,耽误解决问题的时间。

Any way,问题总算解决了,休息一下,休息一下。

5 条评论:

匿名 说...

What's up, I wish for to subscribe for this webpage to take hottest updates, therefore where can i do it please help out.

My blog post air france travel map

匿名 说...

Thanks a bunch for sharing this with all of us you really recognise what you are talking approximately!
Bookmarked. Kindly also discuss with my site =).
We could have a link trade agreement between us

Also visit my blog post luxe vakantieparken frankrijk

匿名 说...

hello there and thank you for your information – I've certainly picked up anything new from right here. I did however expertise some technical points using this website, since I experienced to reload the site lots of times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I'm complaining, but slow loading instances times will sometimes affect your
placement in google and could damage your high-quality score
if advertising and marketing with Adwords. Well I'm adding this RSS to my e-mail and can look out for a lot more of your respective intriguing content. Ensure that you update this again very soon.

Feel free to visit my website - vakantiehuisje frankrijk huren - -

匿名 说...

I do trust all of the ideas you have offered in your post. They are really convincing and can
definitely work. Still, the posts are too short for
starters. May just you please lengthen them a little from next time?
Thank you for the post.

Here is my web site :: vakantiehuisje frankrijk

匿名 说...

Good post. I certainly love this website. Keep it up!

My weblog - vakantiehuisjes frankrijk huren