---- Costa Basil <[EMAIL PROTECTED]> schrieb:
> It turns out that this problem is due to the fact that some code in the 
> Myfaces framework is not thread-safe. I've been able to reproduce this error 
> with JMeter using a threadgroup of 3 users that log in at the same time and 
> navigate to the home page which is where it fails. 

That's very useful info. Could you please create a JIRA issue?
I presume that these "3 users" all have separate http sessions?

> 
> Unfortunately I can't point my finger to the code, but I think it has 
> something to do with the following block from  AddResourceFactory.java 
> (checkEnvironment function) and the way other code that uses 
> getApplicationMap() interacts with it.
> 
>         synchronized (extctx.getApplicationMap())
>         {
>             if (addResource.requiresBuffer())
>             {
>                 if 
> (!extctx.getRequestMap().containsKey(ExtensionsFilter.DOFILTER_CALLED))
>                 {
>                     throwExtensionsFilterMissing("JSF mapping missing. JSF 
> pages not covered.");
>                 }
>             }
> 
>             boolean foundMapping = false;
>             
>             List facesServletMappings = 
> WebXml.getWebXml(extctx).getFacesExtensionsFilterMappings();
>             for (Iterator iterServletMappings = 
> facesServletMappings.iterator(); iterServletMappings.hasNext();)
>             {
>                 FilterMapping filterMapping = (FilterMapping) 
> iterServletMappings.next();
>                 if (checkFilterPattern(extctx, filterMapping))
>                 {
>                     foundMapping = true;
>                     break;
>                 }
>             }
>             
>             if (!foundMapping)
>             {
>                 throwExtensionsFilterMissing("Resource mapping missing. 
> Resources cant be delivered.");
>             }
>             
>             extctx.getApplicationMap().put(ENV_CHECKED_KEY, Boolean.TRUE);
>         }

Yes, as I mentioned in my email this does seem suspect. Reading from  a Map 
that may be concurrently modified in another thread is not a good idea. However 
(as I also mentioned then) I cannot see how this could lead to your problem. At 
the worst it seems to me that this code might NOT find the map entry when it is 
actually there. And in that case, it would just redo all the testing when it 
doesn't need to. So quite what the problem is remains a mystery..


>  
> 
> For now, I use the following parameter to avoid executing the block above and 
> the app doesn't seem to fail anymore.
> 
>   <context-param>
>     <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
>       <param-value>false</param-value>
>   </context-param>

If the problem is that the extensions-filter *has* run, but the 
AddResourceFactory class just isn't correctly detecting that, then this is 
indeed the right fix.

If the problem is that under some circumstances the filter has *not* correctly 
wrapped the response, then this is wrong, as the generated page will *silently* 
fail to have the correct references to stylesheets, js scripts, etc inserted. 
If you find that tomahawk components are intermittently not working or being 
properly rendered then this might be the cause.

Regards,

Simon

Reply via email to