Index: tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/utils/GSERunner.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/utils/GSERunner.java	(revision 296)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/utils/GSERunner.java	(revision 297)
@@ -2,8 +2,17 @@
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 
+import org.eclipse.core.internal.runtime.InternalPlatform;
+import org.eclipse.core.runtime.FileLocator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.wiring.BundleWiring;
+import org.txm.rcpapplication.TXMClassLoader;
+import org.txm.utils.logger.Log;
+
 import groovy.lang.Binding;
 import groovy.util.GroovyScriptEngine;
 import groovy.util.ResourceException;
@@ -69,4 +78,92 @@
 		arrangedMap.put("args", new HashMap<String, Object>());
 		return run(clazz.getCanonicalName().replace(".", "/")+".groovy", new Binding(arrangedMap));
 	}
+	
+	/**
+	 * Creates a new GSERunner and adds to it the class loaders of all installed bundles of the platform. 
+	 * @return a new GSERunner
+	 */
+	public static GSERunner createGSERunner(String[] urls)	{
+		
+		 GSERunner gse = null;
+		
+//		ArrayList<String> roots2 = new ArrayList<String>(200);
+//		roots2.add(roots[0]);
+//		roots2.add(roots[1]);
+//		roots2.add(roots[2]);
+//		
+//		
+//		HashMap<String, Bundle> bundleWithActivators = new HashMap<String, Bundle>();
+		HashSet<ClassLoader> loaders = new HashSet<ClassLoader>();
+		BundleContext bundleContext = InternalPlatform.getDefault().getBundleContext();
+//		String[] bundlesRoots = new String[bundleContext.getBundles().length];
+		
+		for (Bundle b : bundleContext.getBundles()) {
+			
+			//FIXME: debug
+//			System.out.println("ExecuteGroovyScript.executeScript(): bundle symbolic name: " + b.getSymbolicName());
+//			System.out.println("ExecuteGroovyScript.executeScript(): bundle id: " + b.getBundleId());
+//			System.out.println("ExecuteGroovyScript.executeScript(): bundle location: " + b.getLocation());
+//			try {
+//				System.out.println("ExecuteGroovyScript.executeScript(): bundle file location: " + FileLocator.getBundleFile(b).getAbsolutePath());
+//			}
+//			catch(IOException e) {
+//				// TODO Auto-generated catch block
+//				e.printStackTrace();
+//			}
+
+			BundleWiring bundleWiring = b.adapt(BundleWiring.class);
+			loaders.add(bundleWiring.getClassLoader());
+			
+			//FIXME: debug
+			System.out.println("GSERunner.createGSERunner(): class loader added: " + bundleWiring.getClassLoader());
+//			try {
+//				roots2.add(FileLocator.getBundleFile(b).getAbsolutePath());
+//			}
+//			catch(IOException e) {
+//				// TODO Auto-generated catch block
+//				e.printStackTrace();
+//			}
+			
+			
+			
+//			String acName = b.getHeaders().get("Bundle-Activator");
+//			if (acName != null) {
+//				if (!bundleWithActivators.containsKey(b.getSymbolicName())) {
+//					bundleWithActivators.put(b.getSymbolicName(),b);
+//				} else {
+//					Bundle b2 = bundleWithActivators.get(b.getSymbolicName());
+//					if (b2.getVersion().compareTo(b.getVersion()) < 0) {
+//						bundleWithActivators.put(b.getSymbolicName(),b);
+//					}
+//				}
+//			}
+		}
+		
+//		for (Bundle b : bundleWithActivators.values()) {
+//			try {
+//				String acName = b.getHeaders().get("Bundle-Activator");
+//				Class<?> ac = b.loadClass(acName);
+//				loaders.add(ac.getClassLoader());
+//				//FIXME: debug
+//				System.out.println("ExecuteGroovyScript.executeScript(): loaders: " + ac.getClassLoader());
+//			} catch (ClassNotFoundException e) {
+//				e.printStackTrace();
+//			}
+//		}
+		Log.info("Initializing TXMClassLoader with " + loaders.size() + " bundles.");
+		TXMClassLoader scl = new TXMClassLoader(loaders);
+
+		try {
+			gse = new GSERunner(urls, scl);
+//			gse = new GSERunner(roots, ExecuteGroovyScript.class.getClassLoader());
+			//String[] roots3 = roots2.toArray(new String[roots2.size()]);
+			//gse = new GSERunner(roots3, ExecuteGroovyScript.class.getClassLoader());
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		
+		return gse;
+	}
+	
 }
