本文介绍了类加载器问题 - 如何确定加载了哪些库版本(jar 文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚解决了另一个 *I-though-I-was-using-this-version-of-a-library-but-apparently-my-app-server-has-already-loaded-an-older-version-of-this-library-*issue(叹气).

I've just solved another *I-though-I-was-using-this-version-of-a-library-but-apparently-my-app-server-has-already-loaded-an-older-version-of-this-library-*issue (sigh).

有人知道验证(或监控)您的应用程序是否可以访问所有适当的 jar 文件或加载的类版本的好方法吗?

Does anybody know a good way to verify (or monitor) whether your application has access to all the appropriate jar-files, or loaded class-versions?

提前致谢!

[附注在我看来,这是开始使用 OSGi 模块架构的一个很好的理由!]

[P.S. A very good reason to start using the OSGi module architecture in my view!]

更新:这篇文章也有帮助!通过将 JBoss 的类加载器写入日志文件,它让我了解了加载了哪些类.

Update: This article helped as well! It gave me insight which classes JBoss' classloader loaded by writing it to a log file.

推荐答案

如果您碰巧在使用 JBoss,则有一个 MBean(类加载器存储库 iirc),您可以在其中询问已加载某个类的所有类加载器.

If you happen to be using JBoss, there is an MBean (the class loader repository iirc) where you can ask for all classloaders that have loaded a certain class.

如果所有其他方法都失败了,总是有 java -verbose:class 它将为每个正在加载的类文件打印 jar 的位置.

If all else fails, there's always java -verbose:class which will print the location of the jar for every class file that is being loaded.

这篇关于类加载器问题 - 如何确定加载了哪些库版本(jar 文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 07:23