In this case it's not a global, but a temporary variable in the rule consequence. Indeed, the problem is not only about generics, but impacts all the syntax elements that may have changed since Java 1.5, and make the rules Java compiler fails when running in ServiceMix.

As I said before, the workaround is quite easy, changing all the Java code to be compliant with the compilation level. The question is just about a confirmation of the Felix's class loader (org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) in the compiler's behavior, and a better solution to be able to write RHS with a 'modern' syntax.

Thanks.


2014-05-20 16:56 GMT+02:00 Charles Moulliard [via Drools] <[hidden email]>:
Is it a list that you would like to use as global param ? If this is the case, maybe change your rule & code like that 

        //GET A KSESSION
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        //now create some test data
        ksession.insert( new Cheese( "stilton",
                               42 ) );
        ksession.insert( new Person( "michael",
                               "stilton",
                               42 ) );
        final List<String> list = new ArrayList<String>();
        ksession.setGlobal( "list",
                      list );

        ksession.fireAllRules();

        System.out.println(list);

        ksession.dispose();

Rule 

template header
age
type
log

package org.drools.examples.templates;

global java.util.List list;

template "cheesefans"

rule "Cheese fans_@{row.rowNumber}"
    when
        Person(age == @{age})
        Cheese(type == "@{type}")
    then
        list.add("@{log}");
end
end template



On Tue, May 20, 2014 at 4:40 PM, Ephemeris Lappis <[hidden email]> wrote:
Hello.

I have no such kind test with Pax Exam. Should you send me a simple maven project example using a Karaf container ?

Back to the problem, a very simple rule with something like that in the RHS always fails when deployed in a bundle whose class loader is the felix one :

List<String> l = new ArrayList<>();
that must be fixed with :
List<String> l = new ArrayList<String>();

or

int n = 1_000;
that fails instead of :
int n = 1000;

FYI, I use ServiceMix 4.5.3.

Thanks again.
Regards.



2014-05-20 15:41 GMT+02:00 Charles Moulliard <[hidden email]>:

A test case will be required to reproduce your problem. Do you have a pax-exam test ?


On Tue, May 20, 2014 at 1:03 PM, Ephemeris Lappis <[hidden email]> wrote:
Hello.

Here is the first lines of the error message :


14:58:57,457 | ERROR | tp1946301910-151 | AbstractKieModule                |
239 - org.drools.compiler - 6.1.0.20140429-1643 | Unable to build
KieBaseModel:MyKBase
Rule Compilation error : [Rule name='Main Rule']
        my/tests/drools/osgi/expert/rules/Rule_Main_Rule1409557233.java (8:649) :
Incorrect number of arguments for type HashMap<K,V>; it cannot be
parameterized with arguments <?>
        my/tests/drools/osgi/expert/rules/Rule_Main_Rule1409557233.java (8:666) :
Syntax error on token "<", ? expected after this token


I have found the explanation and a workaround : put it all with a strict
"1.5" syntax in the RHS ! In this current case, do not use <> to infere the
generic type, but use the expected declared types instead.

After a rather touchy remote debug of the ServiceMix runtime to inspect what
is different from the Junit tests, I think that the problem comes from the
classloader that is associated with the Kie container. Before compilation
the language source and target level is  set with version 1.7 as expected,
but in the nameEnvironment that is passed to the JavaCompiler (indeed, ecj
compiler), the droolsClassloader is of type
"org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5". As its name
seems to incidate, I'm afraid that the Karaf/Felix loader is originally
built in 1.5.

I've read some posts about the eclipse compiler that perhaps takes into
account the caller compliance to adapt its compilation language level.

Class loaders seem to be a serious problem when using Drools in complex
environment such as a OSGi one...

Please, could you confirm my analysis, and, if you have one, propose any
better solution ? I don't know, for example, if it's possible to influence
Karaf to use different levels of bundle class loaders...

Thanks a lot.

Regards.



--
View this message in context: http://drools.46999.n3.nabble.com/Rules-compilation-error-with-OSGi-integration-6-1-0-Beta3-tp4029601p4029622.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



--
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io


_______________________________________________
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



--
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io


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


If you reply to this email, your message will be added to the discussion below:
http://drools.46999.n3.nabble.com/Rules-compilation-error-with-OSGi-integration-6-1-0-Beta3-tp4029601p4029628.html
To unsubscribe from Rules compilation error with OSGi integration (6.1.0.Beta3), click here.
NAML



View this message in context: Re: [rules-users] Rules compilation error with OSGi integration (6.1.0.Beta3)
Sent from the Drools: User forum mailing list archive at Nabble.com.