开发者

Custom Tomcat Realm and a whole load of JARs in the Lib directory

So I am working on a project whereby we needed to create a custom Tomcat Realm implementation to read authentication credentials from a mongo backed datastore.

This has been pretty painless, but the implementation we have come up with has several dependencies on external libs i.e. scala libs, the java mongo-db driver, spring, salat (a mongodb ORM) etc....

Now in order for Tomcat to use this Realm we must deploy our Jar (and all the dependent jars) to tomcats lib folder.

Being pretty new to Java, I have no idea how much of an issue this is, but it doesn't seem nice to me. So really, my question is what issues would I have with dumping a load of JARs into Tomcats lib dir开发者_开发技巧ectory?

Cheers, Chris.


Most likely dependencies will become a problem. All JARs you place in tomcat/lib are visible to the WARs you deploy at a later time. I suppose your Realm implementation is the base for one or more web applications.

Let's say your Realm depends on Spring 2.0 and you're required to place those libs in tomcat/lib and afterwords you deploy a WAR using Spring 3.0. The WAR will see all classes available in tomcat/lib - the Spring 2.0 classes. So your WAR ships the 3.0 classes in WEB-INF/lib, at runtime it can see the Spring 2.0 libs in tomcat/lib as well as its own Spring 3.0 libs in WEB-INF lib. This is going to cause trouble...

I'm not aware of a simple solution for this, maybe you should have a look at OSGI and Tomcat integration. No question, it won't make life easier...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