java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

0beron
I am getting the following exception. It is weird that somehow "L" is out in front of "org.drools.rule.Package".
13:02:09,412 INFO  [stdout] (qtp810345742-66 - /endpoints/validation) java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
13:02:09,412 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:82)
13:02:09,413 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.URLScanner.readPackage(URLScanner.java:171)
13:02:09,414 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.URLScanner.getChangeSet(URLScanner.java:143)
13:02:09,415 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:119)
13:02:09,416 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:427)
13:02:09,416 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:379)
13:02:09,417 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.RuleAgent.configure(RuleAgent.java:364)
13:02:09,418 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.RuleAgent.init(RuleAgent.java:264)
13:02:09,419 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:204)
13:02:09,424 INFO  [stdout] (qtp810345742-66 - /endpoints/validation)   at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:164)
< rest stacktrace is removed >

My environment contains:
Guvnor 5.4.0.Final
All Drools 5.4..0.Final jars
Mvel2 (16th build)
Reply | Threaded
Open this post in threaded view
|

Re: java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

0beron
these are the jars I have:
drools-compiler-5.4.0.Final
drools-core-5.4.0.Final
drools-decisiontables-5.4.0.Final
droolsjbpm-ide-common-5.4.0.Final
drools-templates-5.4.0.Final
drools-verifier-5.4.0.Final
knowledge-api-5.4.0.Final
knowledge-internal-api-5.4.0.Final
mvel2-2.1.0.drools16
Reply | Threaded
Open this post in threaded view
|

Re: java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

Manasi
Hi,

I am also getting same error when trying to a call rule stored in guvnor.
Following error I am getting:

Exception in thread "main" java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
        at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:82)
        at org.drools.agent.URLScanner.readPackage(URLScanner.java:171)
        at org.drools.agent.URLScanner.getChangeSet(URLScanner.java:143)
        at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:119)
        at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:427)
        at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:379)
        at org.drools.agent.RuleAgent.configure(RuleAgent.java:364)
        at org.drools.agent.RuleAgent.init(RuleAgent.java:264)
        at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:204)
        at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:164)
        at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:273)

I am using Drools 5.4 version.

The error is coming when trying to get the RuleAgent:
RuleAgent agent = RuleAgent.newRuleAgent("/com/model/drools.properties");

drools.properties contains:

url = http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/FeltKnapRestriktionerKundeMedAnl/LATEST
name=guvnorAgent
enableBasicAuthentication=True
username=admin
password=admin

FeltKnapRestriktionerKundeMedAnl is the package name I have created in guvnor ,and I want to call one of the rule in this package.

Thanks,
Manasi
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

ge0ffrey
Administrator
This is a recently known bug in the old RuleAgent api,
use KnowledgeAgent instead.

Because packages can depend on packages, now a list of packages is
returned (instead of a single Package) and RuleAgent can't handle that.

Op 20-06-12 06:38, Manasi schreef:

> Hi,
>
> I am also getting same error when trying to a call rule stored in guvnor.
> Following error I am getting:
>
> Exception in thread "main" java.lang.ClassCastException:
> [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
> at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:82)
> at org.drools.agent.URLScanner.readPackage(URLScanner.java:171)
> at org.drools.agent.URLScanner.getChangeSet(URLScanner.java:143)
> at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:119)
> at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:427)
> at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:379)
> at org.drools.agent.RuleAgent.configure(RuleAgent.java:364)
> at org.drools.agent.RuleAgent.init(RuleAgent.java:264)
> at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:204)
> at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:164)
> at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:273)
>
> I am using Drools 5.4 version.
>
> The error is coming when trying to get the RuleAgent:
> RuleAgent agent = RuleAgent.newRuleAgent("/com/model/drools.properties");
>
> drools.properties contains:
>
> url =
> http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/FeltKnapRestriktionerKundeMedAnl/LATEST
> name=guvnorAgent
> enableBasicAuthentication=True
> username=admin
> password=admin
>
> FeltKnapRestriktionerKundeMedAnl is the package name I have created in
> guvnor ,and I want to call one of the rule in this package.
>
> Thanks,
> Manasi
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-Lorg-drools-rule-Package-cannot-be-cast-to-org-drools-rule-Package-tp4017821p4018085.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>

--
With kind regards,
Geoffrey De Smet


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

Manasi
Hi,

Thanks for your reply.
Now the mentioned error is not coming, but I am not able to fetch packages stored in guvnor.

I have following updated code:

KnowledgeAgent agent =  KnowledgeAgentFactory.newKnowledgeAgent("/com/model/drools.properties");
KnowledgeBase ruleBase = agent.getKnowledgeBase();
       
StatefulKnowledgeSession workingMemory = ruleBase.newStatefulKnowledgeSession();
StaffSO staff = new StaffSO();
staff.setDept("YO");
staff.setUser("User");
workingMemory.insert(staff);
System.out.println("number of facts " + workingMemory.getFactHandles().size());
workingMemory.fireAllRules(new RuleNameEndsWithAgendaFilter("UI_Kunde"));
System.out.println("after fire rules ,number of facts " + workingMemory.getFactHandles().size());
       
for(Iterator i=workingMemory.getObjects().iterator();i.hasNext();){
System.out.println(((StaffSO)i.next()).getEditableFields());
}


