views:

118

answers:

2

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.

+3  A: 

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

Replace your constructor with this:

<constructor-arg ref="httpParams" />
Espen
Spring logging doesn't say in the debug mode why initialization of app context failed ... http://pastebin.com/87cF2Mhp ... could you please take a look last time ?
lisak
Do you need the depends-on attributes? I have never needed this; Spring is usually pretty good about managing this stuff by default. I think you may be causing circular dependencies.
AngerClown
It's the same result without them...btw it's started this way: ApplicationContext ctx = new ClassPathXmlApplicationContext("app-context.xml");logger.debug("ApplicationContext ready");ThreadManager threadManager = (ThreadManager) ctx.getBean("threadManager");
lisak
Logs end with MethodInvokingFactoryBean, I need it to invoke register method on schemeReg with an argument value of scheme bean
lisak
I think you may have to create a factory / proxy class and use that in your Spring xml. MethodInvokingFactoryBean needs a Class - you are giving it a schemeReg as a bean. I haven't looked and the code, but does anything from https://issues.apache.org/jira/browse/HTTPCLIENT-851 help?Also, you could create the SocketFactory needed by the Scheme as a bean rather than using Spring EL - see the Spring doc for the init-method attribute.
AngerClown
A: 

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

lisak