Tuesday, February 25, 2014

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' is defined

"org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' is defined" This error wasted my precious couple of hours yesterday and could not find any blog post pointing to my problem. It seems this problem can occur for various reasons. 

few of them are not including cxf-bundle jar, not having proper cxf.xml files imported into spring context and this error can also occur for the wrong context file. What do I mean by it?

I had below code snippet in my web.xml.
-------------------------------
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

My root-context.xml did not have any cxf related definition in it though I was loading the correct configuration file in CXFServlet servlet-mapping. I was hoping while loading the CXFServlet it will use the right configuration file and should work. 

But unfortunately after looking at CXFServlet source code realized that if the global config location is not null then only it consider local location. 

I just had to move my CXF related definition to root-context.xml and BOOM my problem was gone. I uploaded the working sample CXF project under my github repo. 


interesting isn't it
Manisha


Thursday, February 20, 2014

How to create a Spring MVC skeleton project in 10 minutes :)

I know it's very simple but have seen people struggling a lot to create and setup the first working project using Spring framework.

Here are the steps to create a Spring MVC skeleton project .

1) Download and Install STS ( Spring Source Tools)
2) Click File -> New -> Project
3) Select Spring Project from the provided list.

4) Spring Project Dialog box would appear. Select Spring MVC Project template and provide the project name.


5) Hit Next and Provide an toplevel package name for your application and choose Finish. 

Believe it or not your Spring MVC application is ready to be deployed on any server. Do look into created projects to understand the pieces involve in it :). 

Happing Spring
Manisha