Search code examples
dwrspring-3

Spring @Autowired not working with DWR



Here is my service layer:

@Service
@RemoteProxy
public class ReturnToDWR{

    @Autowired
    private DAOLayer daoLayer;    

    @RemoteMethod
    public List<String> returnRecord(String id){
        List<String> list = daoLayer.returnPendingRecords(id);
        return list;
    }    
}

DWR configuratin setting in applicationContext.xml file:

<dwr:configuration />
    <dwr:controller id="dwrController" debug="true" />

    <bean id="returnToDWR" class="com.service.ReturnToDWR">     
        <dwr:remote javascript="returnToDWR">
            <dwr:include method="returnRecord" />
        </dwr:remote>
    </bean>

When i am calling returnRecord() from my Controller, it is working. But when i am calling same method from jsp using DWR it shows me NullPointerException on List<String> list = daoLayer.returnPendingRecords(id); line.

I think spring is unable to autowire private DAOLayer daoLayer; in the case of DWR.
Please tell me how can i fix my code to work with DWR?
Thanks
Shams


Solution

  • When you place a brakepoint on that line, can you see in the debugger, that value of daoLayer is really null? Isn't it possible that the id value is null and that causes that NullPointerException inside the returnPendingRecords method?