You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Lukasz Dywicki <lu...@dywicki.pl> on 2008/04/29 11:38:07 UTC

Autowire support

Hello,
I try to run cxf service engine base endpoint with autowire support, but it
doesn't work. When I run unit tests
(AbstractDependencyInjectionSpringContextTests) everything is ok. Do I need
change something?

My code:

services.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    default-autowire="byType"

    <bean id="devbankServiceType"
        class="pl.bpsa.smx3.impl.services.devbank.DevbankServiceTypeImpl">
        <!--
        <property name="searchService" ref="searchService" />
        -->
    </bean>

    <bean id="searchService"
       
class="pl.bpsa.smx3.impl.services.devbank.impl.SpringDevbankSearchService">
        <property name="sqlQuery" value="${search.sql.query}" />
        <!--
        <property name="dataSource" ref="dataSource" />
        <property name="personMapper" ref="rowMapper" />
        -->
    </bean>

    <bean id="rowMapper"
class="pl.bpsa.smx3.impl.services.devbank.impl.PersonRowMapper" />

    <bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driver}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
    </bean>
</beans>

xbean.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
    xmlns:devbank="http://smx3.bpsa.pl/services/devbank">

    <import resource="classpath:/services.xml" />

    <cxfse:endpoint service="devbank:Devbank" endpoint="devbank-engine"
        interfaceName="pl.bpsa.smx3.services.devbank.DevbankServiceType"
        pojo="#devbankServiceType" />

</beans>
-- 
View this message in context: http://www.nabble.com/Autowire-support-tp16956833p16956833.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Autowire support

Posted by Lukasz Dywicki <lu...@dywicki.pl>.
Hello,
When I called web service I've got NullPointerException because properties
wasn't set properly. For testing I have other context fragment and
properties are set and code run without any errors.

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

    <!-- override ${jdbc.*} placeholders -->
    <context:property-placeholder location="classpath:/test-jdbc.properties,
         test-search-query.properties" />

    <import resource="classpath:/services.xml" />

</beans>

Regards,
Luke


Freeman Fang wrote:
> 
> Hi Lukasz,
> 
> What you mean it doesn't work but works when you run unit tests?
> What's your unit tests looks like? Is your tests use the spring bean 
> configuration here as you show?
> 
> Freeman
> 
> Lukasz Dywicki wrote:
>> Hello,
>> I try to run cxf service engine base endpoint with autowire support, but
>> it
>> doesn't work. When I run unit tests
>> (AbstractDependencyInjectionSpringContextTests) everything is ok. Do I
>> need
>> change something?
>>
>> My code:
>>
>> services.xml:
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>     xmlns:context="http://www.springframework.org/schema/context"
>>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>     default-autowire="byType"
>>
>>     <bean id="devbankServiceType"
>>        
>> class="pl.bpsa.smx3.impl.services.devbank.DevbankServiceTypeImpl">
>>         <!--
>>         <property name="searchService" ref="searchService" />
>>         -->
>>     </bean>
>>
>>     <bean id="searchService"
>>        
>> class="pl.bpsa.smx3.impl.services.devbank.impl.SpringDevbankSearchService">
>>         <property name="sqlQuery" value="${search.sql.query}" />
>>         <!--
>>         <property name="dataSource" ref="dataSource" />
>>         <property name="personMapper" ref="rowMapper" />
>>         -->
>>     </bean>
>>
>>     <bean id="rowMapper"
>> class="pl.bpsa.smx3.impl.services.devbank.impl.PersonRowMapper" />
>>
>>     <bean id="dataSource"
>> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>>         <property name="driverClassName" value="${jdbc.driver}" />
>>         <property name="url" value="${jdbc.url}" />
>>         <property name="username" value="${jdbc.username}" />
>>         <property name="password" value="${jdbc.password}" />
>>     </bean>
>> </beans>
>>
>> xbean.xml:
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>     xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
>>     xmlns:devbank="http://smx3.bpsa.pl/services/devbank">
>>
>>     <import resource="classpath:/services.xml" />
>>
>>     <cxfse:endpoint service="devbank:Devbank" endpoint="devbank-engine"
>>         interfaceName="pl.bpsa.smx3.services.devbank.DevbankServiceType"
>>         pojo="#devbankServiceType" />
>>
>> </beans>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Autowire-support-tp16956833p16958660.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Autowire support

Posted by Freeman Fang <fr...@gmail.com>.
Hi Lukasz,

What you mean it doesn't work but works when you run unit tests?
What's your unit tests looks like? Is your tests use the spring bean 
configuration here as you show?

Freeman

Lukasz Dywicki wrote:
> Hello,
> I try to run cxf service engine base endpoint with autowire support, but it
> doesn't work. When I run unit tests
> (AbstractDependencyInjectionSpringContextTests) everything is ok. Do I need
> change something?
>
> My code:
>
> services.xml:
> <beans xmlns="http://www.springframework.org/schema/beans"
>     xmlns:context="http://www.springframework.org/schema/context"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     default-autowire="byType"
>
>     <bean id="devbankServiceType"
>         class="pl.bpsa.smx3.impl.services.devbank.DevbankServiceTypeImpl">
>         <!--
>         <property name="searchService" ref="searchService" />
>         -->
>     </bean>
>
>     <bean id="searchService"
>        
> class="pl.bpsa.smx3.impl.services.devbank.impl.SpringDevbankSearchService">
>         <property name="sqlQuery" value="${search.sql.query}" />
>         <!--
>         <property name="dataSource" ref="dataSource" />
>         <property name="personMapper" ref="rowMapper" />
>         -->
>     </bean>
>
>     <bean id="rowMapper"
> class="pl.bpsa.smx3.impl.services.devbank.impl.PersonRowMapper" />
>
>     <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>         <property name="driverClassName" value="${jdbc.driver}" />
>         <property name="url" value="${jdbc.url}" />
>         <property name="username" value="${jdbc.username}" />
>         <property name="password" value="${jdbc.password}" />
>     </bean>
> </beans>
>
> xbean.xml:
> <beans xmlns="http://www.springframework.org/schema/beans"
>     xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
>     xmlns:devbank="http://smx3.bpsa.pl/services/devbank">
>
>     <import resource="classpath:/services.xml" />
>
>     <cxfse:endpoint service="devbank:Devbank" endpoint="devbank-engine"
>         interfaceName="pl.bpsa.smx3.services.devbank.DevbankServiceType"
>         pojo="#devbankServiceType" />
>
> </beans>
>