You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "lt-dh (via GitHub)" <gi...@apache.org> on 2024/04/18 08:53:51 UTC
[I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
lt-dh opened a new issue, #30945:
URL: https://github.com/apache/shardingsphere/issues/30945
all my config:
```
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.9</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.9</version>
<scope>runtime</scope>
</dependency>
```
yaml is as follows:
```
spring:
datasource:
driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
url: jdbc:shardingsphere:classpath:sharding-jdbc.yml
----------------------------------------------------------------------------------------
# Ignore other configurations
dataSources:
master:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://192.168.xx.xx:3306/xxx?
username: root
password: root
```
1. I don't want to use version 1.33 of snackyaml
2. I tried using the java api to config but it didn't work,same error as above
3. I tried this,and i got shardingsphere-jdbc:5.4.2-SNAPSHOT :
```
git clone git@github.com:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw clean install -Prelease -T1C -DskipTests -Djacoco.skip=true -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -B
```
I tried again,yaml configuration is still used:
```
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc</artifactId>
<version>5.4.2-SNAPSHOT</version>
</dependency>
```
I got this error:
> java.lang.ExceptionInInitializerError
at org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilder.build(SystemSchemaBuilder.java:62)
at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:109)
at org.apache.shardingsphere.metadata.factory.ExternalMetaDataFactory.createSystemDatabases(ExternalMetaDataFactory.java:96)
at org.apache.shardingsphere.metadata.factory.ExternalMetaDataFactory.create(ExternalMetaDataFactory.java:73)
at org.apache.shardingsphere.mode.metadata.NewMetaDataContextsFactory.create(NewMetaDataContextsFactory.java:99)
at org.apache.shardingsphere.mode.metadata.NewMetaDataContextsFactory.create(NewMetaDataContextsFactory.java:73)
at org.apache.shardingsphere.mode.manager.standalone.NewStandaloneContextManagerBuilder.build(NewStandaloneContextManagerBuilder.java:54)
at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:79)
at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:67)
at org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:95)
at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:135)
at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:70)
at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.createDataSource(DriverDataSourceCache.java:55)
at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.lambda$get$0(DriverDataSourceCache.java:48)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.get(DriverDataSourceCache.java:48)
at org.apache.shardingsphere.driver.ShardingSphereDriver.connect(ShardingSphereDriver.java:55)
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.<init>(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.doUpdate(SimpleExecutor.java:49)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
at jdk.proxy2/jdk.proxy2.$Proxy170.update(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425)
at jdk.proxy2/jdk.proxy2.$Proxy94.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
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.$Proxy99.insert(Unknown Source)
at com.baomidou.mybatisplus.extension.service.IService.save(IService.java:60)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:351)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:713)
at com.ultrapower.mysql.service.impl.CorePortServiceImpl$$SpringCGLIB$$0.save(<generated>)
at ShardingTest.insert(ShardingTest.java:23)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
at org.apache.shardingsphere.infra.metadata.database.schema.manager.SystemSchemaManager.lambda$static$2(SystemSchemaManager.java:57)
at java.base/java.util.stream.Collectors.lambda$groupingBy$53(Collectors.java:1142)
at java.base/java.util.stream.Collectors.lambda$groupingBy$53(Collectors.java:1144)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.apache.shardingsphere.infra.metadata.database.schema.manager.SystemSchemaManager.<clinit>(SystemSchemaManager.java:56)
What should I do next .Somebody help me .thank you.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
Posted by "lt-dh (via GitHub)" <gi...@apache.org>.
lt-dh commented on issue #30945:
URL: https://github.com/apache/shardingsphere/issues/30945#issuecomment-2068309721
@linghengqian Thank you for your answer
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #30945:
URL: https://github.com/apache/shardingsphere/issues/30945#issuecomment-2065836066
- This is actually because https://github.com/apache/shardingsphere/blob/0ab150a1e435ce58792311ff0a0d3a878d6b3817/infra/util/src/main/java/org/apache/shardingsphere/infra/util/directory/ClasspathResourceDirectoryReader.java is using `Thread.currentThread().getContextClassLoader()`, rather than the class's own ClassLoader. This caused it to be incorrectly parsed to the fastjson2 folder.
- I believe this will have to require you to temporarily remove your use of fastjson2.
- @iamhucong It looks like this class was refactored by you, should the fix for this be put into the 5.5.0-release branch? Or just keep it in the master branch?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #30945:
URL: https://github.com/apache/shardingsphere/issues/30945#issuecomment-2063528028
- Can you provide a reproducible git containing unit tests? The log on 5.4.2-SNAPSHOT seems to be a YAML configuration writing problem. Reference https://github.com/apache/shardingsphere/tree/master/test%2Fnative%2Fsrc%2Ftest%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Ftest%2Fnatived%2Fjdbc%2Fdatabases
- Both testcontainers-java and h2database are available.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #30945:
URL: https://github.com/apache/shardingsphere/issues/30945#issuecomment-2066852213
- @lt-dh You seem to be using an older version, wasn't this issue fixed by #30415?
```
sdk install java 21.0.2-graalce
sdk use java 21.0.2-graalce
git clone git@github.com:apache/shardingsphere.git
cd ./shardingsphere/
git reset --hard 3b88c08e726119d955b6a6d3809072e836c5ab3d
./mvnw clean install -Prelease -T1C -DskipTests -Djacoco.skip=true -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #30945:
URL: https://github.com/apache/shardingsphere/issues/30945#issuecomment-2076750202
- Since there is nothing to do with the current issue, it is closed.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian closed issue #30945: i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void <init>()' not found"
URL: https://github.com/apache/shardingsphere/issues/30945
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] i use "jdk17、spring-boot:3.2.3、shardingsphere-jdbc-core:5.4.1" and i got "org.yaml.snakeyaml.representer.Representer: method 'void ()' not found" [shardingsphere]
Posted by "lt-dh (via GitHub)" <gi...@apache.org>.
lt-dh commented on issue #30945:
URL: https://github.com/apache/shardingsphere/issues/30945#issuecomment-2065692957
> * Can you provide a reproducible git containing unit tests? The log on 5.4.2-SNAPSHOT seems to be a YAML configuration writing problem. Reference https://github.com/apache/shardingsphere/tree/master/test%2Fnative%2Fsrc%2Ftest%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Ftest%2Fnatived%2Fjdbc%2Fdatabases
> * Both testcontainers-java and h2database are available.
I found when calling ClasspathResourceDirectoryReader.read() , it will read to com/alibaba/fastjson2 / fastjson2/2.0.47 / fastjson2-2.0.47. Jar! /schema/ and the static code in SystemSchemaManager:
```
static {
List<String> resourceNames;
try (Stream<String> resourceNameStream = ClasspathResourceDirectoryReader.read("schema")) {
resourceNames = resourceNameStream.collect(Collectors.toList());
}
DATABASE_TYPE_SCHEMA_TABLE_MAP = resourceNames.stream().map(resourceName -> resourceName.split("/")).collect(Collectors.groupingBy(path -> path[1], CaseInsensitiveMap::new,
Collectors.groupingBy(path -> path[2], CaseInsensitiveMap::new, Collectors.mapping(path -> StringUtils.removeEnd(path[3], ".yaml"),
Collectors.toCollection(CaseInsensitiveSet::new)))));
DATABASE_TYPE_SCHEMA_RESOURCE_MAP = resourceNames.stream().map(resourceName -> resourceName.split("/")).collect(Collectors.groupingBy(path -> path[1], CaseInsensitiveMap::new,
Collectors.groupingBy(path -> path[2], CaseInsensitiveMap::new, Collectors.mapping(path -> String.join("/", path),
Collectors.toCollection(CaseInsensitiveSet::new)))));
}
```
resourceNames will contations ["schema/2020-12.json","schema/draft-04.json"].
I think that's the problem,.Whether filter() should be added to the code.
and what do you suggest I do to use sharding.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org