Changeset 388 for trunk/zoo-project


Ignore:
Timestamp:
Jan 11, 2013, 3:43:44 PM (12 years ago)
Author:
djay
Message:

Fix issue in OGR python services, thanks to Farkas to point this issue. Update Java support to handle properly the error messages coming from the JVM. Fix segfault when ZCFG file doesn't exist.

Location:
trunk/zoo-project
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal_java.c

    r364 r388  
    22 * Author : Gérald FENOY
    33 *
    4  * Copyright (c) 2009-2012 GeoLabs SARL
     4 * Copyright (c) 2009-2013 GeoLabs SARL
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    5252    }
    5353    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
    5574#ifdef DEBUG
    5675  fprintf(stderr,"CLASSPATH=%s\n",classpath);
     
    7897  int i;
    7998
    80   options[0].optionString = strdup(oclasspath);
     99  options[0].optionString = oclasspath;
    81100#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";*/
    83105#endif
    84106
     
    112134#endif
    113135  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);
    123137#ifdef JAVA7
    124138    (*jvm).DestroyJavaVM();
     
    182196        dumpMaps(outputs);
    183197#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);
    214200#ifdef JAVA7
    215201        (*jvm).DestroyJavaVM();
     
    221207    }
    222208    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);
    229210#ifdef JAVA7
    230211      (*jvm).DestroyJavaVM();
     
    234215      return -1;
    235216    }
    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 JAVA7
    244     (*jvm).DestroyJavaVM();
    245 #else
    246     (*jvm)->DestroyJavaVM(jvm);
    247 #endif
    248     return -1;
    249217  }
    250218#ifdef JAVA7
     
    254222#endif
    255223  return res;
     224}
     225
     226/**
     227 * Error handling: display stack trace in an ExceptionReport Document
     228 */
     229void 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);
    256256}
    257257
     
    313313            jclass scArrayListClass,scArrayList_class;
    314314            jmethodID scArrayList_constructor;
    315             jobject scObject2,scObject3,scObject4;
     315            jobject scObject2;
    316316#ifdef JAVA7
    317317            scArrayListClass = (*env).FindClass("java/util/ArrayList");
     
    320320            jmethodID add_mid = 0;
    321321            scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
    322             scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
    323             scObject4 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
    324322
    325323            add_mid = (*env).GetMethodID(scArrayListClass,
     
    331329            jmethodID add_mid = 0;
    332330            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);
    335331
    336332            add_mid = (*env)->GetMethodID(env,scArrayListClass,
  • trunk/zoo-project/zoo-kernel/service_internal_java.h

    r348 r388  
    3939  maps* mapsFromHashMap(JNIEnv*,jobject,jclass);
    4040 
     41  void displayStack(JNIEnv*,maps*);
     42
    4143  int zoo_java_support(maps**,map*,service*,maps**,maps**);
    4244
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r387 r388  
    892892    errorException(m, tmpMsg, "InvalidParameterValue");
    893893    free(tmpMsg);
    894     freeService(&s1);
    895894    free(s1);
    896895    freeMaps(&m);
  • trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py

    r382 r388  
    163163        i+=1
    164164    outputResult(conf,outputs["Result"],rgeometries)
    165     return zoo.SUCCEEDED
     165    return zoo.SERVICE_SUCCEEDED
    166166
    167167def ConvexHullPy(conf,inputs,outputs):
     
    177177        i+=1
    178178    outputResult(conf,outputs["Result"],rgeometries)
    179     return zoo.SUCCEEDED
     179    return zoo.SERVICE_SUCCEEDED
    180180
    181181
     
    201201        j=0
    202202        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]
    206209            j+=1
    207210        geometry1[i].Destroy()
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png