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

Ove Ranheim (Reopened) (JIRA) jira-events at lists.jboss.org
Thu Dec 15 05:28:11 EST 2011


     [ https://issues.jboss.org/browse/SOLDER-309?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ove Ranheim reopened SOLDER-309:
--------------------------------



The exception still occurs:

{noformat}
11:21:53,782 INFO  [com.musific.webapp.session.HttpRequestWatcher] (http--127.0.0.1-8080-3) Authorized request to: /index.jsf. Will be redirected to home!
11:21:53,821 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host]] (http--127.0.0.1-8080-3) Exception sending request initialized lifecycle event to listener instance of class org.jboss.solder.servlet.event.ServletEventBridgeListener: java.lang.IllegalStateException: Attempted to inject an HttpServletResponse before it has been initialized.
	at org.jboss.solder.servlet.http.ImplicitHttpServletObjectsProducer.getHttpServletResponse(ImplicitHttpServletObjectsProducer.java:84) [solder-impl-3.1.0-20111214.051054-32.jar:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_29]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_29]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_29]
	at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_29]
	at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:169) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:149) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:361) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:122) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.proxies.HttpServletResponse$1903192262$Proxy$_$$_WeldClientProxy.sendRedirect(HttpServletResponse$1903192262$Proxy$_$$_WeldClientProxy.java) [weld-core-1.1.2.Final.jar:]
	at com.musific.webapp.session.HttpRequestWatcher.observeHttpRequest(HttpRequestWatcher.java:68) [musific-core-1.0-SNAPSHOT.jar:]
	at com.musific.webapp.session.HttpRequestWatcher$Proxy$_$$_WeldClientProxy.observeHttpRequest(HttpRequestWatcher$Proxy$_$$_WeldClientProxy.java) [musific-core-1.0-SNAPSHOT.jar:]
	at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source) [:1.6.0_29]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_29]
	at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_29]
	at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
	at org.jboss.solder.servlet.event.AbstractServletEventBridge.fireEvent(AbstractServletEventBridge.java:45) [solder-impl-3.1.0-20111214.051054-32.jar:]
	at org.jboss.solder.servlet.event.ServletEventBridgeListener.requestInitialized(ServletEventBridgeListener.java:76) [solder-impl-3.1.0-20111214.051054-32.jar:]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
	at java.lang.Thread.run(Thread.java:680) [:1.6.0_29]
{noformat}

Working on a test case so you can reproduce on your side.

It is failing on this line:

{noformat}
response.sendRedirect(request.getContextPath() + "/home");
{noformat}

                
> @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
>
>
> 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