[rules-users] Problem Itegrating Spring 3.2 with Drools 6.0.0
milen igrachev
igrachev at abv.bg
Wed Mar 26 10:57:50 EDT 2014
Hello,
I experience a problem autowiring my KieSession object into my Controller field in Spring.
I read the Spring integration configuration part of Drools documentation and edited my Spring
configuration as adviced. However on deploying I receive one and the same well know exception:
"org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.kie.api.runtime.KieSession] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.kie.api.cdi.KSession(name=, value=ksession-rules)}"
My application's web.xml defines my spring configuration entries as follows:
mvc-dispatcher
......
mvc-dispatcher
/
contextConfigLocation
/WEB-INF/beans.xml,
/WEB-INF/security.xml,
/WEB-INF/entityManager.xml
As guided by Drools documentation I entered the following Drools configuration in my spring configuration (I try to put the bean both in mvc-dispatcher-servlet.xml configuration and in beans.xml the result is the same).
I have this package
"com.my.sample.drools.rulespackage"
with
a simple and tested rule in it.
In my Controller class I am trying to autowire the KieSession bean to a field as follows:
@Controller
@RequestMapping(value = "/")
public class BaseController extends AbstractController {
private static final Logger log = Logger.getLogger(BaseController.class);
@Autowired
@KSession("ksession-rules")
KieSession mySession;
.............
}
I tryed with @Inject instead of spring's @Autowire, the result is the same.
I am using the following Drools dependencies with their versions:
drools-core - 6.0.0.FINAL; drools-compiler - 6.0.0.FINAL; kie-spring - 6.0.0.FINAL; (I am trying to keep it simple as my first integration try.)
The spring version that I am using is 3.2.4.RELEASE.
I debugged
KModuleBeanFactoryPostProcessor
and I can clearly see that an object tree with
KieModuleModelImpl,
KieBaseModelImpl,
KieSessionModelImpl,
with the corresponding details that I entered in the configuration above (packages, name, type, etc.) is created!. However it seems that a KieSession bean is not registered
spring's container.
What I do wrong? Can anyone please help?
Thanks in advance!
Best Regards,
Milen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140326/409d8fe4/attachment.html
More information about the rules-users
mailing list