Currently, I have two OSGi packages ( bundle1 and bundle2 ), both of which provide services through a project in EBA. In bundle2 blueprint.xml I want to refer to a service from bundle1 and embed it in BuildService (code below), because BuildService will be used to call TicketService. However, this results in a timeout exception (also below). It seems that BuildService is never registered with OSGi. How do I do something like this work?
blueprint.xml for bundle1 :
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:bptx="http://aries.apache.org/xmlns/transactions/v1.0.0"> <bean id="TicketServiceBean" class="com.example.b2.impl.TicketServiceImpl"> <bptx:transaction value="Required" method="*" /> </bean> <service ranking="0" id="TicketService" interface="com.example.b2.service.TicketService" ref="TicketServiceBean"> <service-properties> <entry key="service.exported.interfaces" value="*" /> </service-properties> </service> </blueprint>
blueprint.xml for bundle2
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <bean id="BuildServiceImplBean" class="com.example.b1.impl.BuildServiceImpl" activation="eager" > <property name="ticketService" ref="TicketServiceRef" /> </bean> <service id="BuildService" ref="BuildServiceImplBean" interface="com.example.b1.service.BuildService" activation="eager"> <service-properties> <entry key="service.exported.interfaces" value="*" /> </service-properties> </service> <reference id="TicketServiceRef" interface="com.example.b2.service.TicketService" availability="mandatory" activation="eager" /> </blueprint>
BuildService implementation:
public class BuildServiceImpl implements BuildService { private TicketService ticketService; @Override public TicketBuildResponse ticketBuild(TicketBuildRequest ticketBuildRequest) throws BuildServiceException {
When starting the application server (Websphere), I get the following exception:
BlueprintCont E org.apache.aries.blueprint.container.BlueprintContainerImpl$1 run Unable to start blueprint container for bundle com.example.b1.module due to unresolved dependencies [(objectClass=com.example.b2.service.TicketService)] java.util.concurrent.TimeoutException at org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:273) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:453) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:315) at java.util.concurrent.FutureTask.run(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:736)
source share