\ No newline at end of file
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/commands/ExecuteGroovyScript.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/commands/ExecuteGroovyScript.java	(revision 296)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/commands/ExecuteGroovyScript.java	(revision 297)
@@ -220,82 +220,9 @@
 					scriptRootDir+"/import/", //$NON-NLS-1$
 			}; 
 
-//			ArrayList<String> roots2 = new ArrayList<String>(200);
-//			roots2.add(roots[0]);
-//			roots2.add(roots[1]);
-//			roots2.add(roots[2]);
-//			
-//			
-//			HashMap<String, Bundle> bundleWithActivators = new HashMap<String, Bundle>();
-			HashSet<ClassLoader> loaders = new HashSet<ClassLoader>();
-			BundleContext bundleContext = InternalPlatform.getDefault().getBundleContext();
-//			String[] bundlesRoots = new String[bundleContext.getBundles().length];
-			
-			for (Bundle b : bundleContext.getBundles()) {
-				
-				//FIXME: debug
-				System.out.println("ExecuteGroovyScript.executeScript(): bundle symbolic name: " + b.getSymbolicName());
-				System.out.println("ExecuteGroovyScript.executeScript(): bundle id: " + b.getBundleId());
-				System.out.println("ExecuteGroovyScript.executeScript(): bundle location: " + b.getLocation());
-				try {
-					System.out.println("ExecuteGroovyScript.executeScript(): bundle file location: " + FileLocator.getBundleFile(b).getAbsolutePath());
-				}
-				catch(IOException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
 
-				BundleWiring bundleWiring = b.adapt(BundleWiring.class);
-				loaders.add(bundleWiring.getClassLoader());
-				
-				//FIXME: debug
-				System.out.println("ExecuteGroovyScript.executeScript(): loaders: " + bundleWiring.getClassLoader());
-//				try {
-//					roots2.add(FileLocator.getBundleFile(b).getAbsolutePath());
-//				}
-//				catch(IOException e) {
-//					// TODO Auto-generated catch block
-//					e.printStackTrace();
-//				}
-				
-				
-				
-//				String acName = b.getHeaders().get("Bundle-Activator");
-//				if (acName != null) {
-//					if (!bundleWithActivators.containsKey(b.getSymbolicName())) {
-//						bundleWithActivators.put(b.getSymbolicName(),b);
-//					} else {
-//						Bundle b2 = bundleWithActivators.get(b.getSymbolicName());
-//						if (b2.getVersion().compareTo(b.getVersion()) < 0) {
-//							bundleWithActivators.put(b.getSymbolicName(),b);
-//						}
-//					}
-//				}
-			}
-			
-//			for (Bundle b : bundleWithActivators.values()) {
-//				try {
-//					String acName = b.getHeaders().get("Bundle-Activator");
-//					Class<?> ac = b.loadClass(acName);
-//					loaders.add(ac.getClassLoader());
-//					//FIXME: debug
-//					System.out.println("ExecuteGroovyScript.executeScript(): loaders: " + ac.getClassLoader());
-//				} catch (ClassNotFoundException e) {
-//					e.printStackTrace();
-//				}
-//			}
-			Log.info("Initialized TXMClassLoader with "+loaders.size()+ " bundles.");
-			TXMClassLoader scl = new TXMClassLoader(loaders);
+			gse = GSERunner.createGSERunner(roots);
 
-			try {
-				gse = new GSERunner(roots, scl);
-//				gse = new GSERunner(roots, ExecuteGroovyScript.class.getClassLoader());
-				//String[] roots3 = roots2.toArray(new String[roots2.size()]);
-				//gse = new GSERunner(roots3, ExecuteGroovyScript.class.getClassLoader());
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-
 			File jardir = new File(scriptRootDir,"lib"); //$NON-NLS-1$
 			if (jardir.exists() && jardir.isDirectory()) {
 				for (File f: jardir.listFiles(new FilenameFilter() {
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/commands/ExecuteImportScript.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/commands/ExecuteImportScript.java	(revision 296)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcpapplication/commands/ExecuteImportScript.java	(revision 297)
@@ -33,14 +33,11 @@
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.logging.Level;
 
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.internal.runtime.InternalPlatform;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
@@ -53,8 +50,6 @@
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.txm.Toolbox;
 import org.txm.importer.xtz.ImportKeys;
 import org.txm.objects.Base;
@@ -62,10 +57,10 @@
 import org.txm.rcpapplication.Application;
 import org.txm.rcpapplication.Messages;
 import org.txm.rcpapplication.StatusLine;
-import org.txm.rcpapplication.TXMClassLoader;
 import org.txm.rcpapplication.commands.workspace.LoadBinaryCorpus;
 import org.txm.rcpapplication.preferences.ScriptPreferenceInitializer;
 import org.txm.rcpapplication.preferences.ScriptPreferencePage;
+import org.txm.rcpapplication.utils.GSERunner;
 import org.txm.rcpapplication.utils.JobHandler;
 import org.txm.rcpapplication.views.corpora.CorporaView;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
@@ -165,56 +160,17 @@
 				ScriptPreferencePage.SCRIPT_ROOT_DIR,
 				ScriptPreferenceInitializer.SCRIPT_ROOT_DIR_DEFAULT, null);
 		
-		//FIXME: old version
 //		ClassLoader parent = ExecuteImportScript.class.getClassLoader();
 //		final GroovyClassLoader loader = new GroovyClassLoader(parent);
-//		final String[] roots = new String[] { 
-//				script.getParent(),
-//				scriptRootDir };
 		
-		params.load(); // reload params
-
-		//FIXME: new version
+		
 		final String[] roots = new String[] { 
-				scriptRootDir+"/user/", //$NON-NLS-1$
-				scriptRootDir+"/macro/", //$NON-NLS-1$
-				scriptRootDir+"/import/", //$NON-NLS-1$
-		}; 
-		System.err.println("ExecuteImportScript.executeScript(); retrieving bundles class loaders.");
-		HashMap<String, Bundle> bundleWithActivators = new HashMap<String, Bundle>();
-		HashSet<ClassLoader> loaders = new HashSet<ClassLoader>();
-		BundleContext bundleContext = InternalPlatform.getDefault().getBundleContext();
-		for (Bundle b : bundleContext.getBundles()) {
-			String acName = b.getHeaders().get("Bundle-Activator");
-			if (acName != null) {
-				if (!bundleWithActivators.containsKey(b.getSymbolicName())) {
-					bundleWithActivators.put(b.getSymbolicName(),b);
-				} else {
-					Bundle b2 = bundleWithActivators.get(b.getSymbolicName());
-					if (b2.getVersion().compareTo(b.getVersion()) < 0) {
-						bundleWithActivators.put(b.getSymbolicName(),b);
-					}
-				}
-			}
-		}
+				script.getParent(),
+				scriptRootDir };
 		
-		for (Bundle b : bundleWithActivators.values()) {
-			try {
-				String acName = b.getHeaders().get("Bundle-Activator");
-				Class<?> ac = b.loadClass(acName);
-				loaders.add(ac.getClassLoader());
-				//FIXME: debug
-				System.out.println("ExecuteImportScript.executeScript(): " + ac.getClassLoader());
-			} catch (ClassNotFoundException e) {
-				e.printStackTrace();
-			}
-		}
-		Log.info("Initialized TXMClassLoader with "+loaders.size()+ " bundles.");
-		final TXMClassLoader loader = new TXMClassLoader(loaders);
 		
-		// FIXME: end of new version
-		
-		
+		params.load(); // reload params
+
 		// the binary directory which is going to be created
 
 		final File basedir = new File(corporadir, params.name);
@@ -258,8 +214,11 @@
 					//org.txm.Toolbox.shutdownSearchEngine();
 					monitor.worked(5);
 
-					//if (ExecuteImportScript.gse == null)
-						ExecuteImportScript.gse = new GroovyScriptEngine(roots, loader);
+					if (ExecuteImportScript.gse == null)	{
+						//ExecuteImportScript.gse = new GroovyScriptEngine(roots, loader);
+						ExecuteImportScript.gse = GSERunner.createGSERunner(roots);
+						
+					}
 
 					Binding binding = new Binding();
 					binding.setProperty("paramsBinding", p); //$NON-NLS-1$
