Announcement Announcement Module
Collapse
No announcement yet.
Nesting business services with application services proxy issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Nesting business services with application services proxy issue

    Hi,
    I am creating our service layer to wrap our data access layer by DI of DAO's. I have moved transaction management via AOP/Schema from the DAO's to these new wrapper service classes. In simple business services with multiple DAO's injected, life is good. My problem I can't seem to get beyond is that in a few cases, I have to solve for business services that need to DI another application service: a Messaging service I created - so I have a case of nested services which I believe is my configuration problem. Here is my scenario I am troubleshooting:


    I just upgraded MessageService to an application service which needs to be called by several business services: Spring creates a proxy for it
    Code:
    public class MessageService implements BusinessService, IMessageService {
     ... I set my dao's
     ... and do stuff 
    }
    One of my new business services which requires a MessageService: Spring creates a proxy for the business service AND the application service injected into it
    Code:
     <!-- new business service in the service layer I'm building: Until I go to aspectJ, I can't seem to decouple the 
     MessageService from my service layer via Spring AOP -->
      <bean id="noticeService" class="com.foo.services.NoticeService">
             <property name="noticeDAO">
                 <bean id="noticeDAO" parent="sqlMapService" class="com.foo.services.NoticesDAO"/>
             </property>
            <property name="messageService" ref="messageService"/> [Here is the error: can not cast proxy to type]
        </bean>
    
     <!-- Messaging - updated service works fine in isolated testing. In dev and qa, DI injects values from
      a properties file but in prod, all data is from the database, thus all the p:'s -->
        <bean id="messageService" class="com.foo.messaging.services.MessageService"
              p:messageFrom="${messaging.messageFrom}" p:messageTo="${messaging.messageTo}"
              p:messageCc="${messaging.messageCc}" p:messageBcc="${messaging.messageBcc}"
              p:faxConfirmationTo="${messaging.faxConfirmationTo}" p:faxTo="${messaging.faxTo}">
             <property name="recipientListDAO">
                 <bean id="recipientListDAO" parent="sqlMapService" class="com.foo.messaging.services.RecipientListDAO"/>
             </property>
            <property name="businessEmailSender" ref="busMessageSenderBean"/>
            <property name="faxSender" ref="faxSenderBean"/>
            <property name="messageDAO">
                <bean id="messageDAO" parent="sqlMapService" class="com.foo.messaging.services.MessageDAO"/>
            </property>
            <property name="logDAO">
                <bean id="logDAO" parent="sqlMapService" class="com.foo.messaging.services.LogDAO"/>
            </property>
        </bean>
    Part of my Test Class
    Code:
    public class NoticeServiceTest extends SecureTestCase {
     INoticeService noticeService;
     IMessageService messageService; 
     String args = ; // some args setup
    protected void setUp() throws Exception {
     
            super.setUp();
            authenticateTestUser();
    
            noticeService = (INoticeService) systemSetup.getSpringBean("noticeService");
            messageService = (IMessageService) systemSetup.getSpringBean("messageService");
    
        }
    ....
    }
    Log4j output error
    Code:
    DEBUG org.springframework.aop.framework.JdkDynamicAopProxy  - Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [com.foo.messaging.services.MessageService@10df4e2]
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'noticeService' defined in class path resource [service-config.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy9] to required type [com.foo.messaging.services.MessageService] for property 'messageService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy9] to required type [com.foo.messaging.services.MessageService] for property 'messageService': no matching editors or conversion strategy found
    Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
    PropertyAccessException 1:
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy9] to required type [com.foo.messaging.services.MessageService] for property 'messageService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy9] to required type [com.foo.messaging.services.MessageService] for property 'messageService': no matching editors or conversion strategy found
    Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy9] to required type [com.foo.messaging.services.MessageService] for property 'messageService': no matching editors or conversion strategy found
    Any insight on configuration for nested services such as in the schema above would be greatly appreciated.

    kind regards,
    h
    Last edited by Helena; Feb 28th, 2008, 09:17 AM.

  • #2
    I just realized what my problem probably is. i have each service implementing BusinessService, and I have everything that implements BusinessService as transactionally managed. Thus, i am nesting a tx-managed class within a tx-managed class. So i'm trying to figure out the best way to design the solution.

    Comment

    Working...
    X