You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/09/16 12:37:46 UTC

[GitHub] [incubator-shardingsphere] qihuajun opened a new issue #3045: Sharding Proxy throw NullPointerException while querying

qihuajun opened a new issue #3045: Sharding Proxy throw NullPointerException while querying
URL: https://github.com/apache/incubator-shardingsphere/issues/3045
 
 
   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   latest: 4.0.0-RC2
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   
   Sharding-Proxy
   
   ### Expected behavior
   
   Executing query without exception
   
   ### Actual behavior
   
   Almost every query I performed, though I got the query result, but there's  an error log record below in log file:
   
   ```
   [ERROR] 20:17:38.524 [ShardingSphere-Command-5] o.a.s.s.f.c.CommandExecutorTask - Exception occur:
   java.lang.NullPointerException: null
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.createConnection(JDBCBackendDataSource.java:150)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.getConnections(JDBCBackendDataSource.java:123)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnectionFromUnderlying(BackendConnection.java:189)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnectionsWithoutTransaction(BackendConnection.java:172)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnections(BackendConnection.java:141)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.callback.ProxyJDBCExecutePrepareCallback.getConnections(ProxyJDBCExecutePrepareCallback.java:56)
   	at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getSQLExecuteGroups(SQLExecutePrepareTemplate.java:89)
   	at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getSynchronizedExecuteUnitGroups(SQLExecutePrepareTemplate.java:67)
   	at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getExecuteUnitGroups(SQLExecutePrepareTemplate.java:59)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.JDBCExecuteEngine.execute(JDBCExecuteEngine.java:78)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:95)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:81)
   	at org.apache.shardingsphere.shardingproxy.backend.text.query.QueryBackendHandler.execute(QueryBackendHandler.java:54)
   	at org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:72)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:86)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:66)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   	at java.lang.Thread.run(Thread.java:748)
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   Just regular config, regular sql like `show create table` or `select * from table` can prouduce the error log above.
   
   
   Besides this bug I reported, I also found its unfriendly for developers to use Sharding Proxy:
   
   1.  the document about Sharding Proxy is too simple,  I had to read the source code to find out how to config sharding tables with self-implemented sharding algorithm
   2. No detailed error message if schema config file has error configs, here is the error message I
   got when I start Sharding Proxy with some wrong config:
   
   ```
   Exception in thread "main" Cannot create property=shardingRule for JavaBean=org.apache.shardingsphere.shardingproxy.config.yaml.YamlProxyRuleConfiguration@31304f14
    in 'reader', line 1, column 1:
       schemaName: mbase
       ^
   Cannot create property=tables for JavaBean=org.apache.shardingsphere.core.yaml.config.sharding.YamlShardingRuleConfiguration@6302bbb1
    in 'reader', line 502, column 3:
         tables:
         ^
   No single argument constructor found for class org.apache.shardingsphere.core.yaml.config.sharding.YamlTableRuleConfiguration
    in 'reader', line 503, column 5:
           brand:
           ^
   
    in 'reader', line 502, column 3:
         tables:
         ^
   
           at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:312)
           at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:189)
           at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:345)
           at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182)
           at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:141)
           at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:127)
           at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450)
           at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:410)
           at org.apache.shardingsphere.core.yaml.engine.YamlEngine.unmarshal(YamlEngine.java:59)
           at org.apache.shardingsphere.shardingproxy.config.ShardingConfigurationLoader.loadRuleConfiguration(ShardingConfigurationLoader.java:85)
           at org.apache.shardingsphere.shardingproxy.config.ShardingConfigurationLoader.load(ShardingConfigurationLoader.java:63)
           at org.apache.shardingsphere.shardingproxy.Bootstrap.main(Bootstrap.java:74)
   Caused by: Cannot create property=tables for JavaBean=org.apache.shardingsphere.core.yaml.config.sharding.YamlShardingRuleConfiguration@6302bbb1
    in 'reader', line 502, column 3:
         tables:
         ^
   No single argument constructor found for class org.apache.shardingsphere.core.yaml.config.sharding.YamlTableRuleConfiguration
    in 'reader', line 503, column 5:
           brand:
           ^
   
           at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:312)
           at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:189)
           at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:182)
           at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:297)
   ```
   with the error log above, I totally have no idea what's wrong in config file.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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