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

Unable to connect to MongoDB pod from JBoss Data Virtualization (on OpenShift)

    Details

    • Type: Enhancement
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 9.2, 8.12.16.6_4
    • Component/s: None
    • Labels:
    • Environment:

      I was running using JDV 6.3 running on OpenShift 3.4 and couldn't connect my VDB to mongodb.

    • Affects:
      Documentation (Ref Guide, User Guide, etc.), User Experience

      Description

      It looks like the setup of the mongodb resource adapter is not documented correctly. Tested it also locally with the same issue when using an username/password to connect to a mongodb database.

      15:26:01,386 WARN [org.teiid.CONNECTOR] (http-127.0.0.1:8080-1) TEIID30003 Without required support property SelfJoins, pushdown will not be enabled for TableAlias on translator [mongodb, java:jboss/datasources/MongoDS].
      15:26:01,626 INFO [org.teiid.CONNECTOR] (Worker0_QueryProcessorQueue0) SELECT product.itemId AS c_0, product.name AS c_1, product.description AS c_2, product.price AS c_3 FROM product ORDER BY c_0
      15:26:01,662 WARN [org.teiid.CONNECTOR] (Worker0_QueryProcessorQueue0) Connector worker process failed for atomic-request=G8hRIMByScTW.0.0.0: org.teiid.translator.TranslatorException:

      { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18 , "codeName" : "AuthenticationFailed"}

      at org.teiid.translator.mongodb.MongoDBQueryExecution.execute(MongoDBQueryExecution.java:104) [translator-mongodb-8.12.8.6_3-redhat-2.jar:8.12.8.6_3-redhat-2]
      at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:366)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_121]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_121]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_121]
      at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_121]
      at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:211)
      at com.sun.proxy.$Proxy96.execute(Unknown Source)
      at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:306)
      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:112)
      at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_121]
      at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:65)
      at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:280)
      at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119)
      at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:210)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_121]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_121]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]
      Caused by: com.mongodb.CommandFailureException:

      { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18 , "codeName" : "AuthenticationFailed"}

      at com.mongodb.CommandResult.getException(CommandResult.java:76) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.CommandResult.throwOnError(CommandResult.java:140) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBPort$NativeAuthenticator.authenticate(DBPort.java:986) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBPort.authenticate(DBPort.java:432) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBPort.checkAuth(DBPort.java:443) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:289) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:269) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DB.command(DB.java:320) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DB.command(DB.java:299) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBCollectionImpl.aggregate(DBCollectionImpl.java:99) [mongo-java-driver-2.13.1.jar:]
      at com.mongodb.DBCollection.aggregate(DBCollection.java:1649) [mongo-java-driver-2.13.1.jar:]
      at org.teiid.translator.mongodb.MongoDBQueryExecution.execute(MongoDBQueryExecution.java:102) [translator-mongodb-8.12.8.6_3-redhat-2.jar:8.12.8.6_3-redhat-2]
      ... 18 more

      Solution is to add the SecurityType configuration parameter in the mongodb resource adapter configuration and set the value to SCRAM_SHA_1.

      • Create a VDB
        <?xml version="1.0" encoding="UTF-8" standalone="no"?>
        <vdb name="CatalogVDB" version="1">
        <description/>
        <property name="validationDateTime" value="Thu Sep 01 10:33:00 CEST 2016"/>
        <property name="validationVersion" value="8.12.6"/>

      <model name="CatalogDB" type="VIRTUAL">
      <metadata type="DDL"><![CDATA[
      CREATE VIEW products (
      itemId integer,
      name string(50),
      description varchar(1024),
      price bigdecimal,
      CONSTRAINT ITEMID_UK UNIQUE (itemId)
      ) AS select * from Products_MONGODB.product
      ]]></metadata>
      </model>

      <model name="Products_MONGODB">
      <source connection-jndi-name="java:jboss/datasources/MongoDS" name="local" translator-name="mongodb"/>
      <metadata type="DDL"><![CDATA[
      CREATE FOREIGN TABLE product (
      itemId integer,
      name varchar(50),
      description varchar(1024),
      price bigdecimal
      ) OPTIONS(UPDATABLE 'TRUE');
      ]]></metadata>
      </model>
      </vdb>

      • Add following resource adapter configuration without SecurityType parameter
        <resource-adapter id="mongodb">
        <module slot="main" id="org.jboss.teiid.resource-adapter.mongodb"/>
        <connection-definitions>
        <connection-definition class-name="org.teiid.resource.adapter.mongodb.MongoDBManagedConnectionFactory" jndi-name="java:jboss/datasources/MongoDS" use-java-context="true" pool-name="cfName">
        <config-property name="Database">
        catalogdb
        </config-property>
        <config-property name="Username">
        catalogAdmin
        </config-property>
        <config-property name="RemoteServerList">
        localhost:27017
        </config-property>
        <config-property name="Password">
        catalogPW
        </config-property>
        <config-property name="SecurityType">
        SCRAM_SHA_1
        </config-property>
        <validation>
        <background-validation>true</background-validation>
        <background-validation-millis>60</background-validation-millis>
        </validation>
        </connection-definition>
        </connection-definitions>
        </resource-adapter>
      • run mongo product.js // see attachment

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                rareddy Ramesh Reddy
                Reporter:
                cvanball Cojan van Ballegooijen
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: