Results 1 to 2 of 2

Thread: Injecting osgi service reference Null Pointer

  1. #1
    Join Date
    May 2011
    Posts
    3

    Default Injecting osgi service reference Null Pointer

    Hello,

    I'm trying to use the Spring-DM service-reference to inject a service exportet by a backend bundle into a frontend bundle, but I keep getting a Null pointer, as if the service didn't exist. I checked and the backend bundle with the service is up an running with the correct interface.

    Here is a look at the ServiceConnector of the frontend bundle and it's configuration:

    Code:
    public class ServiceConnector implements IServiceConnector {
    	
    	private IUserSessionLifecycle userSessionServiceReference;
    	
    	public ServiceConnector() {
    		super();		
    	}
    
    	public IUserSession getValidUserSession(String email, String password)
    	{
    		return userSessionServiceReference.getUserSession(email, password);
    	}
    }
    Code:
    <osgi:reference id="userSessionServiceReference" interface="de.idarewest.backend.service.transaction.IUserSessionLifecycle"/>
           
        <bean id="serviceConnector" scope="prototype"
    		class="de.pascada.idarewest.ServiceConnector">	
    		<property name="userSessionServiceReference" ref="userSessionServiceReference"/> 		
    	</bean>
    When the service-connector is invoked it throws a null pointer, so it definitely means the userSessionService is not being injected.

    The userSessionService is configured as follows:

    Code:
    public interface IUserSessionLifecycle {
    
    	public abstract IUserSession getUserSession(String email, String password);
    
    	public abstract IUserAccount getUserAccountByEmail(String email);
    
    }
    Code:
    <bean id="IUserSession" name="userSessionBean" scope="prototype"
    		class="de.idarewest.backend.service.transaction.UserSessionLifecycle">			
    	</bean>
    	
    	<osgi:service id="userSessionService" ref="userSessionBean"  
    			 interface="de.idarewest.backend.service.transaction.IUserSessionLifecycle" />
    After the deployment of both bundles Spring-DM confirms the service import as follows:
    Code:
    17:42:47,195  INFO OsgiServiceProxyFactoryBean:470 - Looking for mandatory OSGi service dependency for bean [userSessionServiceReference] matching filter (objectClass=de.idarewest.backend.service.transaction.IUserSessionLifecycle)
    17:42:47,369  INFO OsgiServiceProxyFactoryBean:476 - Found mandatory OSGi service for bean [userSessionServiceReference]
    Any ideas why this Spring-DM is not injecting the service ?

    Thanks for any help

  2. #2
    Join Date
    Sep 2006
    Location
    Russia
    Posts
    28

    Default

    Hi!

    Try to change
    Code:
    <osgi:service id="userSessionService" ref="userSessionBean"  
    			 interface="de.idarewest.backend.service.transaction.IUserSessionLifecycle" />
    to

    Code:
    <osgi:service id="userSessionService" ref="IUserSession"  
    			 interface="de.idarewest.backend.service.transaction.IUserSessionLifecycle" />

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •