[ https://issues.apache.org/jira/browse/SLING-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15576600#comment-15576600 ]
Georg Henzler commented on SLING-5827: -------------------------------------- [~kwin] [~cziegeler]'s changes for SLING-5839 fixed it to use SERVICE_ID instead of SERVICE_PID (although the SERVICE_PID is still used to derive a more speaking HC name if available). Generally it's best to explicitly set the service property "hc.name" (the use of SERVICE_ID/SERVICE_PID in getHealthCheckTitle() is only a fallback mechanism) > HealthCheckMetadata wrongly assumes (String) SERVICE_PID > --------------------------------------------------------- > > Key: SLING-5827 > URL: https://issues.apache.org/jira/browse/SLING-5827 > Project: Sling > Issue Type: Bug > Components: Health Check > Affects Versions: Health Check Core 1.2.4 > Reporter: Ivo Leitão > Assignee: Bertrand Delacretaz > Priority: Critical > Fix For: Health Check Core 1.2.6 > > > I'm getting a classcastexception in the healthcheck component. This is > happenning only for my components (don't know why :-S). > I have looked at the source code and in my case at the > AsyncHelthCheckExecutor the code passes the lines bellow > {code:title=AsyncHelthCheckExecutor.java|borderStyle=solid} > ServiceReference serviceReference = event.getServiceReference(); > final boolean isHealthCheck = > serviceReference.isAssignableTo(bundleContext.getBundle(), > HealthCheck.class.getName()); > if (isHealthCheck) { > // True at my case > } > {code} > Later in the method getHealthCheckTitle of the class HealthCheckMetadata at > the line bellow: > {code:title=HealthCheckMetadata.java|borderStyle=solid} > if (StringUtils.isBlank(name)) { > name = (String) ref.getProperty(Constants.SERVICE_PID); > } > {code} > ref.getProperty(Constants.SERVICE_PID) is returning an ArrayList and I have > the stacktrace bellow as a result > {code:title=Stacktrace|borderStyle=solid} > java.lang.ClassCastException: java.util.ArrayList cannot be cast to > java.lang.String > at > org.apache.sling.hc.util.HealthCheckMetadata.getHealthCheckTitle(HealthCheckMetadata.java:146) > at > org.apache.sling.hc.util.HealthCheckMetadata.<init>(HealthCheckMetadata.java:53) > at > org.apache.sling.hc.core.impl.executor.AsyncHealthCheckExecutor.serviceChanged(AsyncHealthCheckExecutor.java:114) > at > org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:991) > at > org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:839) > at > org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:546) > at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4557) > at org.apache.felix.framework.Felix.registerService(Felix.java:3549) > at > org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348) > at > org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869) > at > org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857) > at > org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133) > at > org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915) > at > org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715) > at > org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:399) > at > org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:676) > at > org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339) > at > org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:360) > at org.apache.felix.scr.impl.Activator.access$000(Activator.java:53) > at > org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:260) > at > org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259) > at > org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232) > at > org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) > at > org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) > at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) > at > org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) > at > org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:916) > at > org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:835) > at > org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:517) > at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541) > at org.apache.felix.framework.Felix.startBundle(Felix.java:2172) > at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) > at aQute.launcher.Launcher.update(Launcher.java:482) > at aQute.launcher.Launcher.activate(Launcher.java:381) > at aQute.launcher.Launcher.run(Launcher.java:275) > at aQute.launcher.Launcher.main(Launcher.java:132) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)