0 Replies Latest reply on Nov 10, 2008 6:10 PM by Christian Lauer

    spring integration problem

    Christian Lauer Newbie

      We've encountered a problem while integrating spring into an existing Seam application. From time to time it happens that the method instantiateIoCBean() of class org.jboss.seam.ioc.spring.SpringComponent returns a component of a wrong type, which results from a call to the thread local object factory of this class.
      This makes the injection of the spring bean (@In) into another component fail.


      Here's the refering stack trace:

      Exception during request processing:
      Caused by javax.servlet.ServletException with message: "value of context variable is not an instance of the component bound to the context variable: serviceLocator. If you are using hot deploy, you may have attempted to hot deploy a session or application-scoped component definition while using an old instance in the session."
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
      weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
      weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
      weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
      weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      weblogic.security.service.SecurityManager.runAs(Unknown Source)
      weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
      weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
      weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
      weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
      weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
      Caused by java.lang.IllegalArgumentException with message: "value of context variable is not an instance of the component bound to the context variable: serviceLocator. If you are using hot deploy, you may have attempted to hot deploy a session or application-scoped component definition while using an old instance in the session."
      org.jboss.seam.Component.getInstance(Component.java:1960)
      org.jboss.seam.Component.getInstance(Component.java:1910)
      org.jboss.seam.Component.getInstance(Component.java:1904)
      org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2271)
      org.jboss.seam.Component.getValueToInject(Component.java:2223)
      org.jboss.seam.Component.injectAttributes(Component.java:1663)
      org.jboss.seam.Component.inject(Component.java:1481)
      org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
      org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
      org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
      org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
      lu.deka.b2c.session.UserAndPasswdAuthenticator_$$_javassist_8.getUsername(UserAndPasswdAuthenticator_$$_javassist_8.java)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
      com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
      org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
      org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
      org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      javax.faces.component.UIOutput.getValue(UIOutput.java:173)
      javax.faces.component.UIInput.validate(UIInput.java:873)
      javax.faces.component.UIInput.executeValidate(UIInput.java:1071)
      javax.faces.component.UIInput.processValidators(UIInput.java:663)
      javax.faces.component.UIForm.processValidators(UIForm.java:229)
      lu.deka.facelets.component.UICatch.processValidators(UICatch.java:172)
      javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1021)
      org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:439)
      org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
      org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:455)
      com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
      weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
      weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
      weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      weblogic.security.service.SecurityManager.runAs(Unknown Source)
      weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
      weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
      weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
      weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
      weblogic.work.ExecuteThread.run(ExecuteThread.java:173)


      I don't quite understand why this method instantiateIoCBean() uses the ObjectFactory. Is it an optimization? In my opinion this handling causes the problem, when the method getObject() in the anonymous inner class that is normally created during a call to  SeamComponentPostProcessor.postProcessAfterInitialization is called without SeamComponentPostProcessor.postProcessAfterInitialization being called first (in that request).



          @Override
          protected Object instantiateIoCBean() throws Exception
          {
              ObjectFactory objectFactory = getObjectFactory();
              if (objectFactory == null)
              {
                  return beanfactory.getBean(springBeanName);
              }
              setObjectFactory(null);
              return objectFactory.getObject();
          }


      We are developing our application on WebLogic Server 10.3. Could it be that the thread pool handling there is different from JBoss AS?


      Best regards,
      Christian