H2 2.0.202 seems not work with default jdbcadapter
manesvenom opened this issue · 3 comments
If I change the h2 database version from 1.4.200 to 2.0.202, following error message will appear:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autoConfigJdbcAdapter' defined in class path resource [org/casbin/spring/boot/autoconfigure/CasbinAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.casbin.jcasbin.persist.Adapter]: Factory method 'autoConfigJdbcAdapter' threw exception; nested exception is org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [CREATE TABLE IF NOT EXISTS casbin_rule ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ptype varchar(255) NOT NULL, v0 varchar(255) DEFAULT NULL, v1 varchar(255) DEFAULT NULL, v2 varchar(255) DEFAULT NULL, v3 varchar(255) DEFAULT NULL, v4 varchar(255) DEFAULT NULL, v5 varchar(255) DEFAULT NULL)]; nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS CASBIN_RULE ( ID INT([]11) NOT NULL AUTO_INCREMENT PRIMARY KEY, PTYPE VARCHAR(255) NOT NULL, V0 VARCHAR(255) DEFAULT NULL, V1 VARCHAR(255) DEFAULT NULL, V2 VARCHAR(255) DEFAULT NULL, V3 VARCHAR(255) DEFAULT NULL, V4 VARCHAR(255) DEFAULT NULL, V5 VARCHAR(255) DEFAULT NULL)"; expected "ARRAY, INVISIBLE, VISIBLE, NOT, NULL, AS, DEFAULT, GENERATED, ON, NOT, NULL, DEFAULT, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, COMMENT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ., )"; SQL statement:
CREATE TABLE IF NOT EXISTS casbin_rule ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ptype varchar(255) NOT NULL, v0 varchar(255) DEFAULT NULL, v1 varchar(255) DEFAULT NULL, v2 varchar(255) DEFAULT NULL, v3 varchar(255) DEFAULT NULL, v4 varchar(255) DEFAULT NULL, v5 varchar(255) DEFAULT NULL) [42001-202]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.14.jar:5.3.14]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.14.jar:5.3.14]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.2.jar:2.6.2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) [spring-boot-2.6.2.jar:2.6.2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.6.2.jar:2.6.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) [spring-boot-2.6.2.jar:2.6.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) [spring-boot-2.6.2.jar:2.6.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) [spring-boot-2.6.2.jar:2.6.2]
at org.joinfaces.example.JoinFacesExampleApplication.main(JoinFacesExampleApplication.java:35) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.6.2.jar:2.6.2]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.casbin.jcasbin.persist.Adapter]: Factory method 'autoConfigJdbcAdapter' threw exception; nested exception is org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [CREATE TABLE IF NOT EXISTS casbin_rule ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ptype varchar(255) NOT NULL, v0 varchar(255) DEFAULT NULL, v1 varchar(255) DEFAULT NULL, v2 varchar(255) DEFAULT NULL, v3 varchar(255) DEFAULT NULL, v4 varchar(255) DEFAULT NULL, v5 varchar(255) DEFAULT NULL)]; nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS CASBIN_RULE ( ID INT([]11) NOT NULL AUTO_INCREMENT PRIMARY KEY, PTYPE VARCHAR(255) NOT NULL, V0 VARCHAR(255) DEFAULT NULL, V1 VARCHAR(255) DEFAULT NULL, V2 VARCHAR(255) DEFAULT NULL, V3 VARCHAR(255) DEFAULT NULL, V4 VARCHAR(255) DEFAULT NULL, V5 VARCHAR(255) DEFAULT NULL)"; expected "ARRAY, INVISIBLE, VISIBLE, NOT, NULL, AS, DEFAULT, GENERATED, ON, NOT, NULL, DEFAULT, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, COMMENT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ., )"; SQL statement:
CREATE TABLE IF NOT EXISTS casbin_rule ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ptype varchar(255) NOT NULL, v0 varchar(255) DEFAULT NULL, v1 varchar(255) DEFAULT NULL, v2 varchar(255) DEFAULT NULL, v3 varchar(255) DEFAULT NULL, v4 varchar(255) DEFAULT NULL, v5 varchar(255) DEFAULT NULL) [42001-202]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.14.jar:5.3.14]
... 24 common frames omitted
Caused by: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [CREATE TABLE IF NOT EXISTS casbin_rule ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ptype varchar(255) NOT NULL, v0 varchar(255) DEFAULT NULL, v1 varchar(255) DEFAULT NULL, v2 varchar(255) DEFAULT NULL, v3 varchar(255) DEFAULT NULL, v4 varchar(255) DEFAULT NULL, v5 varchar(255) DEFAULT NULL)]; nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS CASBIN_RULE ( ID INT([]11) NOT NULL AUTO_INCREMENT PRIMARY KEY, PTYPE VARCHAR(255) NOT NULL, V0 VARCHAR(255) DEFAULT NULL, V1 VARCHAR(255) DEFAULT NULL, V2 VARCHAR(255) DEFAULT NULL, V3 VARCHAR(255) DEFAULT NULL, V4 VARCHAR(255) DEFAULT NULL, V5 VARCHAR(255) DEFAULT NULL)"; expected "ARRAY, INVISIBLE, VISIBLE, NOT, NULL, AS, DEFAULT, GENERATED, ON, NOT, NULL, DEFAULT, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, COMMENT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ., )"; SQL statement:
CREATE TABLE IF NOT EXISTS casbin_rule ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ptype varchar(255) NOT NULL, v0 varchar(255) DEFAULT NULL, v1 varchar(255) DEFAULT NULL, v2 varchar(255) DEFAULT NULL, v3 varchar(255) DEFAULT NULL, v4 varchar(255) DEFAULT NULL, v5 varchar(255) DEFAULT NULL) [42001-202]
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239) ~[spring-jdbc-5.3.14.jar:5.3.14]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) ~[spring-jdbc-5.3.14.jar:5.3.14]
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1541) ~[spring-jdbc-5.3.14.jar:5.3.14]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:393) ~[spring-jdbc-5.3.14.jar:5.3.14]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:431) ~[spring-jdbc-5.3.14.jar:5.3.14]
at org.casbin.adapter.JdbcAdapter.initTable(JdbcAdapter.java:113) ~[casbin-spring-boot-starter-0.4.0.jar:na]
at org.casbin.adapter.JdbcAdapter.(JdbcAdapter.java:68) ~[casbin-spring-boot-starter-0.4.0.jar:na]
at org.casbin.spring.boot.autoconfigure.CasbinAutoConfiguration.autoConfigJdbcAdapter(CasbinAutoConfiguration.java:97) ~[casbin-spring-boot-starter-0.4.0.jar:na]
at org.casbin.spring.boot.autoconfigure.CasbinAutoConfiguration$$EnhancerBySpringCGLIB$$6afe6f40.CGLIB$autoConfigJdbcAdapter$0() ~[casbin-spring-boot-starter-0.4.0.jar:na]
at org.casbin.spring.boot.autoconfigure.CasbinAutoConfiguration$$EnhancerBySpringCGLIB$$6afe6f40$$FastClassBySpringCGLIB$$76092b9e.invoke() ~[casbin-spring-boot-starter-0.4.0.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.14.jar:5.3.14]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.14.jar:5.3.14]
at org.casbin.spring.boot.autoconfigure.CasbinAutoConfiguration$$EnhancerBySpringCGLIB$$6afe6f40.autoConfigJdbcAdapter() ~[casbin-spring-boot-starter-0.4.0.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.14.jar:5.3.14]
... 25 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS CASBIN_RULE ( ID INT([]11) NOT NULL AUTO_INCREMENT PRIMARY KEY, PTYPE VARCHAR(255) NOT NULL, V0 VARCHAR(255) DEFAULT NULL, V1 VARCHAR(255) DEFAULT NULL, V2 VARCHAR(255) DEFAULT NULL, V3 VARCHAR(255) DEFAULT NULL, V4 VARCHAR(255) DEFAULT NULL, V5 VARCHAR(255) DEFAULT NULL)"; expected "ARRAY, INVISIBLE, VISIBLE, NOT, NULL, AS, DEFAULT, GENERATED, ON, NOT, NULL, DEFAULT, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, COMMENT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ., )"; SQL statement:
CREATE TABLE IF NOT EXISTS casbin_rule ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ptype varchar(255) NOT NULL, v0 varchar(255) DEFAULT NULL, v1 varchar(255) DEFAULT NULL, v2 varchar(255) DEFAULT NULL, v3 varchar(255) DEFAULT NULL, v4 varchar(255) DEFAULT NULL, v5 varchar(255) DEFAULT NULL) [42001-202]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) ~[h2-2.0.202.jar:2.0.202]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) ~[h2-2.0.202.jar:2.0.202]
at org.h2.message.DbException.getSyntaxError(DbException.java:261) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.getSyntaxError(Parser.java:1286) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.read(Parser.java:6099) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.readIfMore(Parser.java:1656) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.parseCreateTable(Parser.java:10337) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.parseCreate(Parser.java:7803) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.parsePrepared(Parser.java:1140) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.parse(Parser.java:1068) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.parse(Parser.java:1041) ~[h2-2.0.202.jar:2.0.202]
at org.h2.command.Parser.prepareCommand(Parser.java:965) ~[h2-2.0.202.jar:2.0.202]
at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:614) ~[h2-2.0.202.jar:2.0.202]
at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:552) ~[h2-2.0.202.jar:2.0.202]
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1111) ~[h2-2.0.202.jar:2.0.202]
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:237) ~[h2-2.0.202.jar:2.0.202]
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223) ~[h2-2.0.202.jar:2.0.202]
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-4.0.3.jar:na]
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-4.0.3.jar:na]
at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422) ~[spring-jdbc-5.3.14.jar:5.3.14]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:381) ~[spring-jdbc-5.3.14.jar:5.3.14]
... 39 common frames omitted
Or It is related to Hibernate ORM:H2 version 2.0.202 )auto_increment not working
@manesvenom A syntax error occurred in the table init statement of H2 database and has been resolved by #62.