SpringFramework kills me softly
This 2 lines have caused me a lot of trouble... Well, at the end it was not so complicated, but it does not help to feel me better... How much time lost for these two lines... snif snif...
WebApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(
portlet.getContext());
BasicDataSource ds = (BasicDataSource) ctx.getBean("dataSource");
When you have a web application using Spring, and you want to use some bean from the definition, you ca use several different methods, but this one is probably the most powerful and leverages your Webapp....
But to make it work, you have to add this to the web.xml config file:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/intranet-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>


0 Comments:
Post a Comment
<< Home