为什么 mojarra 2.1 在每个模块启动时扫描所有其他战争?
我们有一个巨大的 EAR 应用程序,包含大约 20 个 ejb-jar 和 war 模块。
对于 Mojarra 启动的每个战争模块,它似乎都在尝试扫描所有其他战争的注释。类加载器无法使用其他战争,因此我遇到了很多异常。无论如何它最终都会启动,但它会用警告扰乱我的日志,我想如果没有这个(+100 秒),应用程序启动时间可能会少得多。
为了清楚起见,我有以下结构:
EAR
+- ejb1
+- ejb2
+- war1
+- war2
当 Mojarra 启动 war1 时,它抱怨 war2 中缺少类(ClassNotFoundException)。
我在升级到 Glassfish 3.1(以及 Mojarra 2.1)时看到了这一点。
We have a huge EAR application with about 20 ejb-jar and war modules.
For each war module that Mojarra starts, it seems it is trying to scan annotation on every other war. Other wars are unavailable to the classloader, so I get lot of exceptions. It eventually starts anyway, but it clutters my logs with warnings, and I guess application startup time could be much less without this (+100 seconds).
To make it clear, I have following structure:
EAR
+- ejb1
+- ejb2
+- war1
+- war2
When Mojarra starts war1, it complains about missing classes from war2 (ClassNotFoundException).
I saw this when upgrading to Glassfish 3.1 (and thus, Mojarra 2.1).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了原因,以及一些解决方法。
在与 Mojarra 2.1 一起发布的 Glassfish 3.1 上,类路径扫描被委托给 Glassfish。现在,Glassfish 似乎提供所有类别的耳档而不是战争。我为此打开了 http://java.net/jira/browse/JAVASERVERFACES-1995 (但这似乎确实是 Glassfish bug,而不是 JSF/Mojarra)。
在等待修复时,我像这样修补了 Mojarra:在 com.sun.faces.config.ConfigManager.java 中,第 834 行左右,我注释掉了一些行:
日志现在不再那么冗长。看来 Glassfish 仍在扫描每个类,所以我仍然收到这样的警告:
但是没有来自 Mojarra 的堆栈跟踪,这已经相当不那么详细了。
I found the reason, and some workaround.
On Glassfish 3.1, which ships with Mojarra 2.1, classpath scanning is delegated to Glassfish. Now, Glassfish seems to give all classes of ear file instead of war. I opened http://java.net/jira/browse/JAVASERVERFACES-1995 for that (but it really seems to be a Glassfish bug, not JSF/Mojarra).
While waiting for a fix, I patched Mojarra like this : in com.sun.faces.config.ConfigManager.java, around line 834, I commented out some lines:
The logs are now much less verbose. It seems Glassfish is still scanning every classes, so I still get warnings like this:
But no stacktrace from Mojarra, which is already quite less verbose.