The table was not found. [GDB_DBTune] createFeatureDataset arcGIS 9.3

2864
6
07-02-2014 11:41 AM
TimothyOMalley
New Contributor
Hi,
  Looking for some help with creating feature datasets in a new Geodatabase. The following code works find with 10.1, but not 9.3.1.

IGeographicCoordinateSystem m_geographicCoordinateSystem = (new SpatialReferenceEnvironment())
    .createGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_WGS1984);

IWorkspaceFactory m_workspaceFactory = new FileGDBWorkspaceFactory();
IWorkspaceName workspaceName = m_workspaceFactory.create(workspacePath, gdbfileName, null, 0);
Workspace m_workspace = new Workspace(m_workspaceFactory.openFromFile(workspaceName.getPathName(), 0));

FeatureDataset featureDataset = new FeatureDataset(m_workspace.createFeatureDataset(name, m_geographicCoordinateSystem));


The exception thrown by createFeatureDataset:
AutomationException: 0x8004120e - The table was not found. [GDB_DBTune] in 'ESRI GeoDatabase'

Thanks
0 Kudos
6 Replies
RobertMaddox
New Contributor III
Try replacing your code with the following:

IGeographicCoordinateSystem m_geographicCoordinateSystem = new SpatialReferenceEnvironment().CreateGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_WGS1984);
IWorkspaceFactory m_workspaceFactory = new FileGDBWorkspaceFactory();
IName workspaceName = m_workspaceFactory.create(workspacePath, gdbfileName, null, 0) as IName;
IFeatureWorkspace m_workspace = workspaceName.Open() as IFeatureWorkspace;

IFeatureDataset featureDataset = m_workspace.createFeatureDataset(name, m_geographicCoordinateSystem);


See if that changes anything. 😉
0 Kudos
TimothyOMalley
New Contributor
Thanks. I tried the following, but I still get The table was not found. [GDB_DBTune].

IName workspaceName = (IName) m_workspaceFactory.create(workspacePath, gdbfileName, null, 0);
Workspace m_workspace = new Workspace(workspaceName.open());
0 Kudos
RobertMaddox
New Contributor III
Why are you calling `new Workspace()`? That shouldn't even compile as Workspace doesn't have any public constructors (hence the reason for IWorkspaceFactory). I'm guessing maybe you have some kind of wrapper class that you've named Workspace. If that's the case, I strongly recommend renaming it. It's just too confusing and causes namespace collisions. You'd be better off naming it something more appropriate to what it actually does, like WorkspaceWrapper or WorkspaceHelper. (Edit: There's actually a class called WorkspaceHelper too, so scratch that one...lol)

The other thing I would check for is to make sure that you can actually open the workspace from within ArcMap so that you can see if it just isn't a valid workspace.

One other thing I would suggest is leaving out the wrapper classes and just use ArcObjects code and see if you get different results.
0 Kudos
TimothyOMalley
New Contributor
I haven't created my own wrapper, com.esri.arcgis.geodatabase.Workspace has a contructor. I also tried a cast:

Workspace m_workspace = (Workspace) m_workspaceFactory.openFromFile(workspaceName.getPathName(), 0);


I'm creating the gdb new, opening it, and trying to create a feature dataset. I don't have an existing gdb to open in ArcMap.

Thanks
0 Kudos
RobertMaddox
New Contributor III
Oh, so you're using Java...

*Looks at the docs for the Java version of Workspace*

*facepalm*

OMG. I am so glad I don't do anything with ArcObjects for Java. I thought they were equivalent, but they apparently aren't.

Sorry man. I can't help you any further on this one. I don't want to touch anything that looks like this statement that I just read in the docs.

public Workspace(Object obj)
          throws IOException
Construct a Workspace using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to Workspace.
Casting to this class from the return value of a method will not work, as this class represents an abstract class in ArcObjects. 
* 
Workspace o = (Workspace)obj; // will not work 

Workspace o = new Workspace(obj); // Use this constructor instead 
* @param obj an object returned from ArcGIS Engine or Server
Throws:
IOException - if there are interop problems Workspace theWorkspace = (Workspace) obj;


So you can't cast the object to an IWorkspace, you have to construct a new object to cast it? No thank you. C# FTW! LOL

I hope someone else could help you. Maybe ldonahue will come give you a hand, since he apparently understands Java ArcObjects better than I do. Good luck with that. 😉
0 Kudos
LeoDonahue
Occasional Contributor III

Timothy,

You were using the wrong workspace.  I don't know if this will help you or not.

import java.io.IOException;

import java.net.UnknownHostException;

import com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory;

import com.esri.arcgis.geodatabase.IFeatureWorkspace;

import com.esri.arcgis.geodatabase.IFeatureWorkspaceProxy;

import com.esri.arcgis.geodatabase.IWorkspace;

import com.esri.arcgis.geodatabase.IWorkspaceFactory;

import com.esri.arcgis.geodatabase.IWorkspaceName;

import com.esri.arcgis.geodatabase.IWorkspaceProxy;

import com.esri.arcgis.geometry.ISpatialReference;

import com.esri.arcgis.geometry.SpatialReferenceEnvironment;

import com.esri.arcgis.interop.AutomationException;

import com.esri.arcgis.system.EngineInitializer;

import com.esri.arcgis.system.IName;

public class FGDBDemo {

    private static IWorkspace workspace;

    public static void main(String[] args) {

    

        // code generated from the File|New|ESRI Templates|ArcObjects Project|Console wizard

        EngineInitializer.initializeEngine();

        initializeArcGISLicenses();

    

        // create the File Geodatbase and Workspace stuff... code copied more or less directly from the help

        createFGDBStuff();

    

        // create the feature dataset... code copied more or less directly from the help

        createFeatureDataset();

    }

    static void initializeArcGISLicenses() {

        try {

            com.esri.arcgis.system.AoInitialize ao = new com.esri.arcgis.system.AoInitialize();

            if (ao.isProductCodeAvailable(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngine) == com.esri.arcgis.system.esriLicenseStatus.esriLicenseAvailable)

                ao.initialize(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngine);

            else if (ao.isProductCodeAvailable(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeArcInfo) == com.esri.arcgis.system.esriLicenseStatus.esriLicenseAvailable)

                ao.initialize(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeArcInfo);

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

    public static void createFGDBStuff(){

    

        try {

        

            //Create a FileGDB workspace factory

            IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();

        

            //Create a new File geodatabase

            IWorkspaceName workspaceName = workspaceFactory.create("C:\\GIS\\", "MyFGDB.gdb", null, 0);

            //Cast for IName

            //   ... there are different ways to do this, it was the first sample I copied from the help.

            //   ... alot of people like opening the opening the FGDB using a path name, there are samples in the help for that.

            IName name = (IName)workspaceName;

            //Open a reference to the FGDB workspace through the name object

            workspace = new IWorkspaceProxy(name.open());

        

        } catch (UnknownHostException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

    private static void createFeatureDataset(){

    

        try {

        

            // variable to hold the named constant value for this spatial reference

            int wgs84 = com.esri.arcgis.geometry.esriSRGeoCSType.esriSRGeoCS_WGS1984;

        

            // Create a SpatialReferenceEnvironment and ISpatialReference

            SpatialReferenceEnvironment spatialRef = new SpatialReferenceEnvironment();

            ISpatialReference gcswgs84 = spatialRef.createGeographicCoordinateSystem(wgs84);

        

            // create the feature workspace

            IFeatureWorkspace featureWorkspace = new IFeatureWorkspaceProxy(workspace);

        

            // create the featureDataset (the name, the featureDataset spatial reference)

            featureWorkspace.createFeatureDataset("MyFDS", gcswgs84);

        

        } catch (AutomationException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

}