Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.yaml.snakeyaml.representer.Representer: method 'void <init>()' not found #30815

Closed
chrismayday opened this issue Apr 9, 2024 · 18 comments
Closed
Assignees
Labels
in: configuration type: dependencies Pull requests that update a dependency file type: duplicate

Comments

@chrismayday
Copy link

chrismayday commented Apr 9, 2024

How to use shardingsphere jdbc version 5.4.1 and springboot 3.1.4 to implement data sharding?

error info:

java.lang.NoSuchMethodError: org.yaml.snakeyaml.representer.Representer: method 'void ()' not found
at org.apache.shardingsphere.infra.util.yaml.representer.ShardingSphereYamlRepresenter.(ShardingSphereYamlRepresenter.java:42)
at org.apache.shardingsphere.infra.util.yaml.YamlEngine.marshal(YamlEngine.java:113)
at org.apache.shardingsphere.mode.metadata.persist.service.config.global.PropertiesPersistService.persist(PropertiesPersistService.java:45)
at org.apache.shardingsphere.mode.metadata.persist.service.config.global.PropertiesPersistService.conditionalPersist(PropertiesPersistService.java:39)
at org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService.persistConfigurations(MetaDataPersistService.java:86)
at org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.persistConfigurations(StandaloneContextManagerBuilder.java:61)
at org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:50)
at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:77)
at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.(ShardingSphereDataSource.java:65)
at org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:93)
at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:153)
at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:95)
at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.createDataSource(DriverDataSourceCache.java:51)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.get(DriverDataSourceCache.java:45)
at org.apache.shardingsphere.driver.ShardingSphereDriver.connect(ShardingSphereDriver.java:51)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:100)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:348)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:89)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:64)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:336)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:158)
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
at jdk.proxy2/jdk.proxy2.$Proxy100.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:154)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:142)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425)
at jdk.proxy2/jdk.proxy2.$Proxy84.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:164)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:152)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at jdk.proxy2/jdk.proxy2.$Proxy88.selectList(Unknown Source)

yaml config_info

image

version info:
SpringB Version : 3.1.4
JDK : jdk21
snakeyaml : 2.2
shardingsphere-jdbc-core: 5.4.1
mybatis-plus-spring-boot3-starter : 3.5.5

@linghengqian
Copy link
Member

@linghengqian linghengqian added type: duplicate type: dependencies Pull requests that update a dependency file labels Apr 9, 2024
@chrismayday
Copy link
Author

@linghengqian
Copy link
Member

  • The answer is that it doesn't make sense. shardingsphere uses methods that were removed in snakeyaml 2.0. So you have to either downgrade to snakeyaml 1.33 or manually compile the shardingsphere master branch. See 5.4.1 yaml Dependency #30318 (comment) .

@linghengqian
Copy link
Member

  • In short, you can try explicitly specifying the snakeyaml version in maven. The 3.0.x branch of spring-boot retains some unit tests for serving snakeyaml 1.33.
<dependency>
    <groupId>org.yaml</groupId>
    <artifactId>snakeyaml</artifactId>
    <version>1.33</version>
</dependency>

@chrismayday
Copy link
Author

  • In short, you can try explicitly specifying the snakeyaml version in maven. The 3.0.x branch of spring-boot retains some unit tests for serving snakeyaml 1.33.
<dependency>
    <groupId>org.yaml</groupId>
    <artifactId>snakeyaml</artifactId>
    <version>1.33</version>
</dependency>

OK。Will it be fixed in version 5.4.2?

@linghengqian
Copy link
Member

  • With snakeyaml 2.2 in shardingsphere 5.4.2-SNAPSHOT/5.5.0, there is no need to explicitly specify the snakeyaml version, unless you are using third-party dependencies that are using the deleted snakeyaml java api.

@chrismayday
Copy link
Author

  • 对于shardingsphere 5.4.2-SNAPSHOT/5.5.0中的snakeyaml 2.2,无需显式指定snakeyaml版本,除非您使用的第三方依赖项正在使用已删除的snakeyaml java api。
    image
    image
    image
    I would like to ask what is causing this problem. Is it a configuration problem?
    grateful

@linghengqian
Copy link
Member

  • Without an example git with unit tests, I have a hard time understanding the picture, and I don't have an ocr tool to identify logs to text. I suggest you rewrite the unit tests to h2database or testcontainers-java, and open a new issue.

@chrismayday
Copy link
Author

  • 如果没有带有单元测试的示例 git,我很难理解图片,而且我没有 ocr 工具来识别日志到文本。我建议你将单元测试重写为 h2database 或 testcontainers-java,并打开一个新问题。

https://github.com/chrismayday/demo-sharding/blob/main/src/test/java/com/example/demo/DemoApplicationTests.java
Under this demo project
grateful

@linghengqian
Copy link
Member

  • You need to provide the SQL file that initializes the database and remove the suspicious jdbcURL. Referring to the documentation for testcontainers-java or h2database, this looks like an external issue.

@chrismayday
Copy link
Author

@linghengqian linghengqian self-assigned this Apr 9, 2024
@chrismayday
Copy link
Author

self-assigned this
I would like to ask if it is a problem with mybatis-plus, or if there is a configuration problem somewhere.

@linghengqian
Copy link
Member

  1. Your rules[1].tables.analytics_event.actualDataNodes is not a legal GroovyShell expression, it looks like there is an extra }. Refer to https://shardingsphere.apache.org/document/current/en/user-manual/common-config/builtin-algorithm/expr/ .
  2. Your rules[1].shardingAlgorithms.analytics_event_inline.props.algorithm-expression seems to expect to continue to configure the Sharding table on the logical database configured with Read/write splitting, but the context of algorithm-expression actually only knows actual table name, it doesn't know the logical or actual database name. You can try debugging into the algorithm class.

@linghengqian linghengqian removed their assignment Apr 9, 2024
@chrismayday
Copy link
Author

  1. 您的rules[1].tables.analytics_event.actualDataNodes不是合法的 GroovyShell 表达式,看起来有一个额外的}.请参阅https://shardingsphere.apache.org/document/current/en/user-manual/common-config/builtin-algorithm/expr/。
  2. rules[1].shardingAlgorithms.analytics_event_inline.props.algorithm-expression似乎期望继续在配置的Sharding表上配置表,但上下文实际上只知道名称,它不知道名称。您可以尝试调试算法类。logical database``Read/write splitting``algorithm-expression``actual table``logical or actual database

ok ,solved
Thank you so much

@James-Zou
Copy link

  • With snakeyaml 2.2 in shardingsphere 5.4.2-SNAPSHOT/5.5.0, there is no need to explicitly specify the snakeyaml version, unless you are using third-party dependencies that are using the deleted snakeyaml java api.

When was version 5.4.2 released?

@linghengqian
Copy link
Member

linghengqian commented Apr 12, 2024

When was version 5.4.2 released?

  • If you expect a faster release, you should leave a message in the mail thread at https://lists.apache.org/[email protected] .

  • As a committer, I personally only have non-binding release voting right. In any case, according to ASF regulations, the release process must be completed on the mailing list, which has nothing to do with github.com.

Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

@github-actions github-actions bot added the stale label May 12, 2024
@linghengqian
Copy link
Member

Closed due to no response.

@linghengqian linghengqian self-assigned this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: configuration type: dependencies Pull requests that update a dependency file type: duplicate
Projects
None yet
Development

No branches or pull requests

3 participants