3 Replies Latest reply on Jun 24, 2013 11:08 AM by Ramesh Reddy

    MongoDB - null unhandled exception

    devin pinkston Newbie

      I have created a connection to MongoDB, when i submit a query, I can see a "connection accepted" from my client IP when mointoring the mongoDB instance.

       

      I used the resource adapter provided in the documentation, and supplied the metadata using DLL:

       

      <model name="mongoClean">

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

              <metadata type="DDL"><![CDATA[

              CREATE FOREIGN TABLE mongoCleaning (

                nyOne varchar(40),

                nyTwo varchar(40),

                nyThree varchar(40),

                nyFour varchar(40)

              ) OPTIONS(UPDATABLE 'TRUE', EMBEDDABLE 'TRUE');

              ]]> </metadata>

          </model>

       

      Do i need to provide a way to grab the data from MongoDB, or should just creating the foreign table allow for my JDBCclient to query data?  What I mean is should I add something similar to how we handle flat files:

      select mongoCleaning.* from (call mongo.getTextFiles('*.txt')) f, TEXTTABLE(f.file COLUMNS theIndex integer, theYear integer, theDay integer, theTime integer, ap integer, rainfall double, windspeed double, temp double HEADER) mongoCleaning;

       

      When I submit a query, I can see a connection accepted, I just don't return results. 

       

      Thanks!

        • 1. Re: MongoDB - null unhandled exception
          Ramesh Reddy Master

          Devin,

           

          try dropping "EMBEDDABLE" property when using only single table

           

          <model name="mongoClean">
                  <source name="local" translator-name="mongodb" connection-jndi-name="java:/mongoDS"/>
                  <metadata type="DDL"><![CDATA[
                  CREATE FOREIGN TABLE MongoCleaning (
                      nyOne varchar(40),
                      nyTwo varchar(40),
                      nyThree varchar(40),
                      nyFour varchar(40)
                  ) OPTIONS(UPDATABLE 'TRUE');
                  ]]> </metadata>
           </model>
          

           

          then try to do insert like

           

          INSERT INTO MongoCleaning (nyOne, nyTwo, nyThree, nyFour) VALUES ('one', 'two', 'three', 'four');
          

           

          if you have data already in another database, you can write a "SELECT INFO" and pump data into MongoDB.

           

          now you can do

           

          SELECT * FROM MongoCleaning
          

           

           

          Thanks.

           

          Ramesh..

          • 2. Re: MongoDB - null unhandled exception
            devin pinkston Newbie

            Ramesh,

             

            I dropped the embeddable property on my Model, it's now identical to your example above.  My resource-adapter is identical to the sample provided in the translator documentation, I just changed the IP/port.  I can see a connection being made by Teiid to Mongo DB (I am monitoring it when i submit a query), however I return a NullPointerException when I try to INSERT INTO like you have posted above. 

             

            This is from the server:

             

             

            07:49:21,523 ERROR [org.teiid.CONNECTOR] (Worker5_QueryProcessorQueue20) XtoBNMeJSoWR Connector worker process failed for atomic-request=XtoBNMeJSoWR.0.0.4: java.lang.NullPointerException

                at org.teiid.translator.mongodb.MongoDBSelectVisitor.isPartOfPrimaryKey(MongoDBSelectVisitor.java:780)

                at org.teiid.translator.mongodb.MongoDBUpdateVisitor.getInsert(MongoDBUpdateVisitor.java:154)

                at org.teiid.translator.mongodb.MongoDBUpdateExecution.execute(MongoDBUpdateExecution.java:109)

                at org.teiid.dqp.internal.datamgr.ConnectorWorkItem$1.execute(ConnectorWorkItem.java:287) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:254) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:446) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:159) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:156) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_43]

                at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_43]

                at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:58) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:269) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:214) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_43]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_43]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_43]

             

            07:49:21,528 ERROR [org.teiid.PROCESSOR] (Worker4_QueryProcessorQueue21) XtoBNMeJSoWR TEIID30019 Unexpected exception for request XtoBNMeJSoWR.0: java.lang.NullPointerException

                at org.teiid.translator.mongodb.MongoDBSelectVisitor.isPartOfPrimaryKey(MongoDBSelectVisitor.java:780)

                at org.teiid.translator.mongodb.MongoDBUpdateVisitor.getInsert(MongoDBUpdateVisitor.java:154)

                at org.teiid.translator.mongodb.MongoDBUpdateExecution.execute(MongoDBUpdateExecution.java:109)

                at org.teiid.dqp.internal.datamgr.ConnectorWorkItem$1.execute(ConnectorWorkItem.java:287) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:254) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:446) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:159) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:156) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_43]

                at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_43]

                at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:58) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:269) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:214) [teiid-engine-8.4.0.Final.jar:8.4.0.Final]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_43]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_43]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_43]

             

            This is from my JDBC client:

            org.teiid.jdbc.TeiidSQLException: org.teiid.core.TeiidException

                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:667)

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

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

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

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

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

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

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

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

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:616)

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

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

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

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

                at org.teiid.jdbc.StatementImpl.execute(StatementImpl.java:1030)

                at org.teiid.jdbc.StatementImpl.execute(StatementImpl.java:312)

                at DataAccess.main(DataAccess.java:32)

            Caused by: org.teiid.core.TeiidException

                at org.teiid.client.ResultsMessage.setException(ResultsMessage.java:202)

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

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

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

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

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

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

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

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

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

                at java.lang.Thread.run(Thread.java:662)

            Caused by: java.lang.NullPointerException

                at org.teiid.translator.mongodb.MongoDBSelectVisitor.isPartOfPrimaryKey(MongoDBSelectVisitor.java:780)

                at org.teiid.translator.mongodb.MongoDBUpdateVisitor.getInsert(MongoDBUpdateVisitor.java:154)

                at org.teiid.translator.mongodb.MongoDBUpdateExecution.execute(MongoDBUpdateExecution.java:109)

                at org.teiid.dqp.internal.datamgr.ConnectorWorkItem$1.execute(ConnectorWorkItem.java:287)

                at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:254)

                at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:446)

                at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:159)

                at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:156)

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

                at java.util.concurrent.FutureTask.run(FutureTask.java:138)

                at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:58)

                ... 6 more

             

            Do I require a primary key?

             

            Thanks!

            • 3. Re: MongoDB - null unhandled exception
              Ramesh Reddy Master

              Devin,

               

              That was bug, I fixed later in code base after 8.4 final. You do not really need PK for Mongo, but in this case if you define a PK even though it is bogus one it will get you out that bug.

               

              Let me know if that works.

               

              Ramesh..