Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-5766

MongoDB import fails when collection contains an empty array

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 8.12.17.6_4
    • Fix Version/s: 12.3, 8.12.19.6_4
    • Component/s: Server
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      1. Create MongoDB collection with first document like:

      { "bday":"2000-01-01", "name":"Bob", "children":[ ] }

      2. Set up resource adapter for mongoDB
      <resource-adapter id="testMongo">
      <module slot="main" id="org.jboss.teiid.resource-adapter.mongodb"/>
      <transaction-support>NoTransaction</transaction-support>
      <connection-definitions>
      <connection-definition class-name="org.teiid.resource.adapter.mongodb.MongoDBManagedConnectionFactory" jndi-name="java:/testMongo" enabled="true" pool-name="testMongo">
      <config-property name="Database">
      test
      </config-property>
      <config-property name="Username">
      test
      </config-property>
      <config-property name="RemoteServerList">
      127.0.0.1:27017
      </config-property>
      <config-property name="Password">
      mypassword
      </config-property>
      </connection-definition>
      </connection-definitions>
      </resource-adapter>

      3. Deploy VDB like below:
      <?xml version="1.0" ?>
      <vdb name="testmongo" version="1">
      <model name="test" type="PHYSICAL" visible="true"><property name="importer.tableTypes" value="TABLE"></property>
      <source name="local" translator-name="mongodb" connection-jndi-name="java:/testMongo"/>
      </model>
      </vdb>

      Show
      1. Create MongoDB collection with first document like: { "bday":"2000-01-01", "name":"Bob", "children":[ ] } 2. Set up resource adapter for mongoDB <resource-adapter id="testMongo"> <module slot="main" id="org.jboss.teiid.resource-adapter.mongodb"/> <transaction-support>NoTransaction</transaction-support> <connection-definitions> <connection-definition class-name="org.teiid.resource.adapter.mongodb.MongoDBManagedConnectionFactory" jndi-name="java:/testMongo" enabled="true" pool-name="testMongo"> <config-property name="Database"> test </config-property> <config-property name="Username"> test </config-property> <config-property name="RemoteServerList"> 127.0.0.1:27017 </config-property> <config-property name="Password"> mypassword </config-property> </connection-definition> </connection-definitions> </resource-adapter> 3. Deploy VDB like below: <?xml version="1.0" ?> <vdb name="testmongo" version="1"> <model name="test" type="PHYSICAL" visible="true"><property name="importer.tableTypes" value="TABLE"></property> <source name="local" translator-name="mongodb" connection-jndi-name="java:/testMongo"/> </model> </vdb>

      Description

      MongoDB import fails with error like [1] when collection returns an empty array in the first doc.

      [1]
      14:32:38,167 WARN [org.teiid.RUNTIME] (teiid-async-threads - 1) TEIID50036 VDB importVDB.1 model "importVDBSrcModel" metadata failed to load. Reason:Index: 0, Size: 0: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.rangeCheck(ArrayList.java:657) [rt.jar:1.8.0_171]
      at java.util.ArrayList.get(ArrayList.java:433) [rt.jar:1.8.0_171]
      at org.teiid.translator.mongodb.MongoDBMetadataProcessor.addColumn(MongoDBMetadataProcessor.java:149)
      at org.teiid.translator.mongodb.MongoDBMetadataProcessor.addTable(MongoDBMetadataProcessor.java:115)
      at org.teiid.translator.mongodb.MongoDBMetadataProcessor.process(MongoDBMetadataProcessor.java:72)
      at org.teiid.translator.mongodb.MongoDBMetadataProcessor.process(MongoDBMetadataProcessor.java:48)
      at org.teiid.translator.ExecutionFactory.getMetadata(ExecutionFactory.java:950) [teiid-api-8.12.17.6_4-redhat-64-2.jar:8.12.17.6_4-redhat-64-2]
      at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:96) [teiid-engine-8.12.17.6_4-redhat-64-2.jar:8.12.17.6_4-redhat-64-2]
      at org.teiid.query.metadata.NativeMetadataRepository.loadMetadata(NativeMetadataRepository.java:62) [teiid-engine-8.12.17.6_4-redhat-64-2.jar:8.12.17.6_4-redhat-64-2]
      at org.teiid.query.metadata.ChainingMetadataRepository.loadMetadata(ChainingMetadataRepository.java:55) [teiid-engine-8.12.17.6_4-redhat-64-2.jar:8.12.17.6_4-redhat-64-2]
      at org.teiid.jboss.VDBService$6.run(VDBService.java:395) [teiid-jboss-integration-8.12.17.6_4-redhat-64-2.jar:8.12.17.6_4-redhat-64-2]
      at org.teiid.jboss.VDBService$7.run(VDBService.java:446) [teiid-jboss-integration-8.12.17.6_4-redhat-64-2.jar:8.12.17.6_4-redhat-64-2]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_171]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_171]
      at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_171]
      at org.jboss.threads.JBossThread.run(JBossThread.java:122)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                shawkins Steven Hawkins
                Reporter:
                mshirley Marc Shirley
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: