我是在我们公司中第一次配置togglz JDBCStateRepository。
在我从InMemoryStateRepository转换为JDBCStateRepository的第一个项目中,项目组合为:
春季启动项目
oracle数据库
为“表名”指定的现有模式和新表
我利用
<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。
有人遇到过吗?有办法解决吗?
最佳答案
Togglz的作者在这里。
这显然看起来像个错误。那么,为什么不在Togglz问题跟踪器中为此打开问题?您可以找到它here。当然也可以提出拉动请求来解决此问题。
但是,与此同时,您可以简单地禁用自动模式迁移功能并自己创建表。构建器中有an option可以执行此操作。
关于java - Togglz JDBCStateRepository在DB2中自动创建格式错误的表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44417735/