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

MongoDB import fails when collection contains an empty array

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 12.3, 8.12.19.6_4
    • 8.12.17.6_4
    • Server
    • None
    • 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>

      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)

              rhn-engineering-shawkins Steven Hawkins
              rhn-support-mshirley Marc Shirley (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: