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/
I have also tried with
WebApplicationContext springCtx = (WebApplicationContext)PortletApplicationContextUtils.getRequiredWebApplicationContext(getPortletContext());
and i have :
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
I have below listner in web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
using liferay 6.1
Please sign in to flag this as inappropriate.