<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">Greetings all,<br><br>I have the following Java code and rule. When executed I get an "Unexpected Global" exception (see below). What am I doing wrong?<br><br>....<br><span style="font-family: tahoma,new york,times,serif;">@In WorkingMemory wm</span><br style="font-family: tahoma,new york,times,serif;"><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">@Logger Log log;</span><br style="font-family: tahoma,new york,times,serif;"><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">public void calculate() {</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wm.setGlobal("logger",log);</span><br
 style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wm.insert(calcResult);</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wm.fireAllRules();</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">}</span><br><br><br><span style="font-family: tahoma,new york,times,serif;">rule "Calc"</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; when </span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $c : CalcResult();</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new
 york,times,serif;">&nbsp;&nbsp;&nbsp;&nbsp; then</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; log(drools.getRule().getName(),log);</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; // Do calculation</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">end</span><br style="font-family: tahoma,new york,times,serif;"><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">function void log(String msg, Log log) {</span><br style="font-family: tahoma,new york,times,serif;"><span style="font-family: tahoma,new york,times,serif;">&nbsp;&nbsp;&nbsp; log.debug(msg,new Object[]{});</span><br style="font-family: tahoma,new york,times,serif;"><span
 style="font-family: tahoma,new york,times,serif;">}</span><br><br>When the calculate method is executed I get the following exception:<br><br><pre><code>java.lang.RuntimeException: Unexpected global [logger]<br>        at org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:367)<br>        at org.ebsinc.ia.action.AnalysisAction.createData(AnalysisAction.java:93)<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:585)<br>        at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)<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.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)<br>        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<br>        at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)<br>        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<br>        at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)<br>        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<br>        at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)<br>        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)<br>        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)<br>        at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)<br>        at
 org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)<br>        at org.ebsinc.ia.action.AnalysisAction_$$_javassist_9.createData(AnalysisAction_$$_javassist_9.java)<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:585)<br>        at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)<br>        at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)<br>        at org.jboss.seam.Component.callComponentMethod(Component.java:2074)<br>        at org.jboss.seam.Component.callCreateMethod(Component.java:1997)<br>        at org.jboss.seam.Component.newInstance(Component.java:1968)<br>        at org.jboss.seam.Component.getInstance(Component.java:1865)<br>        at
 org.jboss.seam.Component.getInstance(Component.java:1832)<br>        at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1911)<br>        at org.jboss.seam.Component.getInstance(Component.java:1855)<br>        at org.jboss.seam.Component.getInstance(Component.java:1832)<br>        at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)<br>        at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)<br>        at org.jboss.seam.Namespace.get(Namespace.java:28)<br>        at org.jboss.seam.el.SeamELResolver.resolveInNamespace(SeamELResolver.java:197)<br>        at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:57)<br>        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)<br>        at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)<br>        at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)<br>        at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)<br>        at
 org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)<br>        at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)<br>        at javax.faces.component.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:102)<br>        at com.sun.facelets.component.UIRepeat.getValue(UIRepeat.java:143)<br>        at com.sun.facelets.component.UIRepeat.getDataModel(UIRepeat.java:121)<br>        at com.sun.facelets.component.UIRepeat.setIndex(UIRepeat.java:305)<br>        at com.sun.facelets.component.UIRepeat.process(UIRepeat.java:333)<br>        at com.sun.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:617)<br>        at org.jboss.seam.pdf.ui.ITextComponent.encode(ITextComponent.java:248)<br>        at org.jboss.seam.pdf.ui.ITextComponent.encodeChildren(ITextComponent.java:213)<br>        at org.jboss.seam.pdf.ui.ITextComponent.encode(ITextComponent.java:248)<br>        at org.jboss.seam.pdf.ui.ITextComponent.encodeChildren(ITextComponent.java:213)<br>        at
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)<br>        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)<br>        at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)<br>        at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)<br>        at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)<br>        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)<br>        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)<br>        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)<br>        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)<br>        at sun.reflect.GeneratedMethodAccessor621.invoke(Unknown Source)<br>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>        at java.lang.reflect.Method.invoke(Method.java:585)<br>        at
 org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)<br>        at java.security.AccessController.doPrivileged(Native Method)<br>        at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)<br>        at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)<br>        at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)<br>        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:283)<br>        at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:56)<br>        at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189)<br>        at java.security.AccessController.doPrivileged(Native Method)<br>        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)<br>        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)<br>        at
 org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)<br>        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)<br>        at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)<br>        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)<br>        at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)<br>        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)<br>        at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)<br>        at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)<br>        at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)<br>        at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)<br>        at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)<br>        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)<br>        at
 org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)<br>        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)<br>        at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)<br>        at sun.reflect.GeneratedMethodAccessor1504.invoke(Unknown Source)<br>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>        at java.lang.reflect.Method.invoke(Method.java:585)<br>        at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)<br>        at java.security.AccessController.doPrivileged(Native Method)<br>        at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)<br>        at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)<br>        at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:218)<br>        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)<br>        at
 org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:56)<br>        at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189)<br>        at java.security.AccessController.doPrivileged(Native Method)<br>        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)<br>        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)<br>        at sun.reflect.GeneratedMethodAccessor620.invoke(Unknown Source)<br>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>        at java.lang.reflect.Method.invoke(Method.java:585)<br>        at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)<br>        at java.security.AccessController.doPrivileged(Native Method)<br>        at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)<br>        at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)<br>        at
 org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:218)<br>        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)<br>        at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:56)<br>        at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189)<br>        at java.security.AccessController.doPrivileged(Native Method)<br>        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)<br>        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)<br>        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)<br>        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)<br>        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)<br>        at
 org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)<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:157)<br>        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br>        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)<br>        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)<br>        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)<br>        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)<br>        at java.lang.Thread.run(Thread.java:595)<br></code></pre><br></div></body></html>