[
https://issues.jboss.org/browse/SOLDER-309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12651367#comment-12651367
]
Marek Schmidt commented on SOLDER-309:
--------------------------------------
There are two tests in the provided test case:
1. JsfRedirectObserverTest
The problem here is that "public void observeHttpRequest(@Observes
HttpServletRequest request, HttpServletResponse response)" doesn't work
* HttpServletResponse doesn't yet exist in the ImplicitServletObjectsHolder
when the first HttpServletRequest event is fired, so the injection fails
* the other problem is that the observer should be annotated with
"@Initialized" (or some other qualifier) as otherwise it will be called more
than once and the second redirect will fail.
changing it to "@Observes @Initialized HttpServletResponse response,
HttpServletRequest request" will make it work (sans the other problem below)
I am not convinced this is a bug, although it probably would be possible to
make this work somehow... At least we should make this clear in the
documentation.
2. JsfSecurityRulesTest
The other problem is the
{noformat}
<navigation-case>
<from-action>#{identity.login}</from-action>
<if>#{identity.loggedIn}</if>
<to-view-id>/home.xhtml</to-view-id>
<redirect/>
</navigation-case>
{noformat}
navigation rule which together with the
org.jboss.seam.faces.security.LoginListener leads to
{noformat}
18:19:42,481 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/solder-http-servlet-response-test].[Faces
Servlet]] (http--127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet
threw exception: javax.enterprise.event.ObserverException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) [:1.6.0_24]
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[:1.6.0_24]
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[:1.6.0_24]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
[:1.6.0_24]
at java.lang.Class.newInstance0(Class.java:355) [:1.6.0_24]
at java.lang.Class.newInstance(Class.java:308) [:1.6.0_24]
at
org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:343)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:340)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:33)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:73)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:162)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:207)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:569)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:559)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:554)
[weld-core-1.1.4.Final.jar:]
at
org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:74)
[solder-impl-3.1.0-SNAPSHOT.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.3.Final.jar:]
at
org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
[solder-impl-3.1.0-SNAPSHOT.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.3.Final.jar:]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151)
[jboss-as-web-7.1.0.Beta1.jar:]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.3.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]
Caused by: javax.servlet.ServletException
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.3.Final.jar:]
at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
[weld-core-1.1.4.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.3.Final.jar:]
at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:126)
[prettyfaces-jsf2-3.3.2.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.3.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.3.Final.jar:]
at
org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
[solder-impl-3.1.0-SNAPSHOT.jar:]
... 16 more
Caused by: java.lang.IllegalStateException
at
org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:436)
[jbossweb-7.0.3.Final.jar:]
at
javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:170)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:]
at
javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:170)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:]
at
org.jboss.weld.servlet.ConversationPropagationFilter$1.sendRedirect(ConversationPropagationFilter.java:79)
[weld-core-1.1.4.Final.jar:]
at
com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:576)
[jsf-impl-2.1.3-b02-jbossorg-2.jar:]
at
javax.faces.context.ExternalContextWrapper.redirect(ExternalContextWrapper.java:462)
[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]
at
org.jboss.seam.faces.environment.SeamExternalContext.redirect(SeamExternalContext.java:71)
[seam-faces-3.1.0-SNAPSHOT.jar:]
at
org.jboss.seam.faces.environment.SeamExternalContext$Proxy$_$$_WeldClientProxy.redirect(SeamExternalContext$Proxy$_$$_WeldClientProxy.java)
[seam-faces-3.1.0-SNAPSHOT.jar:]
at
com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:182)
[jsf-impl-2.1.3-b02-jbossorg-2.jar:]
at
com.ocpsoft.pretty.faces.application.PrettyNavigationHandler.handleNavigation(PrettyNavigationHandler.java:64)
[prettyfaces-jsf2-3.3.2.jar:]
at
org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:63)
[seam-faces-3.1.0-SNAPSHOT.jar:]
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
[jsf-impl-2.1.3-b02-jbossorg-2.jar:]
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]
at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]
at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]
at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
[jsf-impl-2.1.3-b02-jbossorg-2.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
[jsf-impl-2.1.3-b02-jbossorg-2.jar:]
at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
[jsf-impl-2.1.3-b02-jbossorg-2.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
[jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]
... 25 more
{noformat}
The problem seems to be that the LoginListener does the redirect to to the
"oldUrl" and then the JSF will try to do the same because of that navigation
rule, thus the IllegalStateException, as the response is already commited.
Removing that rule and changing the redirects and links from "login" to "home"
(thus letting the ViewConfiguration handle it by itself) makes the tests pass.
It appears similar to https://issues.jboss.org/browse/SEAMFACES-214 (closed as
a configuration issue)
> @Observes HttpServletResponse causes IllegalProductException
> ------------------------------------------------------------
>
> Key: SOLDER-309
> URL: https://issues.jboss.org/browse/SOLDER-309
> Project: Solder
> Issue Type: Bug
> Components: Servlet
> Affects Versions: 3.1.0.CR1
> Reporter: Ove Ranheim
> Assignee: Marek Schmidt
> Fix For: 3.1.0.Final
>
> Attachments: SolderHttpServletResponseTest.zip
>
>
> The ImplicitHttpServletObjectsProducer.getHttpServletResponse() produces a
> null instance when invoked from an @Observer.
> {noformat}
> public void observeHttpRequest(@Observes @Initialized HttpServletRequest
> request, HttpServletResponse response) {
> final String path = request.getServletPath();
>
> if (identity.isLoggedIn()) {
> // Redirect user to dashboard if landing page is requested
> if ("/index".equals(path) || "/index.jsf".equals(path)) {
> log.infof("Authorized request to: %s. Will be redirected to
> home!", path);
> try {
> response.sendRedirect(request.getContextPath() + "/home");
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> }
> }
> {noformat}
> Causes the exception:
> {noformat}
> org.jboss.weld.exceptions.IllegalProductException: WELD-000052 Cannot return
> null from a non-dependent producer method: [method] @Produces @Typed
> @RequestScoped protected
> org.jboss.solder.servlet.http.ImplicitHttpServletObjectsProducer.getHttpServletResponse()
>
> org.jboss.weld.bean.AbstractProducerBean.checkReturnValue(AbstractProducerBean.java:256)
>
> org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:362)
> org.jboss.weld.context.AbstractContext.get(AbstractContext.java:122)
>
> org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)
>
> org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124)
>
> org.jboss.weld.proxies.HttpServletResponse$1903192262$Proxy$_$$_WeldClientProxy.sendRedirect(HttpServletResponse$1903192262$Proxy$_$$_WeldClientProxy.java)
>
> com.musific.webapp.session.HttpRequestWatcher.observeHttpRequest(HttpRequestWatcher.java:80)
>
> com.musific.webapp.session.HttpRequestWatcher$Proxy$_$$_WeldClientProxy.observeHttpRequest(HttpRequestWatcher$Proxy$_$$_WeldClientProxy.java)
> sun.reflect.GeneratedMethodAccessor223.invoke(Unknown Source)
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> java.lang.reflect.Method.invoke(Method.java:597)
>
> org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
>
> org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
>
> org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
>
> org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
>
> org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
>
> org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
>
> org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
>
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)
>
> org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)
>
> org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)
>
> org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635)
>
> org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622)
>
> org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616)
>
> org.jboss.solder.servlet.event.AbstractServletEventBridge.fireEvent(AbstractServletEventBridge.java:45)
>
> org.jboss.solder.servlet.event.ServletEventBridgeListener.requestInitialized(ServletEventBridgeListener.java:76)
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
>
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
>
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)
> java.lang.Thread.run(Thread.java:680)
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues