Index: /trunk/zoo-project/zoo-kernel/service_internal_java.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 387)
+++ /trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 388)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2012 GeoLabs SARL
+ * Copyright (c) 2009-2013 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -52,5 +52,24 @@
     }
     sprintf(oclasspath,"-Djava.class.path=%s",classpath);
-  }
+  }else{
+    if(cclasspath!=NULL){
+      classpath=(char*) malloc((strlen(ntmp)+strlen(cclasspath)+3)*sizeof(char));
+      oclasspath=(char*) malloc((strlen(ntmp)+strlen(cclasspath)+21)*sizeof(char));
+#ifndef WIN32
+      sprintf(classpath,"%s/:%s",ntmp,cclasspath);
+#else
+      sprintf(classpath,"%s/;%s",ntmp,cclasspath);
+#endif
+    }
+    else{
+      classpath=(char*) malloc((strlen(ntmp)+2)*sizeof(char));
+      oclasspath=(char*) malloc((strlen(ntmp)+20)*sizeof(char));
+      sprintf(classpath,"%s/",ntmp);
+    }
+    sprintf(oclasspath,"-Djava.class.path=%s",classpath);
+
+  }
+  sprintf(oclasspath,"-Djava.class.path=%s",classpath);
+
 #ifdef DEBUG
   fprintf(stderr,"CLASSPATH=%s\n",classpath);
@@ -78,7 +97,10 @@
   int i;
 
-  options[0].optionString = strdup(oclasspath);
+  options[0].optionString = oclasspath;
 #ifdef WIN32
-  options[1].optionString = "-Xmx512M";
+  options[1].optionString = "-Xmx512m";
+  /*options[2].optionString = "-Xms128m";
+  options[3].optionString = "-XX:MaxPermSize=256m";
+  options[4].optionString = "-XX:MaxHeapFreeRatio=70";*/
 #endif
 
@@ -112,13 +134,5 @@
 #endif
   if( cls == NULL ) {
-    char pbt[10240];
-    sprintf(pbt,"can't find class %s\n",tmp->value);
-    fprintf(stderr,pbt);
-    fflush(stderr);
-    map* err=createMap("text",pbt);
-    addToMap(err,"code","NoApplicableCode");
-    printExceptionReportResponse(m,err);
-    freeMap(&err);
-    free(err);
+    displayStack(env,*main_conf);
 #ifdef JAVA7
     (*jvm).DestroyJavaVM();
@@ -182,34 +196,6 @@
 	dumpMaps(outputs);
 #endif
-      }else{	  
-	/**
-	 * Error handling displayig stack trace in ExceptionReport
-	 */
-	map *tmpm=getMapFromMaps(*main_conf,"main","tmpPath");
-	char tmps[1024];
-	sprintf(tmps,"%s/%d.ztmp",tmpm->value,getpid());
-	int old_stdout=dup(fileno(stdout));
-	FILE* new_stdout=fopen(tmps,"w+");
-	dup2(fileno(new_stdout),fileno(stdout));
-#ifdef JAVA7
-	(*env).ExceptionDescribe();
-#else
-	(*env)->ExceptionDescribe(env);
-#endif
-	fflush(stdout);
-	dup2(old_stdout,fileno(stdout));
-	fseek(new_stdout, 0, SEEK_END);
-	long flen=ftell(new_stdout);
-	rewind(new_stdout);
-	char *tmps1=(char*)malloc((flen+1)*sizeof(char));
-	fread(tmps1,flen,1,new_stdout);
-	fclose(new_stdout);
-	char *pbt=(char*)malloc((100+flen+1)*sizeof(char));
-	sprintf(pbt,"Unable to run your java process properly. Server returns : %s",tmps1);
-	map* err=createMap("text",pbt);
-	addToMap(err,"code","NoApplicableCode");
-	printExceptionReportResponse(m,err);
-	freeMap(&err);
-	free(err);
+      }else{
+	displayStack(env,*main_conf);
 #ifdef JAVA7
 	(*jvm).DestroyJavaVM();
@@ -221,10 +207,5 @@
     }
     else{
-      char tmpS[1024];
-      sprintf(tmpS, "Cannot find function %s \n", s->name);
-      map* err=createMap("text",tmpS);
-      printExceptionReportResponse(m,err);
-      freeMap(&err);
-      free(err);
+      displayStack(env,*main_conf);
 #ifdef JAVA7
       (*jvm).DestroyJavaVM();
@@ -234,17 +215,4 @@
       return -1;
     }
