visad.TypeException: ScalarType: name already used

My project is a client/server model that uses RMI to communicate across
the network.  The server returns a FlatField to the client generated
from a netcdf file using Plain().open:

  public FlatField GetSOM(String stem) throws VisADException, IOException
  {
    Plain plain=new Plain();
    String filename=GenerateNetcdf(stem);
    FlatField netcdf_data=(FlatField) plain.open(filename+".nc");
    Process shell=Runtime.getRuntime().exec("/bin/rm -f "+filename+".nc");
    return(netcdf_data);
  }

However, I wanted to get rid of the dependance on netcdf because it
requires I use ncgen to convert my CDL to a netcdf file which consequently
makes it less portable.  The replacement code is below.  Now, if I call the
server more than once it generates the exception:

  visad.TypeException: ScalarType: name already used

at this line

  RealType X=new RealType("X",null,null);

I need the name to be "X" because I use axis labels.  I cannot figure out
how to get around this problem.  How can I fix the following method so
one or more clients can call it repeatedly without generating this exception?
Why does this work just fine if I use the above netcdf code?

  public FlatField GetSOM(String stem) throws VisADException, IOException
  {
    // construct a MathType ((X, Y) -> documents)
    RealType X=new RealType("X",null,null);
    RealType Y=new RealType("Y",null,null);
    RealTupleType XY=new RealTupleType(new RealType[] {X,Y});
    RealType Documents=new RealType("documents",null,null);
    FunctionType field_type=new FunctionType(XY,Documents);
    Process shell=Runtime.getRuntime().exec("equinox get-som "+stem);
    BufferedReader in
      new BufferedReader(new InputStreamReader(shell.getInputStream()));
    StringTokenizer tokenstream=new StringTokenizer(in.readLine()," ");
    int width=Integer.parseInt(tokenstream.nextToken());
    int height=Integer.parseInt(tokenstream.nextToken());
    Integer2DSet domain_set=new Integer2DSet(width,height);
    FlatField field=new FlatField(field_type,domain_set);
    float[][] data=new float[1][width*height];
    for (int i=0; i < (width*height); i++)
    {
      tokenstream=new StringTokenizer(in.readLine()," ");
      int x=Integer.parseInt(tokenstream.nextToken());
      int y=Integer.parseInt(tokenstream.nextToken());
      int z=Integer.parseInt(tokenstream.nextToken());
      data[0][x+y*width]=z;
    }
    in.close();
    field.setSamples(data);
    return(field);
  }

As soon as I resolve this problem, I will making this application available
on the Net so others can benefit from my efforts.

  • 1998 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: