4 Replies Latest reply on Oct 13, 2015 1:03 PM by Lei Feng

    Data Extract API java error

    darren holmblad

      Created some data extract code in java, it functions. However when the code base was enhanced I now revieve an error message seen below.

       

       

      com.tableausoftware.TableauException: Invalid Extract handle
              at com.tableausoftware.DataExtract.Extract.addTable(Unknown Source)
              at tableau.dataExtractSample.main(dataExtractSample.java:186)
      

           

       

      On line 186 is where I am adding the table to the extract. Which can be seen below.

       

      TableDefinition tableDefInit = makeTableDefinition(columns);
      Table table = extract.addTable("Extract", tableDefInit);
      

       

      Has anyone encountered this issue before?

       

      Below is how the tableDef is created

       

      private static TableDefinition makeTableDefinition(NodeList col) throws TableauException {
        TableDefinition tableDef = new TableDefinition();
        tableDef.setDefaultCollation(Collation.EN_US);
        
        for(int i=0; i<col.getLength(); i++){
        Element elm = (Element) col.item(i);
        if(elm.getTagName().equalsIgnoreCase("attribute")){
        System.out.println(elm.getAttribute("name"));
        tableDef.addColumn(elm.getAttribute("name"),Type.UNICODE_STRING);
        }else {
        System.out.println(elm.getAttribute("name"));
        tableDef.addColumn(elm.getAttribute("name"),Type.UNICODE_STRING);
        }
        }
        return tableDef;
        }
      
        • 1. Re: Data Extract API java error

          Hey Darren,

           

          I went ahead and moved this to our Tableau Developer Community where it's more likely to receive a response.

           

          Good luck!

           

          -Diego

          • 2. Re: Data Extract API java error
            Doug Gischlar

            I think I may have your answer.  I am using the Java API and had a similar problem.  Here is my original code to create the extract:

             

             

            Extract  extract = new Extract("C:/personal/Hadoop/Tableau Extract API/Person.tde");

             

             

            The statement above is valid.  But every time I interacted with the extract variable like extract.hasTable("Extract") I would get an Invalid Extract handle error.  Here is the fix:

             

             

            Extract  extract = new Extract("C:\\personal\\Hadoop\\Tableau Extract API\\Person.tde");

             

             

            Make sure if you are running on windows and have a fully qualified path that you use the double back slash in you directory structure.

            • 3. Re: Data Extract API java error
              darren holmblad

              I will try a full path, but unfortunately I don't know if this is the solution to my problem. Currently I am not specifying a path in the Extract so it should just place it where the jar exists. This small snippet of code didnt change in the version which worked vs the one that didnt.

               

              Extract extract = new Extract("TestTableauReport.tde");

              • 4. Re: Data Extract API java error
                Lei Feng

                I had the same issue, but I figured out that anytime you specify the .tde directory make sure it exists. In Doug's example, you have to make sure the directory structure "C:\\personal\\Hadoop\\Tableau Extract API" exists. It seems that Tabelau API cannot build the path automatically.