I am configuring a togglz JDBCStateRepository for the first time in our company.
On the first project I converted from InMemoryStateRepository to JDBCStateRepository the project mix was:
- spring boot project
- oracle database
- already existing schema and new table specified for "table name"
I utilized
<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>
Everything worked correctly automatically.
On the second project I converted the InMemoryStateRepository to JDBCStateRepository and the project mix was:
- plain spring project (not spring boot)
- DB2 database
- new schema and new table specified for "table name"
I utilized
<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>
and upon hitting the togglz index page I get the following exception:
[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
With the important part being:
Caused by: com.ibm.db2.jcc.a.fn: DB2 SQL Error: SQLCODE=-542, SQLSTATE=42831, SQLERRMC=FEATURE_NAME, DRIVER=4.1.85
The definition of this SQLCODE and SQLSTATE can be found here: https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/codes/src/tpc/n542.html
In which it states:
-542 column-name CANNOT BE A COLUMN OF A HASH KEY, PRIMARY KEY, A UNIQUE CONSTRAINT, OR A PARENT KEY BECAUSE IT CAN CONTAIN NULL VALUES
In other words it appears togglz is trying to create a table in which the column name "FEATURE_NAME" is both nullable and has a primary key or unique constraint on. When I reference the table created in my first project, the column "FEATURE_NAME" is non nullable and marked as a primary key. The only differences in the second project is the togglz-core vs togglz-spring-boot-starter and oracle vs db2.
Has anyone encountered this? Are there ways around this?