Changeset 388
- Timestamp:
- Jan 11, 2013, 3:43:44 PM (12 years ago)
- Location:
- trunk/zoo-project
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal_java.c
r364 r388 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 2GeoLabs SARL4 * Copyright (c) 2009-2013 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 52 52 } 53 53 sprintf(oclasspath,"-Djava.class.path=%s",classpath); 54 } 54 }else{ 55 if(cclasspath!=NULL){ 56 classpath=(char*) malloc((strlen(ntmp)+strlen(cclasspath)+3)*sizeof(char)); 57 oclasspath=(char*) malloc((strlen(ntmp)+strlen(cclasspath)+21)*sizeof(char)); 58 #ifndef WIN32 59 sprintf(classpath,"%s/:%s",ntmp,cclasspath); 60 #else 61 sprintf(classpath,"%s/;%s",ntmp,cclasspath); 62 #endif 63 } 64 else{ 65 classpath=(char*) malloc((strlen(ntmp)+2)*sizeof(char)); 66 oclasspath=(char*) malloc((strlen(ntmp)+20)*sizeof(char)); 67 sprintf(classpath,"%s/",ntmp); 68 } 69 sprintf(oclasspath,"-Djava.class.path=%s",classpath); 70 71 } 72 sprintf(oclasspath,"-Djava.class.path=%s",classpath); 73 55 74 #ifdef DEBUG 56 75 fprintf(stderr,"CLASSPATH=%s\n",classpath); … … 78 97 int i; 79 98 80 options[0].optionString = strdup(oclasspath);99 options[0].optionString = oclasspath; 81 100 #ifdef WIN32 82 options[1].optionString = "-Xmx512M"; 101 options[1].optionString = "-Xmx512m"; 102 /*options[2].optionString = "-Xms128m"; 103 options[3].optionString = "-XX:MaxPermSize=256m"; 104 options[4].optionString = "-XX:MaxHeapFreeRatio=70";*/ 83 105 #endif 84 106 … … 112 134 #endif 113 135 if( cls == NULL ) { 114 char pbt[10240]; 115 sprintf(pbt,"can't find class %s\n",tmp->value); 116 fprintf(stderr,pbt); 117 fflush(stderr); 118 map* err=createMap("text",pbt); 119 addToMap(err,"code","NoApplicableCode"); 120 printExceptionReportResponse(m,err); 121 freeMap(&err); 122 free(err); 136 displayStack(env,*main_conf); 123 137 #ifdef JAVA7 124 138 (*jvm).DestroyJavaVM(); … … 182 196 dumpMaps(outputs); 183 197 #endif 184 }else{ 185 /** 186 * Error handling displayig stack trace in ExceptionReport 187 */ 188 map *tmpm=getMapFromMaps(*main_conf,"main","tmpPath"); 189 char tmps[1024]; 190 sprintf(tmps,"%s/%d.ztmp",tmpm->value,getpid()); 191 int old_stdout=dup(fileno(stdout)); 192 FILE* new_stdout=fopen(tmps,"w+"); 193 dup2(fileno(new_stdout),fileno(stdout)); 194 #ifdef JAVA7 195 (*env).ExceptionDescribe(); 196 #else 197 (*env)->ExceptionDescribe(env); 198 #endif 199 fflush(stdout); 200 dup2(old_stdout,fileno(stdout)); 201 fseek(new_stdout, 0, SEEK_END); 202 long flen=ftell(new_stdout); 203 rewind(new_stdout); 204 char *tmps1=(char*)malloc((flen+1)*sizeof(char)); 205 fread(tmps1,flen,1,new_stdout); 206 fclose(new_stdout); 207 char *pbt=(char*)malloc((100+flen+1)*sizeof(char)); 208 sprintf(pbt,"Unable to run your java process properly. Server returns : %s",tmps1); 209 map* err=createMap("text",pbt); 210 addToMap(err,"code","NoApplicableCode"); 211 printExceptionReportResponse(m,err); 212 freeMap(&err); 213 free(err); 198 }else{ 199 displayStack(env,*main_conf); 214 200 #ifdef JAVA7 215 201 (*jvm).DestroyJavaVM(); … … 221 207 } 222 208 else{ 223 char tmpS[1024]; 224 sprintf(tmpS, "Cannot find function %s \n", s->name); 225 map* err=createMap("text",tmpS); 226 printExceptionReportResponse(m,err); 227 freeMap(&err); 228 free(err); 209 displayStack(env,*main_conf); 229 210 #ifdef JAVA7 230 211 (*jvm).DestroyJavaVM(); … … 234 215 return -1; 235 216 } 236 }else{237 char tmpS[1024];238 sprintf(tmpS, "Cannot find function %s \n", tmp->value);239 map* err=createMap("text",tmpS);240 printExceptionReportResponse(m,err);241 freeMap(&err);242 free(err);243 #ifdef JAVA7244 (*jvm).DestroyJavaVM();245 #else246 (*jvm)->DestroyJavaVM(jvm);247 #endif248 return -1;249 217 } 250 218 #ifdef JAVA7 … … 254 222 #endif 255 223 return res; 224 } 225 226 /** 227 * Error handling: display stack trace in an ExceptionReport Document 228 */ 229 void displayStack(JNIEnv *env,maps* main_conf){ 230 map *tmpm=getMapFromMaps(main_conf,"main","tmpPath"); 231 char tmps[1024]; 232 sprintf(tmps,"%s/%d.ztmp",tmpm->value,getpid()); 233 FILE* new_stdout=fopen(tmps,"wb+"); 234 fflush(stderr); 235 dup2(fileno(new_stdout),fileno(stderr)); 236 fprintf(stderr,"Unable to run your java process properly: "); 237 fflush(stderr); 238 #ifdef JAVA7 239 (*env).ExceptionDescribe(); 240 #else 241 (*env)->ExceptionDescribe(env); 242 #endif 243 fflush(new_stdout); 244 fseek(new_stdout, 0, SEEK_END); 245 long flen=ftell(new_stdout); 246 fseek(new_stdout, 0, SEEK_SET); 247 char *tmps1=(char*)malloc((flen+1)*sizeof(char)); 248 fread(tmps1,flen,1,new_stdout); 249 fclose(new_stdout); 250 tmps1[flen]=0; 251 map* err=createMap("text",tmps1); 252 addToMap(err,"code","InternalError"); 253 printExceptionReportResponse(main_conf,err); 254 freeMap(&err); 255 free(err); 256 256 } 257 257 … … 313 313 jclass scArrayListClass,scArrayList_class; 314 314 jmethodID scArrayList_constructor; 315 jobject scObject2 ,scObject3,scObject4;315 jobject scObject2; 316 316 #ifdef JAVA7 317 317 scArrayListClass = (*env).FindClass("java/util/ArrayList"); … … 320 320 jmethodID add_mid = 0; 321 321 scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor); 322 scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);323 scObject4 = (*env).NewObject(scArrayList_class, scArrayList_constructor);324 322 325 323 add_mid = (*env).GetMethodID(scArrayListClass, … … 331 329 jmethodID add_mid = 0; 332 330 scObject2 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor); 333 scObject3 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);334 scObject4 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);335 331 336 332 add_mid = (*env)->GetMethodID(env,scArrayListClass, -
trunk/zoo-project/zoo-kernel/service_internal_java.h
r348 r388 39 39 maps* mapsFromHashMap(JNIEnv*,jobject,jclass); 40 40 41 void displayStack(JNIEnv*,maps*); 42 41 43 int zoo_java_support(maps**,map*,service*,maps**,maps**); 42 44 -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r387 r388 892 892 errorException(m, tmpMsg, "InvalidParameterValue"); 893 893 free(tmpMsg); 894 freeService(&s1);895 894 free(s1); 896 895 freeMaps(&m); -
trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py
r382 r388 163 163 i+=1 164 164 outputResult(conf,outputs["Result"],rgeometries) 165 return zoo.S UCCEEDED165 return zoo.SERVICE_SUCCEEDED 166 166 167 167 def ConvexHullPy(conf,inputs,outputs): … … 177 177 i+=1 178 178 outputResult(conf,outputs["Result"],rgeometries) 179 return zoo.S UCCEEDED179 return zoo.SERVICE_SUCCEEDED 180 180 181 181 … … 201 201 j=0 202 202 while j < len(geometry2): 203 tres=geometry1[i].Union(geometry2[j]) 204 if not(tres.IsEmpty()): 205 rgeometries+=[tres] 203 tmp=geometry1[j].Clone() 204 resg=geometry2[i].GetGeometryRef() 205 resg=resg.Union(geometry1[i].GetGeometryRef()) 206 tmp.SetGeometryDirectly(resg) 207 if not(resg.IsEmpty()): 208 rgeometries+=[tmp] 206 209 j+=1 207 210 geometry1[i].Destroy()
Note: See TracChangeset
for help on using the changeset viewer.