Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Injecting osgi service reference Null Pointer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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" />

    Comment

    Working...
    X