我在我们公司第一次配置一个togglz JDBCStateRepository。
在我从 InMemoryStateRepository 转换为 JDBCStateRepository 的第一个项目中,项目组合是:
- 春季启动项目
- 甲骨文数据库
- 已为“表名”指定的现有架构和新表
我利用
<dependency>
<groupId>org.togglz</groupId>
<artifactId>togglz-spring-boot-starter</artifactId>
<version>2.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.togglz</groupId>
<artifactId>togglz-console</artifactId>
<version>2.4.1.Final</version>
</dependency>
一切都自动正常工作。
在第二个项目中,我将 InMemoryStateRepository 转换为 JDBCStateRepository,项目组合为:
- 普通的弹簧项目(不是弹簧靴)
- DB2 数据库
- 为“表名”指定的新模式和新表
我利用
<dependency>
<groupId>org.togglz</groupId>
<artifactId>togglz-core</artifactId>
<version>2.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.togglz</groupId>
<artifactId>togglz-console</artifactId>
<version>2.4.1.Final</version>
</dependency>
在点击 togglz 索引页面时,我得到以下异常:
[6/7/17 10:25:55:672 EDT] 000000c4 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: An exception was thrown by one of the service methods of the servlet [TogglzConsoleServlet] in application [pp_dial2_issuance_pub]. Exception created : [java.lang.IllegalStateException: Failed to migrate the database schema
at org.togglz.core.repository.jdbc.JDBCStateRepository.migrateSchema(JDBCStateRepository.java:184)
at org.togglz.core.repository.jdbc.JDBCStateRepository.<init>(JDBCStateRepository.java:152)
at org.togglz.core.repository.jdbc.JDBCStateRepository.<init>(JDBCStateRepository.java:96)
at com.lmig.ci.policy.publisher.issuance.togglz.ToggleFMP.getFeatureManager(ToggleFMP.java:41)
at org.togglz.core.context.FeatureContext.findFeatureManagerInClassLoader(FeatureContext.java:108)
at org.togglz.core.context.FeatureContext.getFeatureManagerOrNull(FeatureContext.java:74)
at org.togglz.core.context.FeatureContext.getFeatureManager(FeatureContext.java:47)
at org.togglz.core.manager.LazyResolvingFeatureManager.getDelegate(LazyResolvingFeatureManager.java:24)
at org.togglz.core.manager.LazyResolvingFeatureManager.getCurrentFeatureUser(LazyResolvingFeatureManager.java:49)
at org.togglz.console.TogglzConsoleServlet.isFeatureAdmin(TogglzConsoleServlet.java:75)
at org.togglz.console.TogglzConsoleServlet.service(TogglzConsoleServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1232)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:781)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:480)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
at org.togglz.servlet.TogglzFilter.doFilter(TogglzFilter.java:100)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3928)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1007)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1881)
Caused by: com.ibm.db2.jcc.a.fn: DB2 SQL Error: SQLCODE=-542, SQLSTATE=42831, SQLERRMC=FEATURE_NAME, DRIVER=4.1.85
at com.ibm.db2.jcc.a.yc.a(yc.java:592)
at com.ibm.db2.jcc.a.yc.a(yc.java:60)
at com.ibm.db2.jcc.a.yc.a(yc.java:127)
at com.ibm.db2.jcc.a.il.c(il.java:1914)
at com.ibm.db2.jcc.a.il.d(il.java:1902)
at com.ibm.db2.jcc.a.il.b(il.java:1369)
at com.ibm.db2.jcc.t4.db.h(db.java:219)
at com.ibm.db2.jcc.t4.db.b(db.java:45)
at com.ibm.db2.jcc.t4.t.b(t.java:38)
at com.ibm.db2.jcc.t4.sb.g(sb.java:120)
at com.ibm.db2.jcc.a.il.P(il.java:1364)
at com.ibm.db2.jcc.a.il.a(il.java:2261)
at com.ibm.db2.jcc.a.il.c(il.java:614)
at com.ibm.db2.jcc.a.il.executeUpdate(il.java:598)
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.pmiExecuteUpdate(WSJdbcStatement.java:1804)
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeUpdate(WSJdbcStatement.java:1135)
at org.togglz.core.repository.jdbc.SchemaUpdater.execute(SchemaUpdater.java:135)
at org.togglz.core.repository.jdbc.SchemaUpdater.migrateToVersion1(SchemaUpdater.java:39)
at org.togglz.core.repository.jdbc.JDBCStateRepository.migrateSchema(JDBCStateRepository.java:170)
... 37 more
重要的部分是:
原因:com.ibm.db2.jcc.a.fn:DB2 SQL 错误:SQLCODE=-542,SQLSTATE=42831,SQLERRMC=FEATURE_NAME,DRIVER=4.1.85
这个 SQLCODE 和 SQLSTATE 的定义可以在这里找到: https ://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/codes/src/tpc/n542.html
其中指出:
-542 列名不能是哈希键、主键、唯一约束或父键的列,因为它可以包含空值
换句话说,togglz 似乎正在尝试创建一个表,其中列名“FEATURE_NAME”既可以为空,又具有主键或唯一约束。当我引用在我的第一个项目中创建的表时,“FEATURE_NAME”列不可为空并标记为主键。第二个项目的唯一区别是 togglz-core vs togglz-spring-boot-starter 和 oracle vs db2。
有没有人遇到过这个?有没有办法解决这个问题?