Problems while defining injection of service

164 views
Skip to first unread message

Christoph Prybila

unread,
Oct 17, 2012, 6:27:45 PM10/17/12
to openen...@googlegroups.com
Hello,

I have extended the ConnectorManager with new functionality. But part of it should not be acessible from remote.
So I created a second interface, with the functions and let the ConnectorManagerImpl implement it.

Now I want to access the new functions in the UI admin bundle.
First I extended the Servicedefinition of the ConnectorManager (found in "service-context.xml")  with the new interface, it now looks like this

  <service>
    <interfaces>
      <value>org.openengsb.core.api.ConnectorManager</value>
      <value>org.openengsb.core.api.xlink.service.XLinkConnectorManager</value>
    </interfaces>
    <service-properties>
      <entry key="service.pid" value="connectorManager" />
    </service-properties>
    <ref component-id="connectorManager" />
  </service>

Then I referenced the service in the blueprint of the ui/admin bundle, now I have two references to the service
  <reference id="serviceManager" interface="org.openengsb.core.api.ConnectorManager" />
  <reference id="xlinkServiceManager" interface="org.openengsb.core.api.xlink.service.XLinkConnectorManager" />
the first reference is the old one, used by the all the other ui/admin webpages, the second one is used by one of my beans.

  <bean id="toolChooserLogic" class="org.openengsb.ui.admin.xlink.ToolChooserLogicImpl">
    <property name="xlinkServiceManager" ref="xlinkServiceManager" />
  </bean> 

The class ToolChooserLogicImpl has the constructor

    public ToolChooserLogicImpl(XLinkConnectorManager xlinkServiceManager) {
        this.serviceManager = xlinkServiceManager;
    }

But I still get this exception

org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor on class org.openengsb.ui.admin.xlink.ToolChooserLogicImpl for arguments [] when instanciating bean toolChooserLogic
    at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:336)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[26:org.apache.aries.blueprint.core:1.0.1]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_07]
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_07]
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:646)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:353)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:252)[26:org.apache.aries.blueprint.core:1.0.1]
    at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[26:org.apache.aries.blueprint.core:1.0.1]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_07]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_07]
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_07]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_07]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_07]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)[:1.7.0_07]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)[:1.7.0_07]
    at java.lang.Thread.run(Thread.java:722)[:1.7.0_07]

What am I doing wrong.

kr Chris

Felix Mayerhuber

unread,
Oct 17, 2012, 7:02:05 PM10/17/12
to openen...@googlegroups.com
Hi,

the problem is located in the creation of your "toolChooserLogic" bean.
Your class have a constructor, as you stated, but you want to create the
bean with no arguments, but setting the value for the
"xlinkServiceManager"through a setter. The correct construction of the
"toolChooserLogic" bean would look like this:

<bean id="toolChooserLogic" class="org.openengsb.ui.admin.xlink.ToolChooserLogicImpl">
<argument ref="xlinkServiceManager" />
</bean>

Then it should work :-)

Kind regards
Felix

Christoph Prybila

unread,
Oct 18, 2012, 10:49:13 AM10/18/12
to openen...@googlegroups.com
Now it works, thanks!

kr Chris
Reply all
Reply to author
Forward
0 new messages