So, you have multiple CSVBeanAgent's (created from a text file somewhere). These are stored in a Map created in Java called "globals".

Where do you actually set the global in WorkingMemory: See http://docs.jboss.org/drools/release/5.4.0.Final/drools-expert-docs/html/ch04.html#d0e4482.

Furthermore, the Global will be of type Map not CSVBeanAgent, unless you want a Global for each CSVBeanAgent - but then how do you decide which you need.

Personally, I'd go back to inserting CSVBeanAgents as Facts and tackle the Java Heap Space issue... there are definitely things you are not telling us.

With kind regards,

Mike

On 26 July 2012 10:37, zeeshan <zeeshan.spring@gmail.com> wrote:
Hi Mike !

Earlier I tried it inserting as a Fact in using Statefull Session in my
RuleMain.java but was facing Java Heap Space error.......so I tried
Declaring as a Global in RuleMain.java like this----


HashMap<String, Object> globals = new HashMap<String, Object>();

StatefulSession statefulSession=new
RuleRunner().getStatefulSession(RULES_FILES8,null,null, globals, null);
...
....


//local block for Agent
                {
                        System.out.println("agent block>>>>>>>>>>>>>>>>");
                        String csvPath="C:/Users/new_user/Desktop/CIMS/ABAgent.csv";
                          try{
                        File f = new File(csvPath);
                        InputStream is = new FileInputStream( f );
                        Reader rdr = new InputStreamReader( is );
                        LineNumberReader lnrdr = new LineNumberReader( rdr );

                        String line;
                        while( (line = lnrdr.readLine()) != null ){
                            if( line.charAt(0) == '"' ) continue;
                            String[] tokens = line.split( ";" );
                            if( tokens.length != 3 ) continue;

                            int agentId = Integer.parseInt( tokens[0] );
                            int agentNo  = Integer.parseInt( tokens[1] );
                            String agentStatus = tokens[2];
                           /* System.out.println("1>>"+agentId);
                            System.out.println("2>>"+agentNo);
                            System.out.println("3>>"+agentStatus);*/

                            CSVBeanAgent csvAg = new CSVBeanAgent();
                            csvAg.setAgentId(agentId);
                            csvAg.setAgentNo(agentNo);
                            csvAg.setAgentStatus(agentStatus);

                         //statefulSession.insert(csvAg);

                            *globals.put(csvAg.getAgentId()+"", csvAg);*

                        }

                          }catch (Exception e) {
                                        System.out.println(e);
                                }
        }




System.out.println("fire all rule>>>>>>>>");


                statefulSession.fireAllRules();
                //statefulSession2.fireAllRules();



                log.debug("============ End Firing Rules =========");

                // Close the session
                 statefulSession.dispose();
}
}



--
View this message in context: http://drools.46999.n3.nabble.com/Using-global-variable-in-DRL-file-tp4018911p4018915.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users