Java

本类阅读TOP10

·使用MyEclipse开发Struts框架的Hello World!(录像1)
·hibernate配置笔记
·AOP编程入门--Java篇
·linux下Tomcat 5.0.20 与 Apache 2 安装/集成/配置
·在win2003下整合了整合Tomcat5.5+ apache_2.0.53+ mod_jk_2.0.47.dll
·构建Linux下IDE环境--Eclipse篇
·Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
·ASP、JSP、PHP 三种技术比较
·Tomcat5.5.9的安装配置
·AWT GUI 设计笔记(二)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
ClassLoader Hell?

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

ClassLoader Hell?

My team is developing a complex project that depends on lots of third party jars. Some new colleagues come to this project recently. So they have to set up a new environment to share in our work. It’s so surprised that nobody could set up this environment without my help. So my colleagues fell so sadly about it: ”what a notorious classloader hell!”.

So I ask myself the classloader is really notorious? My answer is no. I give some briefly introduction our developing environment here: We put all third party jars in a shared network directory that sounds like a MAVEN style repository and there are some IDES in our team such as Intellj IDEA, Eclipse and JBuilder. So there is no way to share a common project file among the team (I know this may be a bad manner, but it’s the fact in our team). Everyone have to set the classpath in different IDES with a manifest of third party jars. Everyone’s environment is ok in compiling phase and fails in runtime phase. So I checked their environment one by one: they all add some other jars that are not used in the project and they do not really get the difference between runtime phase and compiling phase. The compliers in IDES may facilitate the system level classpath to compile our source code. So we all put the third party jars in the system level classloader. But there is a big difference in runtime phase. Different application server may have different classloader with different mechanisms. The tomcat server that our project utilize has sever classloader:

bootstrap<-> extension<->system<->common<->catalina<->shared<->web

and different classloader may take different responsibilities. For example the common classloader is shared by tomcat and web applications that deployed in this tomcat. So we MUST have a good knowledge about classloader too, otherwise we may get an unwanted result. A typical error occurred in our colleagues is ClassNotFoundException. They all like to put all third party jars in the system classlaoder and some jars in system classloader may depend on some servlet APIS. But the common classloader takes the responsibility to load the servlet jars. If we do not really get idea of classloader in tomcat, so we may not resolve this problem quickly.

(TBC...)   

 




相关文章

相关软件