Uploaded image for project: 'Solder'
  1. Solder
  2. SOLDER-309

@Observes HttpServletResponse causes IllegalProductException

    Details

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.0.CR1
    • Fix Version/s: 3.2.0.Final
    • Component/s: Servlet
    • Labels:
      None
    • Affects:
      Compatibility/Configuration

      Description

      The ImplicitHttpServletObjectsProducer.getHttpServletResponse() produces a null instance when invoked from an @Observer.

      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();
                  }
              }
          }
      }
      

      Causes the exception:

      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)
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  shane.bryzak Shane Bryzak
                  Reporter:
                  oranheim Ove Ranheim
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated: