[seam-issues] [JBoss JIRA] (SOLDER-309) @Observes HttpServletResponse causes IllegalProductException

Marek Schmidt (Commented) (JIRA) jira-events at lists.jboss.org
Fri Dec 16 04:49:09 EST 2011


    [ https://issues.jboss.org/browse/SOLDER-309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12651522#comment-12651522 ] 

Marek Schmidt commented on SOLDER-309:
--------------------------------------

Re #1: That is what the IllegalStateException is telling you: "Attempted to inject an HttpServletResponse before it has been initialized." 

Re #2: "User may request a protected bookmarkable URL and consequently should be redirected to the initial request, after login."... that is exactly how it works. That is not the problem, the problem is that in addition to this redirect that happens automatically you have the "#{identity.login}" navigation rule, which tries to redirect again.
                
> @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: Shane Bryzak
>             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

        


More information about the seam-issues mailing list