[Sloved][Q] Custom addon. ClassCastException while saving addon settings

Solution: You can’t use xml <reference field=""> just use xml <reference bind=""> for dependency injection.
Imho there is still a bug in ESH as per osgi spec 1.3 service can have multiple service.pid values
///-- original question
Hello,
After config is saved I get HTTP 500 curl 'http://localhost:8080/rest/services
with json

{"error":{"message":"java.util.ArrayList cannot be cast to java.lang.String","http-code":500,"exception":{"class":"java.lang.ClassCastException","message":"java.util.ArrayList cannot be cast to java.lang.String","localized-message":"java.util.ArrayList cannot be cast to java.lang.String"}}}

And indeed local var pid in ConfigurableServiceResource#getServiceId() is ArrayList,
serviceReference.getProperty("service.pid") returns list of two strings

Full Stacktrace

getServiceId:232, ConfigurableServiceResource (org.eclipse.smarthome.io.rest.core.internal.service)
getConfigurableServices:214, ConfigurableServiceResource (org.eclipse.smarthome.io.rest.core.internal.service)
getAll:93, ConfigurableServiceResource (org.eclipse.smarthome.io.rest.core.internal.service)
invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
invoke:62, NativeMethodAccessorImpl (sun.reflect)
invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
invoke:498, Method (java.lang.reflect)
invoke:81, ResourceMethodInvocationHandlerFactory$1 (org.glassfish.jersey.server.model.internal)
run:144, AbstractJavaResourceMethodDispatcher$1 (org.glassfish.jersey.server.model.internal)
invoke:161, AbstractJavaResourceMethodDispatcher (org.glassfish.jersey.server.model.internal)
doDispatch:205, JavaResourceMethodDispatcherProvider$TypeOutInvoker (org.glassfish.jersey.server.model.internal)
dispatch:99, AbstractJavaResourceMethodDispatcher (org.glassfish.jersey.server.model.internal)
invoke:389, ResourceMethodInvoker (org.glassfish.jersey.server.model)
apply:347, ResourceMethodInvoker (org.glassfish.jersey.server.model)
apply:102, ResourceMethodInvoker (org.glassfish.jersey.server.model)
run:326, ServerRuntime$2 (org.glassfish.jersey.server)
call:271, Errors$1 (org.glassfish.jersey.internal)
call:267, Errors$1 (org.glassfish.jersey.internal)
process:315, Errors (org.glassfish.jersey.internal)
process:297, Errors (org.glassfish.jersey.internal)
process:267, Errors (org.glassfish.jersey.internal)
runInScope:317, RequestScope (org.glassfish.jersey.process.internal)
process:305, ServerRuntime (org.glassfish.jersey.server)
handle:1154, ApplicationHandler (org.glassfish.jersey.server)
serviceImpl:473, WebComponent (org.glassfish.jersey.servlet)
service:427, WebComponent (org.glassfish.jersey.servlet)
service:388, ServletContainer (org.glassfish.jersey.servlet)
service:341, ServletContainer (org.glassfish.jersey.servlet)
service:228, ServletContainer (org.glassfish.jersey.servlet)
service:76, ServletContainerBridge (com.eclipsesource.jaxrs.publisher.internal)
handle:848, ServletHolder (org.eclipse.jetty.servlet)
doHandle:584, ServletHandler (org.eclipse.jetty.servlet)
doHandle:71, HttpServiceServletHandler (org.ops4j.pax.web.service.jetty.internal)
handle:143, ScopedHandler (org.eclipse.jetty.server.handler)
handle:548, SecurityHandler (org.eclipse.jetty.security)
doHandle:226, SessionHandler (org.eclipse.jetty.server.session)
doHandle:1180, ContextHandler (org.eclipse.jetty.server.handler)
doHandle:284, HttpServiceContext (org.ops4j.pax.web.service.jetty.internal)
doScope:512, ServletHandler (org.eclipse.jetty.servlet)
doScope:185, SessionHandler (org.eclipse.jetty.server.session)
doScope:1112, ContextHandler (org.eclipse.jetty.server.handler)
handle:141, ScopedHandler (org.eclipse.jetty.server.handler)
handle:80, JettyServerHandlerCollection (org.ops4j.pax.web.service.jetty.internal)
handle:134, HandlerWrapper (org.eclipse.jetty.server.handler)
handle:534, Server (org.eclipse.jetty.server)
handle:333, HttpChannel (org.eclipse.jetty.server)
onFillable:251, HttpConnection (org.eclipse.jetty.server)
succeeded:283, AbstractConnection$ReadCallback (org.eclipse.jetty.io)
fillable:108, FillInterest (org.eclipse.jetty.io)
run:93, SelectChannelEndPoint$2 (org.eclipse.jetty.io)
executeProduceConsume:303, ExecuteProduceConsume (org.eclipse.jetty.util.thread.strategy)
produceConsume:148, ExecuteProduceConsume (org.eclipse.jetty.util.thread.strategy)
run:136, ExecuteProduceConsume (org.eclipse.jetty.util.thread.strategy)
runJob:671, QueuedThreadPool (org.eclipse.jetty.util.thread)
run:589, QueuedThreadPool$2 (org.eclipse.jetty.util.thread)
run:748, Thread (java.lang)

Addon settings

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="io.github.bademux.huemu.openhab.addon" configuration-policy="optional" immediate="true" activate="activate" deactivate="deactivate" modified="modified">
  <implementation class="io.github.bademux.huemu.openhab.HuemuAddon"/>
  <service>
    <provide interface="io.github.bademux.huemu.openhab.HuemuAddon"/>
  </service>
  <reference name="eventPublisher" interface="org.eclipse.smarthome.core.events.EventPublisher" field="eventPublisher"/>
  <reference name="httpService" interface="org.osgi.service.http.HttpService" field="httpService"/>
  <reference name="itemRegistry" interface="org.eclipse.smarthome.core.items.ItemRegistry" field="itemRegistry"/>
  <reference name="networkAddressService" interface="org.eclipse.smarthome.core.net.NetworkAddressService" field="networkAddressService"/>
  <reference name="thingRegistry" interface="org.eclipse.smarthome.core.thing.ThingRegistry" field="thingRegistry"/>
  <property name="service.config.category" type="String" value="io"/>
  <property name="service.config.label" type="String" value="Philips Hue API Emulator"/>
  <property name="service.config.description.uri" type="String" value="io:huemu"/>
  <property name="service.pid" type="String" value="io.github.bademux.huemu.openhab.addon"/>
</scr:component>