lisak
lisak

Reputation: 21981

Spring - singleton problem - No bean named '....' found

Hey, I can't figure out what is wrong with this beans definition. I'm getting this error http://pastebin.com/ecn5SWLa . Especially the 14th log message is interesting. This is my app-context file http://pastebin.com/dreubpRY

httpParams is a singleton which is set up in httpParamBean and then used by tsccManager and httpClient. The various depends-on settings is a result of my effort to figure it out.

Upvotes: 1

Views: 1439

Answers (2)

lisak
lisak

Reputation: 21981

Got it, it has to be like this: " <property name="targetObject"><ref local="schemeReg"/></property> "


<bean id="plainSocketFactory" class="org.apache.http.conn.scheme.PlainSocketFactory"
      factory-method="getSocketFactory"/>

<bean id="scheme" class="org.apache.http.conn.scheme.Scheme">
    <constructor-arg value="http"/>
    <constructor-arg ref="plainSocketFactory"/>
    <constructor-arg type="int" value="80" />
</bean>

<bean id="schemeReg" class="org.apache.http.conn.scheme.SchemeRegistry"/>

<bean id="configurator" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject"><ref local="schemeReg"/></property>
    <property name="targetMethod" value="register"/>
    <property name="arguments">
        <list>
            <ref bean="scheme"/>
        </list>
    </property>
</bean>

Thank you guys

Upvotes: 0

Espen
Espen

Reputation: 10745

You can't reference other beans with "#{httpParams}".

Replace your constructor with this:

<constructor-arg ref="httpParams" />

Upvotes: 3

Related Questions