Search code examples
springliferayliferay-6spring-jdbc

Failing to call spring bean from portlet


I have Spring bean as below:

    @Service("bookService")
public class BookServiceImpl implements BookService {
    @Autowired
    @Qualifier("bookDao")
    private BookDao bookDao;

i have a portlet trying access it as below:

   62   public BookService getBookService() {
63      ApplicationContext springCtx =   PortletApplicationContextUtils.getWebApplicationContext(getPortletContext());
64      return (BookService)springCtx.getBean("bookService");
    }


but i have the below nullpointer exception:
java.lang.NullPointerException
at chapter09.code.listing.base.BookCatalogPortlet.getBookService(BookCatalogPortlet.java:64)
at chapter09.code.listing.base.BookCatalogPortlet.init(BookCatalogPortlet.java:59)

Please let me know if i am missing some thing source available @http://portletsinaction.googlecode.com/svn/trunk/ch9_BookCatalogSpringJdbc/

enter code here

Solution

  • Its issue with Liferay 6.1.1 I have tested the same with 6.0.6 and its working fine.