Thanks,
Manasi.
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

ganeshneelekani
In reply to this post by ge0ffrey
Hi Ge0ffrey,



I struggled with same exception above,I am using drools-guvnor 5.4 version and designer of 2.2 ,Can you tell me which version I need to use, which solve this issue.

and in which version this issue been, Which issue is a best one(both drools and designer )

I struggling with above issue from many days,if I redeploy then it will be solved for same webservice request... It is very strange


Regards
Ganesh N
Team Agile
India

Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

ganeshneelekani
 Hi George,

As you told in earlier post i am using knowledgeAgent but still causing the problem



Regards
Ganesh N
Team Agile
India



Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

ganeshneelekani
Hi All,



I fed up by this issue .. I used proper Interface and KnowledgeAgent
But same issue again and again..

At last I added try,catch block in my every rule which solved the issue.



Regards
Ganesh Neelekani
India

Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

Davide Sottara
Could you post the exact exception, as well as the code you are using to
set up the knowledgeagent?
Adding try/catch is quite likely to break your system, since your
knowledge base won't be loaded
correctly anyway.
Davide

On 07/22/2013 07:24 AM, Ganesh wrote:

> Hi All,
>
>
>
> I fed up by this issue .. I used proper Interface and KnowledgeAgent
> But same issue again and again..
>
> At last I added try,catch block in my every rule which solved the issue.
>
>
>
> Regards
> Ganesh Neelekani
> India
>
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-Lorg-drools-rule-Package-cannot-be-cast-to-org-drools-rule-Package-tp4017821p4025066.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

ganeshneelekani
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

Mark Proctor
Your's is a different issue.

You either have an incorrect class path, with mixed versions. Or your client and your server are using different versions. Or you didn't tell Guvnor to recompile all it's packages, when you changed jar versions.

Also your try/catch would result in no actual consequence happening - which would be pointless.

Mark
On 22 Jul 2013, at 11:17, Ganesh <[hidden email]> wrote:

> Hi David,
>
>
> Thanks for response,
> Exacts exception is "java.lang.ClassCastException:
> [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package "
>
>
> And I am not handing exception in any java code ..
> I am just handling it in rule part.
>
> ex.
>
> dialect "java"
> no-loop
> ruleflow-group "Apply Buy Discount"
>
> when
> /*removed*/
> then
>
> try{
>
>
> System.out.println("==================================");
> System.out.println("Apply Buy Discount");
> System.out.println($discountPercent);
> System.out.println($advAdditional);
> System.out.println("==================================");
> $lql.setEndUserUnitPrice(applyDiscount($lql.getEndUserUnitPrice(),$discountPercent+$advAdditional));
> $lql.setTotalCost(applyDiscount($lql.getTotalCost(),$discountPercent));
> // update($lql);
>
> }
> catch(Exception e)
> {
>
> System.out.println(e.toString());
>
> }
>
> Let me know if any issue.
>
>
> Regards
> Ganesh Neelekani
> India
>
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-Lorg-drools-rule-Package-cannot-be-cast-to-org-drools-rule-Package-tp4017821p4025073.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

Mark Proctor
That's assuming you have done as geoffrey instructed and use the correct classes. Lots of examples here in this unit test, as to which classes to use:
http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.drools/drools-compiler/5.5.0.Final/org/drools/agent/KnowledgeAgentTest.java/

So first make sure you are using the correct classes and apis, as per above. Then do as per below, checking your client and server class paths and rebuilding packages on the server.

Mark
On 22 Jul 2013, at 12:24, Mark Proctor <[hidden email]> wrote:

> Your's is a different issue.
>
> You either have an incorrect class path, with mixed versions. Or your client and your server are using different versions. Or you didn't tell Guvnor to recompile all it's packages, when you changed jar versions.
>
> Also your try/catch would result in no actual consequence happening - which would be pointless.
>
> Mark
> On 22 Jul 2013, at 11:17, Ganesh <[hidden email]> wrote:
>
>> Hi David,
>>
>>
>> Thanks for response,
>> Exacts exception is "java.lang.ClassCastException:
>> [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package "
>>
>>
>> And I am not handing exception in any java code ..
>> I am just handling it in rule part.
>>
>> ex.
>>
>> dialect "java"
>> no-loop
>> ruleflow-group "Apply Buy Discount"
>>
>> when
>> /*removed*/
>> then
>>
>> try{
>>
>>
>> System.out.println("==================================");
>> System.out.println("Apply Buy Discount");
>> System.out.println($discountPercent);
>> System.out.println($advAdditional);
>> System.out.println("==================================");
>> $lql.setEndUserUnitPrice(applyDiscount($lql.getEndUserUnitPrice(),$discountPercent+$advAdditional));
>> $lql.setTotalCost(applyDiscount($lql.getTotalCost(),$discountPercent));
>> // update($lql);
>>
>> }
>> catch(Exception e)
>> {
>>
>> System.out.println(e.toString());
>>
>> }
>>
>> Let me know if any issue.
>>
>>
>> Regards
>> Ganesh Neelekani
>> India
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-Lorg-drools-rule-Package-cannot-be-cast-to-org-drools-rule-Package-tp4017821p4025073.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/rules-users
>


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users