7 Replies Latest reply on Jun 14, 2017 10:17 AM by Ramesh Reddy

    AdminAPI extended validity errors

    Lukáš Svačina Newbie

      Hi,

      i'm trying to get errors from Teiid server console (not embedded teiid) into our java application through AdminAPI. For example:

      13:07:01,763 WARN  [org.teiid.RUNTIME] (Worker283_async-teiid-threads816)  TEIID50036 VDB _GENERATED_lukyer.1.0.0 model "postgresDSModel" metadata failed to load. Reason:TEIID31178 Could not obtain connection for schema postgresDSModel, but one is required for metadata load. : org.teiid.translator.TranslatorException: TEIID31178 Could not obtain connection for schema postgresDSModel, but one is required for metadata load.
              at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:76)
              at org.teiid.query.metadata.NativeMetadataRepository.loadMetadata(NativeMetadataRepository.java:62)
              at org.teiid.query.metadata.ChainingMetadataRepository.loadMetadata(ChainingMetadataRepository.java:55)
              at org.teiid.jboss.VDBService$6.run(VDBService.java:342)
              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(ThreadPoolExecutor.java:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at java.lang.Thread.run(Thread.java:748)
      Caused by: org.teiid.translator.TranslatorException: TEIID11009 java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/postgresDS_postgresql
              at org.teiid.translator.jdbc.JDBCExecutionFactory.getConnection(JDBCExecutionFactory.java:282)
              at org.teiid.translator.jdbc.JDBCExecutionFactory.getConnection(JDBCExecutionFactory.java:69)
              at org.teiid.translator.ExecutionFactory.getConnection(ExecutionFactory.java:205)
              at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:72)
              ... 9 more
      Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/postgresDS_postgresql
              at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:146)
              at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:66)
              at org.teiid.translator.jdbc.JDBCExecutionFactory.getConnection(JDBCExecutionFactory.java:278)
              ... 12 more
      Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/postgresDS_postgresql
              at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:656)
              at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:429)
              at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:747)
              at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138)
              ... 14 more
      Caused by: javax.resource.ResourceException: IJ031084: Unable to create connection
              at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:509)
              at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:416)
              at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1319)
              at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:496)
              at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:626)
              at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:598)
              at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:590)
              ... 17 more
      Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgress"
              at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
              at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:106)
              at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
              at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:123)
              at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:28)
              at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:20)
              at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
              at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:22)
              at org.postgresql.Driver.makeConnection(Driver.java:391)
              at org.postgresql.Driver.connect(Driver.java:265)
              at java.sql.DriverManager.getConnection(DriverManager.java:664)
              at java.sql.DriverManager.getConnection(DriverManager.java:247)
              at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:90)
              at org.postgresql.xa.jdbc3.AbstractJdbc3XADataSource.getXAConnection(AbstractJdbc3XADataSource.java:54)
              at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:492)
              ... 23 more
      
      

       

      is Teiid server output, but in AdminAPI i can access only List of strings like:

      errors=[TEIID31178 Could not obtain connection for schema postgresDSModel, but one is required for metadata load. ]
      

       

      How can i access details like:

      org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgress"
      

       

      ? Or at least how to get stack trace to be able to parse it by myself? I have found only org.teiid.adminapi.VDB#getValidityErrors method to get at least some info from teiid server.

       

      Thank you.

       

      Best regards,
      Lukas.

        • 1. Re: AdminAPI extended validity errors
          Ramesh Reddy Master

          There is no Teiid Admin API call for getting the contents of the log file. However, WildFly does provide CLI that can provide the access to the log files. For example, you can issue

           

          /subsystem=logging:read-log-file(name=server.log)
          

           

          to get the contents of server.log file. Now, what you need do is extend the Admin API to wrap the above CLI call in Java so that you can use it. All the Admin API calls are wrappers around CLI calls. See [1]. Here is complete description of CLI method

           

          [standalone@localhost:9990 /] /subsystem=logging:read-operation-description(name=read-log-file)
          {
              "outcome" => "success",
              "result" => {
                  "operation-name" => "read-log-file",
                  "description" => "Reads the contents of a log file. The file must be in the jboss.server.log.dir and must be defined as a file-handler, periodic-rotating-file-handler or size-rotating-file-handler.",
                  "request-properties" => {
                      "name" => {
                          "type" => STRING,
                          "description" => "The name of the log file to read. This file must exist in the jboss.server.log.dir.",
                          "expressions-allowed" => true,
                          "required" => true,
                          "nillable" => false,
                          "min-length" => 1L,
                          "max-length" => 2147483647L
                      },
                      "encoding" => {
                          "type" => STRING,
                          "description" => "The character encoding used to read the file.",
                          "expressions-allowed" => true,
                          "required" => false,
                          "nillable" => true,
                          "min-length" => 1L,
                          "max-length" => 2147483647L
                      },
                      "lines" => {
                          "type" => INT,
                          "description" => "The number of lines to read from the file. A value of -1 will read all log lines.",
                          "expressions-allowed" => true,
                          "required" => false,
                          "nillable" => true,
                          "default" => 10,
                          "min" => -1L,
                          "max" => 2147483647L
                      },
                      "skip" => {
                          "type" => INT,
                          "description" => "The number of lines to skip before reading.",
                          "expressions-allowed" => true,
                          "required" => false,
                          "nillable" => true,
                          "default" => 0,
                          "min" => 0L,
                          "max" => 2147483647L
                      },
                      "tail" => {
                          "type" => BOOLEAN,
                          "description" => "Reads from the end of the file.",
                          "expressions-allowed" => true,
                          "required" => false,
                          "nillable" => true,
                          "default" => true
                      }
                  },
                  "reply-properties" => {
                      "type" => LIST,
                      "value-type" => STRING
                  },
                  "deprecated" => {
                      "since" => "3.0.0",
                      "reason" => "Use the log-file resource to read the log file."
                  },
                  "access-constraints" => {"sensitive" => {"view-server-logs" => {"type" => "logging"}}},
                  "read-only" => true,
                  "runtime-only" => true
              }
          }
          

           

          [1] teiid/AdminFactory.java at master · teiid/teiid · GitHub

          • 2. Re: AdminAPI extended validity errors
            Lukáš Svačina Newbie

            Thank you for pointing out how it works. However i do not think it is a good way to parse potentially very large log files all the time. Is there any other solution how to get object stacktrace mapped to my adminApi call? I need to do a lot of parallel vdb deploys so it is not so easy sequential case.

             

            What about wildfly logger filters? May it be possible to access messages in structured object way?

             

            Could you please point out where does AdminFactory.java load and parse data for org.teiid.adminapi.VDB#getValidityErrors method?

             

            Thank you.

            • 3. Re: AdminAPI extended validity errors
              Ramesh Reddy Master

              However i do not think it is a good way to parse potentially very large log files all the time.

              Looks like the CLI API gives you ways to skip the lines, if applicable you can use that

               

              Is there any other solution how to get object stacktrace mapped to my adminApi call? I need to do a lot of parallel vdb deploys so it is not so easy sequential case.

              You deploy your own log appenders, it is easy to write Log4J appenders and configure in WildFly, then choice will be users as to where you are writing and how you are consuming.

              What about wildfly logger filters? May it be possible to access messages in structured object way?

              I guess you mean logging appenders as I mentioned above, yes, to read as object your application need to be in the same VM as Teiid/WildFly. Otherwise, there needs to be a mechanism to write to some pipe/stream and read on the other side.

              Could you please point out where does AdminFactory.java load and parse data for org.teiid.adminapi.VDB#getValidityErrors method?

              teiid/VDBRepository.java at master · teiid/teiid · GitHub  is where the VDB log errors are logged, however, these are carried with VDB to show up in a console. If you want on AdminAPI you can get the getVDB call, that will have errors you are looking for. For general log file messages you need to think about the log appenders.

              • 4. Re: AdminAPI extended validity errors
                Lukáš Svačina Newbie

                Hi,

                thank you for all information provided. I will try to "hack" around it somehow. Is there any chance teiid AdminAPI will be able to grab detailed error message from teiid server?
                I think it should be logically joined together (jsut "error happend" general message is really not a good programmers habit).

                • 5. Re: AdminAPI extended validity errors
                  Ramesh Reddy Master

                  The error we capture is solely for display purposes, so keeping a stack trace around does not fit that model. The idea is this error gives you enough details for the user to start resolving the issue.

                  • 6. Re: AdminAPI extended validity errors
                    Lukáš Svačina Newbie

                    I understand the main purpose of error capturing in AdminAPI. However given you are building automatized system with minimum user interaction with server or server logs, you need some deterministic way how to obtain teiid state in structured way.

                    • 7. Re: AdminAPI extended validity errors
                      Ramesh Reddy Master

                      Ok, if you want log enhancement JIRA and may provide a patch, I will try to get that one into the build.