Hi Stan,
I've just tried the latest snapshot and I get a new error now :(
11:33:51,072 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException
at com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:428)
at com.sun.faces.context.FacesContextImpl.getExternalContext(FacesContextImpl.java:149)
at org.jboss.jsfunit.context.JSFUnitFacesContext.getExternalContext(JSFUnitFacesContext.java:114)
at org.jboss.jsfunit.context.JSFUnitFacesContext.release(JSFUnitFacesContext.java:170)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:619)
11:33:51,175 ERROR [[ServletTestRunner]] Servlet.service() for servlet ServletTestRunner threw exception
java.lang.IllegalStateException
at com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:428)
at com.sun.faces.context.FacesContextImpl.getExternalContext(FacesContextImpl.java:149)
at org.jboss.jsfunit.context.JSFUnitFacesContext.release(JSFUnitFacesContext.java:170)
at org.jboss.jsfunit.context.JSFUnitFacesContext.valueUnbound(JSFUnitFacesContext.java:201)
at org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1649)
at org.apache.catalina.session.StandardSession.removeAttribute(StandardSession.java:1207)
at org.apache.catalina.session.StandardSession.removeAttribute(StandardSession.java:1179)
at org.apache.catalina.session.StandardSessionFacade.removeAttribute(StandardSessionFacade.java:140)
at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:127)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
...
...
The application I'm working on uses form authentication set up in the following manor in the web.xml:
<security-constraint>
<display-name>Must be logged in</display-name>
<web-resource-collection>
<web-resource-name>All Pages</web-resource-name>
<description>Secure all pages in the application</description>
<url-pattern>*.jspx</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description>Must have login role to view any pages</description>
<role-name>log_in</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>xxxxx</realm-name>
<form-login-config>
<form-login-page>/login.jspx</form-login-page>
<form-error-page>/loginError.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description>Must be logged in to view any pages.</description>
<role-name>log_in</role-name>
</security-role>
And in the tests I use the following code to ensure that the test authenticates with the system:
public static JSFClientSession getClientSession(String url)
throws MalformedURLException, IOException, SAXException {
JSFClientSession client = new JSFClientSession(url);
JSFServerSession server = new JSFServerSession(client);
if (server.getCurrentViewID().endsWith("login.xhtml")) {
// we've been redirected, need to login
WebForm loginForm = client.getWebResponse().getFormWithID("loginform");
if (loginForm != null) {
loginForm.setParameter("j_username", "regaladmin");
loginForm.setParameter("j_password", "regaladmin");
SubmitButton loginButton = loginForm.getSubmitButton("login");
if (loginButton != null) {
loginButton.click();
} else {
throw new IOException("Test for " + url + " was redirected to the login " +
"page but we were unable to locate the login button");
}
FacesContext facesContext = FacesContextBridge.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
String expectedViewId = url.replace(".jspx", ".xhtml");
if (!expectedViewId.equals(root.getViewId())) {
throw new IOException("Failed to login to application, last view id was " + root.getViewId());
}
// no we are logged in, re-request the client to refresh it
client = new JSFClientSession(url);
} else {
throw new IOException("Test for " + url + " was redirected to the login " +
"page but we were unable to locate the login form");
}
}
return client;
}
I've stuck a debugger on it an it blows up when trying to create the JSFClientSession (JSFClientSession client = new JSFClientSession(url);).
This was working in the beta-1 code, but not the snapshot.