开发者社区> 问答> 正文

Drools6.3集成Spring在web项目,诸多问题,求高手。?报错

Dear All

最近在做Drools6.3集成Spring Web应用,简直是噩梦啊。

1. 创建了maven web工程,将各种依赖包导入;

2. 在main/resources下创建,drools-bean.xml,并导入到applicationContext.xml中,drools-bean.xml文件内容如下:


<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task" xmlns:kie="http://drools.org/schema/kie-spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://drools.org/schema/kie-spring https://raw.githubusercontent.com/droolsjbpm/droolsjbpm-integration/master/kie-spring/src/main/resources/org/kie/spring/kie-spring-6.0.0.xsd" default-lazy-init="true"> <kie:kmodule id="test-kmodule"> <kie:kbase name="test_kbase" packages="rules.test"> <kie:ksession name="ksession1" scope="prototype"/> </kie:kbase> </kie:kmodule> <bean id="kiePostProcessor" class="org.kie.spring.KModuleBeanFactoryPostProcessor" /> </beans>


tomcat一启动就报错,错误如下:

302  [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader  - Context initialization failed
java.lang.RuntimeException: Unable to get all ZipFile entries: \Users\duanjunwei\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\drools-scm\WEB-INF\classes
at org.drools.core.util.IoUtils.indexZipFile(IoUtils.java:151)
at org.drools.compiler.kie.builder.impl.ZipKieModule.<init>(ZipKieModule.java:35)
at org.drools.compiler.kie.builder.impl.ClasspathKieProject.createInternalKieModule(ClasspathKieProject.java:202)
at org.kie.spring.KModuleBeanFactoryPostProcessor.createKieModule(KModuleBeanFactoryPostProcessor.java:189)
at org.kie.spring.KModuleBeanFactoryPostProcessor.addKieModuleToRepo(KModuleBeanFactoryPostProcessor.java:162)
at org.kie.spring.KModuleBeanFactoryPostProcessor.postProcessBeanFactory(KModuleBeanFactoryPostProcessor.java:121)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:640)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:405)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.FileNotFoundException: \Users\duanjunwei\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\drools-scm\WEB-INF\classes (系统找不到指定的路径。)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:214)
at java.util.zip.ZipFile.<init>(ZipFile.java:144)
at java.util.zip.ZipFile.<init>(ZipFile.java:158)
at org.drools.core.util.IoUtils.indexZipFile(IoUtils.java:139)
... 21 more

我的疑问:按照Drools6.3的官方文档,在Spring中定义<kmodule>是可以替换掉kmodule.xml文件的,感觉这个初始化是去zip文件,或者说是jar文件中找drl规则去了,我放到classes根目录下的规则文件视而不见,请问我是啥配置不对么?


展开
收起
爱吃鱼的程序员 2020-06-09 15:52:53 721 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    找到原因了,我的Eclipse工程将web应用发布到了C盘:C:\Users\duanjunwei\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps,但Tomcat是在D盘,可能Drools不认C盘,修改下Eclipse下的tomcat发布路径配置ServerLocations,选择第二项:TomcatInstallation,然后重新发布就可以了。这个问题折腾了好几天,Drools坑还是很多的。

    2020-06-09 15:53:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里邮箱—安全高效集成 立即下载
集成智能接入网关APP:优化企业级移动办公网络 立即下载
云效助力企业集成安全到DevOps中 立即下载