1 Reply Latest reply on Mar 26, 2012 9:45 PM by Hector Mendoza

    Seam and Drools Integration problems

    finalspy Newbie

      Hi,


      I'm getting a strange Exception while changing some configuration in my components.xml file in order to get Seam and Drools integration. Here's the whole story :


      I've been sucessfully using drools (5.0.2.BRMS 32440M) and Seam (2.2) configured in the components.xml file through a RuleAgent as follow :



      <drools:rule-agent name="myRuleAgent" url="http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/myPackage/LATEST" local-cache-dir="/tmp" poll="30" /> 
      <drools:managed-working-memory name="memory" auto-create="true" rule-base="#{myRuleAgent}" />




      Despite the documentation on http://docs.jboss.org/seam/snapshot/en-US/html/drools.html doesn't mention how to link the rule-agent with the managed-working-memory, I guessed that passing the rule-agent name in the rule-base property should do the trick and it did.


      Recently I changed the drools version for a more recent one (5.1.0.BRMS 36220), which came packaged with more security.
      Thus the drools packages URL are not accessible freely anymore and I have to provide a user/passwd to get them.


      1°) The rule-agent component does not expose user and password properties, but fortunately someone on the drools IRC chan suggested me to use the configurationFile attribute on the rul-agent tag as follow :



       <drools:rule-agent name="sampleAgent" configurationFile="/WEB-INF/brms-demo.properties" />



      and to provide a property file :



      newInstance=true
      url=http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/myPackage/LATEST
      localCacheDir=/tmp
      poll=30
      name=sampleAgent
      basicAuthentication=enabled
      username=admin
      password=admin



      So why not but :


      2°) As soon as I used the configurationFile attribute on the drools:rule-agent tag , I start getting an Exception :
      Exception during request processing:
      Caused by javax.el.ELException with message: java.lang.ClassCastException: org.jboss.seam.drools.RuleAgent cannot be cast to org.drools.RuleBase


      I also tried it on my old sample site using drools 5.0.1 and it does the same, so I guess this is not linked to the drools engine but to the seam component configuration.


      Here's the full stackTrace :



      Exception during request processing:
      Caused by javax.el.ELException with message: java.lang.ClassCastException: org.jboss.seam.drools.RuleAgent cannot be cast to org.drools.RuleBase




      org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:339)
      org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
      org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
      org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
      org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
      org.jboss.seam.navigation.Pages.callAction(Pages.java:703)
      org.jboss.seam.navigation.Pages.preRender(Pages.java:331)
      org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:561)
      org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:472)
      org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:148)
      org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
      com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      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:206)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      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:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
      java.lang.Thread.run(Thread.java:619)



      Caused by java.lang.ClassCastException with message: org.jboss.seam.drools.RuleAgent cannot be cast to org.drools.RuleBase



      org.jboss.seam.drools.ManagedWorkingMemory.getRuleBaseFromValueBinding(ManagedWorkingMemory.java:125)
      org.jboss.seam.drools.ManagedWorkingMemory.getStatefulSession(ManagedWorkingMemory.java:76)
      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)
      org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
      org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
      org.jboss.seam.Component.callComponentMethod(Component.java:2275)
      org.jboss.seam.Component.unwrap(Component.java:2301)
      org.jboss.seam.Component.getInstance(Component.java:2044)
      org.jboss.seam.Component.getInstance(Component.java:1986)
      org.jboss.seam.Component.getInstance(Component.java:1980)
      org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2375)
      org.jboss.seam.Component.getValueToInject(Component.java:2327)
      org.jboss.seam.Component.injectAttributes(Component.java:1739)
      org.jboss.seam.Component.inject(Component.java:1557)
      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:185)
      org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
      com.spb.sample.seamdrools.action.TestAction3_$$_javassist_seam_3.testAction(TestAction3_$$_javassist_seam_3.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)
      org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
      org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
      org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
      org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
      org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
      org.jboss.seam.navigation.Pages.callAction(Pages.java:703)
      org.jboss.seam.navigation.Pages.preRender(Pages.java:331)
      org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:561)
      org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:472)
      org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:148)
      org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
      com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      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:206)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      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:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
      java.lang.Thread.run(Thread.java:619)








      I investigate a little and found that the org.jboss.seam.drools.RuleAgent class has the following @Unwrap annotation :



      @Unwrap
         public org.drools.RuleBase getRuleBase()
         {
            return agent.getRuleBase();   
         }



      Shouldn't the ruleAgent return a ruleBase then ?



      If someone has already face this problem, knows a turnaround or is clever enough to diagnosticate an error on my configuration, or a real bug in Seam, please let me know.


      Regards,


      Yann

        • 1. Re: Seam and Drools Integration problems
          Hector Mendoza Newbie

          I use seam 2.2.0 and drools 5.0.1 and when add authentification in the configuration-file,in drools:rule-agent throw the same error, how do you solve this?

           

          I already solve this for my case, just changed the drools version from 5.0.1 to 5.1, because in the code I don't know why the authentication in the 5 version isn't supported, so only change the jars and works out.