6 Replies Latest reply on Dec 28, 2017 10:52 PM by Ramesh Reddy

    MongoDB configuration in Teiid.

    Kulbhushan Chaskar Master

      Hi,

       

      I am using Wilfly 10.0.0 along with teiid admin api 9.1.3.

       

      1.     I need to configure mongodb in teiid, I know how to configure jdbc datasources like mysql, oracle in wildfly. Similar way I am searching to configure MongoDB.

      2.     Which database driver I need to use for Teiid?

      3.     What will be the VDB xml file content? Do I need to embed schema structure in VDB?

       

      Thanks,

      Kulbhushan Chaskar

        • 1. Re: MongoDB configuration in Teiid.
          Ramesh Reddy Master

          1) See this for an example resource-adapter creation. teiid/IntegrationTestDeployment.java at master · teiid/teiid · GitHub

          2) No JDBC Driver involved with MongoDB, Teiid uses MongoDB Java Client library internally which is supplied with the install

          3) Same as any other VDB, just use "mongodb" as translator name. This is when using the Dynamic VDB where the metadata is being automatically downloaded. If you want to provide the DDL yourself then read this document MongoDB Translator · Teiid Documentation  and understand how the metadata is mapped from document model to a relational model. Then you can hand code the DDL appropriately. Failure to correctly define the metadata just going to end up with errors.

           

          HTH

           

          Ramesh..

          • 2. Re: MongoDB configuration in Teiid.
            Kulbhushan Chaskar Master

            Thanks Ramesh,

             

            As you mentioned above that When using the Dynamic VDB where the metadata is being automatically downloaded, when I tried to deploy VDB by importing monogDB resource adapter created on server then VDB failed to get active, but it worked when metadata information is added to the VDB.

             

            VDB xml file:

            <?xml version="1.0" ?>

            <vdb name="nothwind" version="1">

               <model name="northwind" type="PHYSICAL" visible="true"><property name="importer.tableTypes" value="TABLE"></property>

                 <source name="local" translator-name="mongodb" connection-jndi-name="java:/mongoDS"/>

               </model>

            </vdb>

             

            Resource Adapter in standalone-teiid.xml:

            <resource-adapter id="mongodb123">

                                <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:/mongoDS" enabled="true" use-java-context="true" pool-name="teiid-mongodb-ds">

                                        <config-property name="Database">

                                            mongoTest

                                        </config-property>

                                        <config-property name="RemoteServerList">

                                            <mongod_db_ip>:27019

                                        </config-property>

                                    </connection-definition>

                                </connection-definitions>

                            </resource-adapter>

             

            Failure Stack-Trace:

            10:55:45,868 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (Worker0_async-teiid-threads0)  IJ000604: Throwable while attempting to get a new connection: null: java.lang.NullPointerException

            at org.teiid.resource.adapter.mongodb.MongoDBManagedConnectionFactory.getCredential(MongoDBManagedConnectionFactory.java:94)

            at org.teiid.resource.adapter.mongodb.MongoDBManagedConnectionFactory.access$100(MongoDBManagedConnectionFactory.java:38)

            at org.teiid.resource.adapter.mongodb.MongoDBManagedConnectionFactory$1.getConnection(MongoDBManagedConnectionFactory.java:69)

            at org.teiid.resource.adapter.mongodb.MongoDBManagedConnectionFactory$1.getConnection(MongoDBManagedConnectionFactory.java:64)

            at org.teiid.resource.spi.BasicManagedConnectionFactory.createManagedConnection(BasicManagedConnectionFactory.java:67)

            at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1327)

            at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499)

            at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:632)

            at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:604)

            at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624)

            at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:597)

            at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789)

            at org.teiid.resource.spi.WrappedConnectionFactory.getConnection(WrappedConnectionFactory.java:54)

            at org.teiid.translator.ExecutionFactory.getConnection(ExecutionFactory.java:180)

            at org.teiid.translator.ExecutionFactory.getConnection(ExecutionFactory.java:201)

            at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:68)

            at org.teiid.query.metadata.NativeMetadataRepository.loadMetadata(NativeMetadataRepository.java:58)

            at org.teiid.query.metadata.ChainingMetadataRepository.loadMetadata(ChainingMetadataRepository.java:51)

            at org.teiid.jboss.VDBService$6.run(VDBService.java:337)

            at org.teiid.jboss.VDBService$7.run(VDBService.java:388)

            at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:280)

            at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:115)

            at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:206)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

            at java.lang.Thread.run(Unknown Source)

             

             

            10:55:45,889 WARN  [org.teiid.RUNTIME] (Worker0_async-teiid-threads0)  TEIID50036 VDB nothwind.1 model "northwind" metadata failed to load. Reason:java.lang.NullPointerException: java.lang.NullPointerException

            at org.teiid.translator.mongodb.MongoDBMetadataProcessor.process(MongoDBMetadataProcessor.java:67)

            at org.teiid.translator.mongodb.MongoDBMetadataProcessor.process(MongoDBMetadataProcessor.java:50)

            at org.teiid.translator.ExecutionFactory.getMetadata(ExecutionFactory.java:973)

            at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:92)

            at org.teiid.query.metadata.NativeMetadataRepository.loadMetadata(NativeMetadataRepository.java:58)

            at org.teiid.query.metadata.ChainingMetadataRepository.loadMetadata(ChainingMetadataRepository.java:51)

            at org.teiid.jboss.VDBService$6.run(VDBService.java:337)

            at org.teiid.jboss.VDBService$7.run(VDBService.java:388)

            at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:280)

            at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:115)

            at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:206)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

            at java.lang.Thread.run(Unknown Source)

             

             

            10:55:45,950 INFO  [org.jboss.as.server] (External Management Request Threads -- 6)  WFLYSRV0010: Deployed "nothwind-vdb.xml" (runtime-name : "nothwind-vdb.xml")

             

            Thanks,

            Kulbhushan Chaskar

            • 3. Re: MongoDB configuration in Teiid.
              Steven Hawkins Master

              Were you able to get past this?  Was this on a 10.0.x Teiid server?

              • 4. Re: MongoDB configuration in Teiid.
                Kulbhushan Chaskar Master

                No.. Teiid Server version is 9.1.3

                • 5. Re: MongoDB configuration in Teiid.
                  Kulbhushan Chaskar Master

                  Ramesh/Steven..

                   

                  Due to wrong configuration in Resource adapter I was not able to get MongoDB schema dynamically. Now I am able to get the schema.

                   

                  But I am facing issue when I am executing query on the basis of _id. e.g SELECT _id FROM Customer/ INSERT INTO ...

                   

                  I there any work-around to achieve the same?

                   

                  Exception Stack trace:

                  Remote org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "SELECT [*]_[*]id from" at line 1, column 8.

                  Lexical error. Character is not a valid token: _ 

                  org.teiid.jdbc.TeiidSQLException: Remote org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "SELECT [*]_[*]id from" at line 1, column 8.

                  Lexical error. Character is not a valid token: _

                  at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:135)

                  at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:71)

                  at org.teiid.jdbc.StatementImpl.postReceiveResults(StatementImpl.java:747)

                  at org.teiid.jdbc.StatementImpl.access$100(StatementImpl.java:65)

                  at org.teiid.jdbc.StatementImpl$2.onCompletion(StatementImpl.java:561)

                  at org.teiid.client.util.ResultsFuture.done(ResultsFuture.java:135)

                  at org.teiid.client.util.ResultsFuture.access$200(ResultsFuture.java:40)

                  at org.teiid.client.util.ResultsFuture$1.receiveResults(ResultsFuture.java:79)

                  at org.teiid.net.socket.SocketServerInstanceImpl.receivedMessage(SocketServerInstanceImpl.java:285)

                  at org.teiid.net.socket.SocketServerInstanceImpl.read(SocketServerInstanceImpl.java:337)

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                  at java.lang.reflect.Method.invoke(Unknown Source)

                  at org.teiid.net.socket.SocketServerConnectionFactory$ShutdownHandler.invoke(SocketServerConnectionFactory.java:98)

                  at com.sun.proxy.$Proxy1.read(Unknown Source)

                  at org.teiid.net.socket.SocketServerInstanceImpl$RemoteInvocationHandler$1.get(SocketServerInstanceImpl.java:427)

                  at org.teiid.jdbc.StatementImpl.executeSql(StatementImpl.java:570)

                  at org.teiid.jdbc.StatementImpl.executeSql(StatementImpl.java:423)

                  at org.teiid.jdbc.StatementImpl.executeQuery(StatementImpl.java:354)

                  at com.bitwise.mySql.WithTeiid.execute(WithTeiid.java:678)

                  at com.bitwise.mySql.WithTeiid.executeSelect(WithTeiid.java:247)

                  at com.bitwise.mySql.WithTeiid.main(WithTeiid.java:48)

                  Caused by: org.teiid.core.TeiidProcessingException: Remote org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "SELECT [*]_[*]id from" at line 1, column 8.

                  Lexical error. Character is not a valid token: _

                  at org.teiid.query.parser.QueryParser.convertParserException(QueryParser.java:214)

                  at org.teiid.query.parser.QueryParser.parseCommand(QueryParser.java:164)

                  at org.teiid.query.parser.QueryParser.parseCommand(QueryParser.java:140)

                  at org.teiid.dqp.internal.process.Request.parseCommand(Request.java:306)

                  at org.teiid.dqp.internal.process.Request.generatePlan(Request.java:407)

                  at org.teiid.dqp.internal.process.Request.processRequest(Request.java:481)

                  at org.teiid.dqp.internal.process.RequestWorkItem.processNew(RequestWorkItem.java:657)

                  at org.teiid.dqp.internal.process.RequestWorkItem.process(RequestWorkItem.java:338)

                  at org.teiid.dqp.internal.process.AbstractWorkItem.run(AbstractWorkItem.java:51)

                  at org.teiid.dqp.internal.process.RequestWorkItem.run(RequestWorkItem.java:275)

                  at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:282)

                  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(Unknown Source)

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                  at java.lang.Thread.run(Unknown Source)

                  • 6. Re: MongoDB configuration in Teiid.
                    Ramesh Reddy Master

                    Use quotes around like "_id"