Results 1 to 3 of 3

Thread: Can't resolve reference while using Spring EL

  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Default Can't resolve reference while using Spring EL

    Hi,

    What I am trying to do is to create a Struts base action that initializes a logging proxy. All services called by any action will use this proxy to log errors. The proxy is then accessed by an interceptor that then does the actual logging. Everything compiles, builds. However deployment I get the following error on Tomcat 7:

    I am getting the following error in my application:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'journalVoucherService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean '#{baseAction.logger}' while setting bean property 'logger'; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'com.blah.logging.LoggingProxy@58edf4c8' is defined

    Here's my applicationContext.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.1.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schem...ontext-3.1.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schem...ing-tx-3.1.xsd
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util-3.1.xsd">

    <!-- Needed to run @PostConstruct initialization checking methods -->
    <context:annotation-config />

    <!-- Needed for @Transactional annotation -->
    <tx:annotation-driven />

    <!-- Journal Voucher Service -->
    <bean id="journalVoucherService"
    class="com.blah.service.impl.JournalVoucherService Impl"
    parent="baseService">
    </bean>

    <!-- Base Service -->
    <bean id="baseService" abstract="true"
    class="com.blah.service.impl.BaseServiceDatabaseIm pl">
    <property name="dataSource" ref="dataSource" />
    <property name="logger" ref="#{baseAction.logger}" />
    </bean>

    <!-- Loggging Proxy -->
    <bean id="loggingProxy" class="com.blah.logging.LoggingProxy"/>

    <!-- Struts 2 Actions -->
    <bean id="baseAction"
    class="com.blah.action.BaseAction">
    <property name="logger" ref="loggingProxy" />
    </bean>

    All of my beans are found in the standard java web structure place (WEB-INF/classes). It appears as though the EL needs a reference to the class path. It's probably something pretty simple but am I am new to Spring EL.

  2. #2
    Join Date
    Apr 2008
    Location
    Seville, Spain
    Posts
    132

    Default

    Use value, not ref to inject a bean property using spel. For example:

    Code:
    <!-- Base Service -->
    <bean id="baseService" abstract="true"
    class="com.blah.service.impl.BaseServiceDatabaseIm pl">
    <property name="dataSource" ref="dataSource" />
    <property name="logger" value="#{baseAction.logger}" />
    </bean>
    Jose Luis Martin
    Freelance Senior Consultant
    JDAL - Java Database Application Library

  3. #3
    Join Date
    Apr 2012
    Posts
    3

    Default

    Yes, that was it! Thank you, Bob

Posting Permissions

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