-  }else{
-    char tmpS[1024];
-    sprintf(tmpS, "Cannot find function %s \n", tmp->value);
-    map* err=createMap("text",tmpS);
-    printExceptionReportResponse(m,err);
-    freeMap(&err);
-    free(err);
-#ifdef JAVA7
-    (*jvm).DestroyJavaVM();
-#else
-    (*jvm)->DestroyJavaVM(jvm);
-#endif
-    return -1;
   }
 #ifdef JAVA7
@@ -254,4 +222,36 @@
 #endif
   return res;
+}
+
+/**
+ * Error handling: display stack trace in an ExceptionReport Document
+ */
+void displayStack(JNIEnv *env,maps* main_conf){
+  map *tmpm=getMapFromMaps(main_conf,"main","tmpPath");
+  char tmps[1024];
+  sprintf(tmps,"%s/%d.ztmp",tmpm->value,getpid());
+  FILE* new_stdout=fopen(tmps,"wb+");
+  fflush(stderr);
+  dup2(fileno(new_stdout),fileno(stderr));
+  fprintf(stderr,"Unable to run your java process properly: ");
+  fflush(stderr);
+#ifdef JAVA7
+  (*env).ExceptionDescribe();
+#else
+  (*env)->ExceptionDescribe(env);
+#endif
+  fflush(new_stdout);
+  fseek(new_stdout, 0, SEEK_END);
+  long flen=ftell(new_stdout);
+  fseek(new_stdout, 0, SEEK_SET);
+  char *tmps1=(char*)malloc((flen+1)*sizeof(char));
+  fread(tmps1,flen,1,new_stdout);
+  fclose(new_stdout);
+  tmps1[flen]=0;
+  map* err=createMap("text",tmps1);
+  addToMap(err,"code","InternalError");
+  printExceptionReportResponse(main_conf,err);
+  freeMap(&err);
+  free(err);
 }
 
@@ -313,5 +313,5 @@
 	    jclass scArrayListClass,scArrayList_class;
 	    jmethodID scArrayList_constructor;
-	    jobject scObject2,scObject3,scObject4;
+	    jobject scObject2;
 #ifdef JAVA7
 	    scArrayListClass = (*env).FindClass("java/util/ArrayList");
@@ -320,6 +320,4 @@
 	    jmethodID add_mid = 0;
 	    scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
-	    scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
-	    scObject4 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
 
 	    add_mid = (*env).GetMethodID(scArrayListClass,
@@ -331,6 +329,4 @@
 	    jmethodID add_mid = 0;
 	    scObject2 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
-	    scObject3 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
-	    scObject4 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
 
 	    add_mid = (*env)->GetMethodID(env,scArrayListClass,
Index: /trunk/zoo-project/zoo-kernel/service_internal_java.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_java.h	(revision 387)
+++ /trunk/zoo-project/zoo-kernel/service_internal_java.h	(revision 388)
@@ -39,4 +39,6 @@
   maps* mapsFromHashMap(JNIEnv*,jobject,jclass);
   
+  void displayStack(JNIEnv*,maps*);
+
   int zoo_java_support(maps**,map*,service*,maps**,maps**);
 
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 387)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 388)
@@ -892,5 +892,4 @@
     errorException(m, tmpMsg, "InvalidParameterValue");
     free(tmpMsg);
-    freeService(&s1);
     free(s1);
     freeMaps(&m);
Index: /trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py
===================================================================
--- /trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py	(revision 387)
+++ /trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py	(revision 388)
@@ -163,5 +163,5 @@
         i+=1
     outputResult(conf,outputs["Result"],rgeometries)
-    return zoo.SUCCEEDED
+    return zoo.SERVICE_SUCCEEDED
 
 def ConvexHullPy(conf,inputs,outputs):
@@ -177,5 +177,5 @@
         i+=1
     outputResult(conf,outputs["Result"],rgeometries)
-    return zoo.SUCCEEDED
+    return zoo.SERVICE_SUCCEEDED
 
 
@@ -201,7 +201,10 @@
         j=0
         while j < len(geometry2):
-            tres=geometry1[i].Union(geometry2[j])
-            if not(tres.IsEmpty()):
-                rgeometries+=[tres]
+            tmp=geometry1[j].Clone()
+            resg=geometry2[i].GetGeometryRef()
+            resg=resg.Union(geometry1[i].GetGeometryRef())
+            tmp.SetGeometryDirectly(resg)
+            if not(resg.IsEmpty()):
+                rgeometries+=[tmp]
             j+=1
         geometry1[i].Destroy()
