Hello,

I am using Blueprint / Managed OpenJPA in a scenario based on the blog 
sample.  I need a way to fetch a Blueprint service from a point in the 
code that starts with no reference to anything Blueprint related.  As I 
understand it, this should be possible using something that looks a bit 
like this:

InitialContext ic = new InitialContext();
Object s = ic.lookup("osgi:service/" + 
ThingPersistenceService.class.getName());

Where ThingPersistenceService is the interface my service is implementing. 
 However when I try this code, I get this unhelpful exception:

javax.naming.NameNotFoundException: 
osgi:service/alex.mjpa.api.persistence.ThingPersistenceService
at 
org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:110)
at 
org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:141)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:148)
at javax.naming.InitialContext.lookup(InitialContext.java:455)
at alex.mjpa.ThingCommandProvider.getThingPS(ThingCommandProvider.java:22)
...

I know the service is registered in the OSGi environment because typing 
"services" at the OSGi console includes this line:

{alex.mjpa.api.persistence.ThingPersistenceService}={osgi.service.blueprint.compname=persistenceImpl,
 
service.id=51}
  Registered by bundle: alex.mjpa.persistence.jpa_1.0.0.qualifier [35]
  No bundles using service.

The service is registered in Blueprint using the following blueprint.xml:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0";
        xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0";
        default-activation="lazy" >
 
        <bean id="persistenceImpl"
 class="alex.mjpa.persistence.jpa.ThingPersistenceServiceImpl" >
                <tx:transaction method="*" value="Required" />
                <jpa:context property="entityManager" 
unitname="thingExample" />
        </bean>
 
        <service ref="persistenceImpl"
 interface="alex.mjpa.api.persistence.ThingPersistenceService" >
        </service>
 
</blueprint>

I feel that I am missing something obvious here, but after an hour of 
experimentation I am still not making any progress.  Can anyone here help 
me solve this?  If I have not provided enough information, please let me 
know.

thanks in advance,

alex






Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU





Reply via email to