---- Costa Basil <[EMAIL PROTECTED]> schrieb:
> Hi:
>
> I am using Myfaces core 1.1.5/Tomahawk 1.1.6 on a weblogic 9.1/jdk1.5.0_4
> jrockit server on a redhat linux server. Rarely -3 times so far from June- I
> get the exception below.
>
> I never got it on my computer, I never got it in the test environment, only 3
> times in production. There are no error messages before this error, just this
> error out of the blue. I restart weblogic and everything is fine.
>
> I did my homework, I configured everything according to the documents. I am
> not using forwards and I use redirections so I think what was described in
> the faq (http://wiki.apache.org/myfaces/FAQ - search for extensionsfilter)
> doesn't apply here.
>
> Did you see this error? I checked the source code (here is the link to the
> class
> http://myfaces.apache.org/tomahawk/xref/org/apache/myfaces/renderkit/html/util/AddResourceFactory.html)
> and it is almost as if the web.xml file is not parsed properly. I am worried
> that every time the weblogic server is restarted the app will not be working
> properly because of this error.
>
> java.lang.IllegalStateException: ExtensionsFilter not correctly configured.
> Resource mapping missing. Resources cant be delivered. Please see:
> http://myfaces.apache.org/tomahawk/extensionsFilter.html
> at
> org.apache.myfaces.renderkit.html.util.AddResourceFactory.throwExtensionsFilterMissing(AddResourceFactory.java:358)
> at
> org.apache.myfaces.renderkit.html.util.AddResourceFactory.checkEnvironment(AddResourceFactory.java:337)
> at
> org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:273)
> at
> org.apache.myfaces.custom.document.DocumentHeadRenderer.writeBeforeEnd(DocumentHeadRenderer.java:54)
> at
> org.apache.myfaces.custom.document.AbstractDocumentRenderer.closeTag(AbstractDocumentRenderer.java:70)
> at
> org.apache.myfaces.custom.document.AbstractDocumentRenderer.encodeEnd(AbstractDocumentRenderer.java:83)
> at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
> at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:498)
> at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:366)
>
This exception does not happen at startup, it's generated during handling of a
request if some tomahawk component tries to declare a dependency on some
resource (eg a css or javascript file), and the tomahawk resource-management
code detects that the request has not passed through the ExtensionsFilter.
In your separate email, you do appear to have the filter set up correctly, so
that it is applied to every JSF request:
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
The error message you report is only output if code calls AddResourceFactory,
and the only thing that does that is Tomahawk components. And those components
will not be executed except inside a JSF request. But your servlet mapping
correctly ensures that the extensions filter runs whenever the FacesServlet
runs.
Hmm..I wonder if it is possible that some of your users are occasionally typing
in raw urls like "/foo.jsp", causing the pages to be run as jsp pages rather
than as jsf pages? The components would then run without the ExtensionsFilter.
The page would certainly fail eventually, but I don't know whether the
ExtensionsFilter error or some other error would be reported first. It's not
likely this is the cause, but maybe worth checking that you correctly block
.jsp urls...
Otherwise I would guess that there is some thread-unsafe code somewhere in
ExtensionsFilter or AddResourceFactory or similar. That certainly matches your
description: an intermittent failure that only happens under production load.
Finding thread-safety problems is unfortunately not easy. I have had a quick
look at the code, and cannot see any problems. It's really pretty simple: add
flag to request-scope in the ExtensionsFilter, then later look in the
request-scope to see if the flag is there. And there should never be
thread-safety issues checking the request-scope vars.
Well, one other remote possibility is a bug in weblogic that sometimes doesn't
run the right filters, but that's fairly unlikely.
Hmm..from a quick look at the code, this looks a bit worrying
thread-safety-wise:
if (extctx.getApplicationMap().containsKey(ENV_CHECKED_KEY))
{
// already checked
return;
}
The application-scope vars are being accessed without a lock. Reading from a
normal Map object is not thread-safe. The Sun javadoc for getApplicationMap do
not mention anything about what kind of locking is required to access
application-scoped data. Probably needs further investigation, but it is
unlikely to be the cause of your problem anyway. At worst, this should cause
the slightly time-consuming check to be repeated when not necessary.
NB: the official config docs for ExtensionsFilter are here:
http://myfaces.apache.org/tomahawk/extensionsFilter.html
Regards,
Simon