为什么 mojarra 2.1 在每个模块启动时扫描所有其他战争?

发布于 2024-10-22 03:44:55 字数 386 浏览 0 评论 0原文

我们有一个巨大的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜兔 2024-10-29 03:44:56

我找到了原因,以及一些解决方法。

在与 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 行左右,我注释掉了一些行:

//            if (provider instanceof DelegatingAnnotationProvider &&
//                null != annotationScanner) {
//                // This InjectionProvider is capable of annotation scanning *and*
//                // injection.
//                ((DelegatingAnnotationProvider)provider).setAnnotationScanner(annotationScanner,
//                        metadataGetter.getJarNames());
//                scanUris = Collections.emptySet();
//            } else {
                // This InjectionProvider is capable of annotation scanning only
                scanUris = metadataGetter.getAnnotationScanURIs();
//            }

日志现在不再那么冗长。看来 Glassfish 仍在扫描每个类,所以我仍然收到这样的警告:

[#|2011-03-18T13:47:05.019+0100|WARNING|oracle-glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_ThreadID=57;_ThreadName=Thread-1;|WEB9052: Unable to load class org.apache.myfaces.custom.inputTextHelp.HtmlTextHelpRenderer, reason: java.lang.ClassNotFoundException: org.apache.myfaces.custom.inputTextHelp.HtmlTextHelpRenderer|#]

但是没有来自 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:

//            if (provider instanceof DelegatingAnnotationProvider &&
//                null != annotationScanner) {
//                // This InjectionProvider is capable of annotation scanning *and*
//                // injection.
//                ((DelegatingAnnotationProvider)provider).setAnnotationScanner(annotationScanner,
//                        metadataGetter.getJarNames());
//                scanUris = Collections.emptySet();
//            } else {
                // This InjectionProvider is capable of annotation scanning only
                scanUris = metadataGetter.getAnnotationScanURIs();
//            }

The logs are now much less verbose. It seems Glassfish is still scanning every classes, so I still get warnings like this:

[#|2011-03-18T13:47:05.019+0100|WARNING|oracle-glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_ThreadID=57;_ThreadName=Thread-1;|WEB9052: Unable to load class org.apache.myfaces.custom.inputTextHelp.HtmlTextHelpRenderer, reason: java.lang.ClassNotFoundException: org.apache.myfaces.custom.inputTextHelp.HtmlTextHelpRenderer|#]

But no stacktrace from Mojarra, which is already quite less verbose.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文