Aled Sage created BROOKLYN-410:
----------------------------------

             Summary: Rebind fails in karaf, with app creating location from 
class in bundle
                 Key: BROOKLYN-410
                 URL: https://issues.apache.org/jira/browse/BROOKLYN-410
             Project: Brooklyn
          Issue Type: Bug
            Reporter: Aled Sage


With brooklyn 0.10.0-SNAPSHOT...

A customer has an advanced/unusual Java-based app that programmatically adds a 
location to an entity. They are switching to using karaf.

The app deploys successfully. However, on rebind it fails because it fails to 
instantiate the location (fails to load the class for the location).

I reproduced this with a simpler test case - output shown below:

{noformat}
2016-12-14 13:49:16,912 WARN  Rebind: continuing after problem creating 
LOCATION pjt0hzet8u of type com.acme.autobrick:com.acme.location.MyLocation
org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
        at 
org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:129) 
~[classes/:na]
Caused by: java.lang.ClassNotFoundException: Class 
com.acme.autobrick:com.acme.location.MyLocation not found on the application 
class path, nor in the bundle white list.
        at 
org.apache.brooklyn.util.core.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:155)
 ~[classes/:na]

...

org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Failure 
rebinding: problem creating LOCATION pjt0hzet8u of type 
com.acme.autobrick:com.acme.location.MyLocation: ClassNotFoundException: Class 
com.acme.autobrick:com.acme.location.MyLocation not found on the application 
class path, nor in the bundle white list.
        at 
org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:129)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebind(RebindManagerImpl.java:513)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils.rebindAll(RebindTestUtils.java:457)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils.rebind(RebindTestUtils.java:334)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindTestFixture.rebind(RebindTestFixture.java:303)
        at 
org.apache.brooklyn.camp.brooklyn.AbstractYamlRebindTest.rebind(AbstractYamlRebindTest.java:87)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindTestFixture.rebind(RebindTestFixture.java:238)
        at 
org.apache.brooklyn.camp.brooklyn.catalog.CatalogOsgiVersionMoreEntityRebindTest.testFoo(CatalogOsgiVersionMoreEntityRebindTest.java:143)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at 
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
        at 
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
        at org.testng.TestRunner.privateRun(TestRunner.java:782)
        at org.testng.TestRunner.run(TestRunner.java:632)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
        at org.testng.SuiteRunner.run(SuiteRunner.java:268)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
        at org.testng.TestNG.run(TestNG.java:1064)
        at 
org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.util.concurrent.ExecutionException: 
org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Failure 
rebinding: problem creating LOCATION pjt0hzet8u of type 
com.acme.autobrick:com.acme.location.MyLocation: ClassNotFoundException: Class 
com.acme.autobrick:com.acme.location.MyLocation not found on the application 
class path, nor in the bundle white list.
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:188)
        at 
com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
        at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebind(RebindManagerImpl.java:511)
        ... 30 more
Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
Failure rebinding: problem creating LOCATION pjt0hzet8u of type 
com.acme.autobrick:com.acme.location.MyLocation: ClassNotFoundException: Class 
com.acme.autobrick:com.acme.location.MyLocation not found on the application 
class path, nor in the bundle white list.
        at 
org.apache.brooklyn.util.exceptions.Exceptions.create(Exceptions.java:432)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDoneImpl(RebindExceptionHandlerImpl.java:497)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDone(RebindExceptionHandlerImpl.java:413)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:268)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:558)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:508)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:506)
        at 
org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:522)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: problem creating LOCATION 
pjt0hzet8u of type com.acme.autobrick:com.acme.location.MyLocation
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onCreateFailed(RebindExceptionHandlerImpl.java:265)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration.instantiateLocationsAndEntities(RebindIteration.java:441)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration.doRun(RebindIteration.java:240)
        at 
org.apache.brooklyn.core.mgmt.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:266)
        ... 8 more
Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
ClassNotFoundException: Class com.acme.autobrick:com.acme.location.MyLocation 
not found on the application class path, nor in the bundle white list.
        at 
org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:129)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.loadClass(RebindIteration.java:999)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.newLocation(RebindIteration.java:1007)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration.instantiateLocationsAndEntities(RebindIteration.java:438)
        ... 11 more
Caused by: java.lang.ClassNotFoundException: Class 
com.acme.autobrick:com.acme.location.MyLocation not found on the application 
class path, nor in the bundle white list.
        at 
org.apache.brooklyn.util.core.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:155)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.loadClass(RebindIteration.java:991)
        at 
org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.loadClass(RebindIteration.java:997)
        ... 13 more
{noformat}

Looking at the persisted state for the location, it looks good: 
{{<type>com.acme.autobrick:com.acme.location.MyLocation</type>}} and 
{{<catalogItemId>with-private-location:1.0</catalogItemId>}}.

Looking at the code path in the stacktrace above, the loading of locations 
differs from entities. That calls 
{{RebindIteration.BrooklynObjectInstantiator.load()}}, which tries to use the 
catalog id. However, for locations it calls straight to 
{{RebindIteration.BrooklynObjectInstantiator.loadClass()}}, which does not 
respect the catalog id.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to