You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@skywalking.apache.org by GitBox <gi...@apache.org> on 2017/12/22 02:50:18 UTC

[GitHub] jjtyro opened a new issue #699: MySQL Plugin not support application using MysqlDataSource

jjtyro opened a new issue #699: MySQL Plugin not support application using MysqlDataSource 
URL: https://github.com/apache/incubator-skywalking/issues/699
 
 
   Please answer these questions before submitting your issue.
   
   ### What version of sky-walking are you using?
   v3.2.6
   
   ### What version of your OS?
   Windows 10
   
   ### What version of your JRE?
   1.8.0_152
   
   ### What company or project?
   
   
   ### What did you do?
   I use skywalking v3.2.6 to monitor my demo application,  found that MySQL database operations did not appear in the Tracing records. Check the agent log, found this exception:
   "ERROR 2017-12-21 15:16:04 InstMethodsInter :  class[class com.mysql.jdbc.JDBC4Connection] before method[close] intercept failure 
   java.lang.NullPointerException
   	at org.skywalking.apm.plugin.jdbc.ConnectionServiceMethodInterceptor.beforeMethod(ConnectionServiceMethodInterceptor.java:47)
   	at org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:81)
   	at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java)
   	at com.mysql.jdbc.jdbc2.optional.MysqlPooledConnection.close(MysqlPooledConnection.java:183)
   	at com.mysql.jdbc.jdbc2.optional.JDBC4MysqlXAConnection.close(JDBC4MysqlXAConnection.java:46)
   ..."
   
   In Class ConnectionServiceMethodInterceptor?s code, line 46-47 is:
   "ConnectionInfo connectInfo = (ConnectionInfo)objInst.getSkyWalkingDynamicField();
   AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/Connection/" + method.getName(), connectInfo.getDatabasePeer());"
   
   Here it did not get connectInfo object,  got a NullPointerException. Take a breakpoint at org.skywalking.apm.plugin.jdbc.JDBCDriverInterceptor, then debug application, found it not reach this breakpoint. I judge is not intercepted Jdbc driver's methods.
   
   My demo application uses MysqlXADataSource, which is an extension of MysqlDataSource. Look at MysqlDataSource's code, instead of using jdbc.driver, it uses jdbc.NonRegisteringDriver:
   "public class MysqlDataSource extends ConnectionPropertiesImpl implements DataSource, Referenceable, Serializable {
       static final long serialVersionUID = -5515846944416881264L;
       protected final static NonRegisteringDriver mysqlDriver;
       static {
           try {
               mysqlDriver = new NonRegisteringDriver();
           } catch (Exception E) {
               throw new RuntimeException("Can not load Driver class com.mysql.jdbc.Driver");
           }
       }
   ...
   }"
   
   SkyWalking  mysql agent plugin's Class DriverInstrumentation not match com.mysql.jdbc.NonRegisteringDriver, add it to byMultiClassMatch method call:
   "return byMultiClassMatch("com.mysql.jdbc.Driver", "com.mysql.cj.jdbc.Driver", "com.mysql.jdbc.NonRegisteringDriver");"
   
   The problem is solved. No longer throw an exception, operation of database show in tracing records.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services