[
http://issues.apache.org/jira/browse/MYFACES-1121?page=comments#action_12366451
]
Ramon Casha commented on MYFACES-1121:
--------------------------------------
Ok here's what I did to fix it. Note that this is a duct tape solution.
Edit HtmlRendererUtils.java, function "public static String
selectContentType(String contentTypeListString)" (line 995 or thereabouts)
Replace the first bit with:
if (contentTypeListString == null)
{
FacesContext context = FacesContext.getCurrentInstance();
if(context == null) {
contentTypeListString = HTML_CONTENT_TYPE;
} else {
contentTypeListString = (String)
context.getExternalContext().getRequestHeaderMap().get("Accept");
if(contentTypeListString == null)
{
if (log.isDebugEnabled())
log.debug("No content type list given, creating
HtmlResponseWriterImpl with default content type.");
contentTypeListString = HTML_CONTENT_TYPE;
}
}
}
The main change is that if FacesContext.getCurrentContext() is null, it uses
the default content type too.
> FacesContext.getCurrentContext is null after login on Tomcat/JBoss
> ------------------------------------------------------------------
>
> Key: MYFACES-1121
> URL: http://issues.apache.org/jira/browse/MYFACES-1121
> Project: MyFaces
> Type: Bug
> Components: Implementation
> Versions: Nightly
> Environment: Windows XP; JBoss 4.0.4RC1
> Reporter: Ramon Casha
>
> FacesContext.getCurrentContext is null in the page following a successful
> login. The login is a standard JSP forms-based login. The form redirects to
> j_security_check as normal, then presumably it gets automatically redirected
> to the originally requested page. That's when the error occurs (see stack
> trace below). If I then refresh the page, it displays correctly.
> 12:46:14,137 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces
> Servlet threw exception
> java.lang.NullPointerException
> at
> org.apache.myfaces.renderkit.html.HtmlRendererUtils.selectContentType(HtmlRendererUtils.java:995)
> at
> org.apache.myfaces.renderkit.html.util.DefaultAddResource.writeResponse(DefaultAddResource.java:786)
> at
> org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:143)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at
> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
> at
> org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
> at
> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:514)
> at
> org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
> at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
> at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
> at
> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
> at java.lang.Thread.run(Unknown Source)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira