why does mojarra 2.1 scan every other war on each module startup?

末鹿安然 提交于 2020-01-23 12:22:16

问题


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).


回答1:


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.



来源:https://stackoverflow.com/questions/5327070/why-does-mojarra-2-1-scan-every-other-war-on-each-module-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!