Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
When testing rebind with 0.11.0 RC1 against historic persisted state, we saw the exception below:
Caused by: org.apache.brooklyn.util.exceptions.CompoundRuntimeException: Failure rebinding; 2 errors including: problem creating POLICY lplpmv3goo of type org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsembleImpl$MemberTrackingPolicy: Cannot instantiate instance of type class org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsembleImpl$MemberTrackingPolicy; expected constructor signature not found (args are [{id=lplpmv3goo, deferConstructionChecks=true, noConstructionInit=true, group=ZooKeeperEnsembleImpl{id=stkwkmp76w}, uniqueTag=MemberTrackingPolicy:ZooKeeperEnsembleImpl{id=stkwkmp76w}, tags=[]}]) at org.apache.brooklyn.util.exceptions.Exceptions.create(Exceptions.java:474)[141:org.apache.brooklyn.utils-common:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDoneImpl(RebindExceptionHandlerImpl.java:498)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDone(RebindExceptionHandlerImpl.java:414)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:267)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:560)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:510)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:508)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:529)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] ... 4 more Caused by: java.lang.IllegalStateException: problem creating POLICY lplpmv3goo of type org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsembleImpl$MemberTrackingPolicy at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onCreateFailed(RebindExceptionHandlerImpl.java:265)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.instantiateAdjuncts(RebindIteration.java:484)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.doRun(RebindIteration.java:241)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:265)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] ... 8 more Caused by: java.lang.IllegalStateException: Cannot instantiate instance of type class org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsembleImpl$MemberTrackingPolicy; expected constructor signature not found (args are [{id=lplpmv3goo, deferConstructionChecks=true, noConstructionInit=true, group=ZooKeeperEnsembleImpl{id=stkwkmp76w}, uniqueTag=MemberTrackingPolicy:ZooKeeperEnsembleImpl{id=stkwkmp76w}, tags=[]}]) at org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.invokeConstructor(RebindIteration.java:1157)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.newPolicy(RebindIteration.java:1061)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.instantiateAdjuncts(RebindIteration.java:481)[120:org.apache.brooklyn.core:0.11.0.SNAPSHOT] ... 11 more
The problem is that persisted state refers to an instance of org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsembleImpl$MemberTrackingPolicy, which has since been made a private class. The no-arg constructor is therefore not directly accessible, which leads us down the wrong code path.
The generalise advice would be to ensure that the class for anything in persisted state has a public no-arg constructor.
A general fix would be to use getDeclaredConsturctor(new Class[0]) (so we get the private constructor), and then to call the constructor after doing constructor.setAccessible(true).
We should also add a public no-arg constructors to ZooKeeperEnsembleImpl$MemberTrackingPolicy (which only exists for backwards compatibility).
Attachments
Issue Links
- relates to
-
BROOKLYN-473 Brooklyn 0.11.0 RC1 fails to rebind to state from 0.9.0
- Resolved
- links to