<HTML dir=ltr><HEAD></HEAD>
<BODY>
<DIV dir=ltr id=idOWAReplyText1000>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>I am having trouble getting my rule package, which contains a reference to a custom accumulate function, to compile within Guvnor (5.2.0.Final on JBoss AS 5.1.0.GA). I have been using the same rules as DRL files without issue in Eclipse. I have tests which exercise the accumulate function and they are all passing. </FONT><FONT color=#000000 size=2 face=Arial>The error I get from Guvnor when I try to build the package is:</FONT></DIV></DIV>
<DIV dir=ltr>
<DIV dir=ltr id=idOWAReplyText19409>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Service method 'public abstract org.drools.guvnor.client.rpc.BuilderResult org.drools.guvnor.client.rpc.PackageService.buildPackage(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,boolean,java.lang.String,java.lang.String,boolean,java.lang.String) throws com.google.gwt.user.client.rpc.SerializationException' threw an unexpected exception: java.lang.ClassCastException: test.accumulate.BigIntegerSumAccumulateFunction cannot be cast to org.drools.runtime.rule.AccumulateFunction</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>I've isolated the problem into a reproducible test, or rather a set of steps:
<DIV dir=ltr><FONT size=2 face=Arial>1. Compile the attached BigIntegerSumAccumulateFunction.java into a jar and copy the jar to the JBoss server's lib folder.</FONT></DIV>
<DIV dir=ltr>2. Start up JBoss.</DIV></FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>3. Create a new package in Guvnor. I called mine "test".</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>4. Create a new fact that has a numeric property. Here's mine:</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial> declare Foo</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial> value : int</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial> end</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>5. Upload the attached drools.packagebuilder.conf to the Guvnor package.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>6. Create a new rule that references the custom accumulate function:</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial> when</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial> BigInteger() from accumulate( Foo( $v : value), bigIntegerSum( $v ) )</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial> then</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial> System.out.println("test");</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>7. Try to build the binary package in Guvnor. The error listed above occurs. Please see the end of this email for a full stack trace.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>It's telling me that my custom accumulate function can't be cast to org.drools.runtime.rule.AccumulateFunction, but I have a unit test (also attached) that proves that it can. Again, I have other tests which exercise rules that reference the accumulate function and they compile and work fine.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Any thoughts? Why does the Guvnor compiler work differently from when I build my knowledge base in code?</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Thanks in advance for any assistance.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Mike Melton</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>FULL STACK TRACE:</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>java.lang.ClassCastException: test.accumulate.BigIntegerSumAccumulateFunction cannot be cast to org.drools.runtime.rule.AccumulateFunction<BR> at org.drools.compiler.PackageBuilderConfiguration.loadAccumulateFunction(PackageBuilderConfiguration.java:491)<BR> at org.drools.compiler.PackageBuilderConfiguration.buildAccumulateFunctionsMap(PackageBuilderConfiguration.java:440)<BR> at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:177)<BR> at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:148)<BR> at org.drools.guvnor.server.builder.BRMSPackageBuilder.getPackageBuilderConfiguration(BRMSPackageBuilder.java:134)<BR> at org.drools.guvnor.server.builder.BRMSPackageBuilder.<init>(BRMSPackageBuilder.java:67)<BR> at org.drools.guvnor.server.builder.AssemblerBase.createBuilder(AssemblerBase.java:46)<BR> at org.drools.guvnor.server.builder.PackageAssembler.createBuilder(PackageAssembler.java:35)<BR> at org.drools.guvnor.server.builder.AssemblerBase.<init>(AssemblerBase.java:42)<BR> at org.drools.guvnor.server.builder.PackageAssemblerBase.<init>(PackageAssemblerBase.java:44)<BR> at org.drools.guvnor.server.builder.PackageAssembler.<init>(PackageAssembler.java:49)<BR> at org.drools.guvnor.server.RepositoryPackageOperations.buildPackage(RepositoryPackageOperations.java:522)<BR> at org.drools.guvnor.server.RepositoryPackageOperations.buildPackage(RepositoryPackageOperations.java:480)<BR> at org.drools.guvnor.server.RepositoryPackageService.buildPackage(RepositoryPackageService.java:299)<BR> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<BR> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<BR> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<BR> at java.lang.reflect.Method.invoke(Method.java:597)<BR> at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)<BR> at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)<BR> at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)<BR> at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)<BR> at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<BR> at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)<BR> at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<BR> at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)<BR> at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<BR> at org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:157)<BR> at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<BR> at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)<BR> at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)<BR> at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)<BR> at org.drools.guvnor.server.RepositoryPackageService_$$_javassist_7.buildPackage(RepositoryPackageService_$$_javassist_7.java)<BR> at org.drools.guvnor.server.RepositoryServiceServlet.buildPackage(RepositoryServiceServlet.java:282)<BR> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<BR> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<BR> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<BR> at java.lang.reflect.Method.invoke(Method.java:597)<BR> at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)<BR> at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)<BR> at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)<BR> at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)<BR> at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)<BR> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)<BR> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<BR> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<BR> at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)<BR> at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)<BR> at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)<BR> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<BR> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<BR> at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)<BR> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<BR> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<BR> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)<BR> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<BR> at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)<BR> at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)<BR> at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)<BR> at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)<BR> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)<BR> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<BR> at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)<BR> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<BR> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)<BR> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)<BR> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)<BR> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)<BR> at java.lang.Thread.run(Thread.java:662)</FONT></DIV></DIV></DIV></BODY></HTML>