deer147

linux  arcengine for java   openFeatureClass(Unknown Source)

Discussion created by deer147 on Mar 25, 2011
Latest reply on Mar 26, 2011 by deer147
I use arcengine for java in linux operation.
The exception I got was "AutomationException: 0x80004005 - Unspecified error".
My product version is arcengine 9.3 java for linux.
error in
at com.esri.arcgis.geodatabase.Workspace.openFeatureClass(Unknown Source)

code
{
String workspacePath = arcGISHome + "/java/samples/data/usa";
String featureClassName = "states.shp";
File shapefileFile = new File(workspacePath, featureClassName);
if (!shapefileFile.exists()) {
System.out.println("Shapefile " + shapefileFile.getAbsolutePath() + " doesn't exist. Exiting.");
System.exit(-1);
}
System.out.println("Shapefile: " + shapefileFile.getAbsolutePath());

try {
AoInitialize aoInitializer = new AoInitialize();
aoInitializer.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);

ShapefileWorkspaceFactory shapefileWorkspaceFactory = new ShapefileWorkspaceFactory();
Workspace workspace = new Workspace(shapefileWorkspaceFactory.openFromFile(workspacePath, 0));
FeatureClass featureClass = new FeatureClass(workspace.openFeatureClass(featureClassName)); int numFeatures = featureClass.featureCount(null);
System.out.println("There are " + numFeatures + " features:");

for (int i = 0; i < numFeatures; i++){
IFeature feature = featureClass.getFeature(i);
IGeometry geometry = feature.getShapeCopy();
System.out.println("Feature " + i + ": ");
System.out.println(getStringFromShape(geometry));
if (i >= 9) {
break; // 10 is enough
}
}
aoInitializer.shutdown();
System.out.println("Sample finished.");
} catch (Exception e) {
e.printStackTrace();
}

}


why use workspace.openFeatureClass in some errors,the shapefile's path and name is correct .

Any solution or workaround this?

Thank you very much in advance

Outcomes