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
Error when passing a <reference> to a class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error when passing a <reference> to a class

    I am getting the following error when deploying a springDM file into Karaf:

    Code:
    org.springframework.beans.NotWritablePropertyException: Invalid property 'controller' of bean class [java.lang.string]: Bean property 'controller' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    First, here is where I create my bean:

    Code:
    <bean id="myAppDataSourceController" class="myApp.controller.DataSourceController" 
      p:Dao-ref="myAppDao" />
    and in another xml file I attach it to the service registry:

    Code:
    <service ref="myAppDataSourceController" 
         interface="myApp.controller.DataSourceControllerIfc" />
    Here is the pojo in another bundle that uses the service:

    Code:
    public class DAOTest { 
    
     private static DataSourceController controller; 
    
     public static void setController(DataSourceController controller){ 
      DAOTest.controller = controller; 
     } 
    
     public static DataSourceController getController() { 
      return controller; 
     } 
    
     public static String dataPopulator() { 
      // excercise the DAO and return "pass" if it passes 
     } 
    
    }
    Here is where I get the reference:

    Code:
    <reference id="myAppDataSourceController"
                      interface="myApp.controller.DataSourceControllerIfc"/>
    And here is the where I attempt to inject the service reference into the above class:

    Code:
    <bean id="DAOTest" class="myApp.testharness.DAOTest" 
        factory-method="dataPopulator" 
        p:controller-ref="myAppdataSourceController" 
    />
    In Karaf when I perform an 'ls' on the myApp.controller bundle I get the following:
    Bundle <id> provides:
    ---------------------------
    Bundle-SymboicName = myApp.controller
    Bundle-Version = 0.0.1
    objectClass = myApp.controller.DataSourceControllerIfc
    org.springframework.osgi.bean.name = myAppDataSourceController
    service.id = <number>

    Does anyone have an idea what the issue is?

    I also noticed that when I inject a service reference to my pojo, it wont' let me pass in Strings or Ints. Kind of unnerving.

    v/r,

    Mike Van

  • #2
    Solution

    Ok, after speaking with the Karaf group, it looks like the problem was with how I was starting my initialization method "doPopulate()".

    To fix this, I removed all of the final and static words from my property and method signatures. Then, I had my class implement the InitializerBean interface, and changed "public String doPopulate()" to "public void afterPropertiesSet()".

    Hope this makes sense.

    Comment

    Working...
    X