[英]Runtime Exception with Drools(java.lang.ClassCastException: org.drools.io.impl.ClassPathResource cannot be cast to org.drools.io.InternalResource)
I have all the required JARS. 我有所有必需的JARS。 Even though facing below issue:
即使遇到以下问题:
java.lang.ClassCastException: org.drools.io.impl.ClassPathResource cannot be cast to org.drools.io.InternalResource
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:487)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
attached images for the reference 附图供参考
It is too little information but I guess that you should create resource using the method ResourceFactory.newClassPathResource. 信息太少,但我想你应该使用ResourceFactory.newClassPathResource方法创建资源。
I had similar exception lately. 我最近有类似的例外。 I tried to use following code:
我试着使用以下代码:
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add((Resource) new ByteArrayResource(data.getBytes()), ResourceType.DRL);
I had to change the second line to this one: 我不得不将第二行改为这一行:
kbuilder.add(ResourceFactory.newByteArrayResource(data.getBytes()), ResourceType.DRL);
Try to make analogous changes in your code (note that you have classPathResource not byteArrayResource). 尝试在代码中进行类似的更改(请注意,您有classPathResource而不是byteArrayResource)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.