Two Laptop Bag*
The moose likes Spring and the fly likes Getting error while reading XML file from initializing bean from servlet.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Getting error while reading XML file from initializing bean from servlet.xml" Watch "Getting error while reading XML file from initializing bean from servlet.xml" New topic
Author

Getting error while reading XML file from initializing bean from servlet.xml

Suresh Pritmani
Greenhorn

Joined: May 24, 2009
Posts: 8
I have defined one Class using beanFactory method. That bean is defiend in servlet.xml. This xml method will be called from DispatcherServlet of Spring Framework.
I want to pass path of XML file in that bean. I have tried to pass that path as relative path. I have stored that XML file in WEB-INF directory. But while trying to read that file, I am getting error like File does not exist. But if I'll provide absolute path, then it's work properly. Can Anyone suggest how to pass relative path in beanFactory.

I am using eclipse 3.5 as an editor and SPRING/HIBERNATE in my project.
The code of my servlet.xml is...
~~~~~~~~~~~~~~~~~~~~~
<bean id="handlerMappingClass" init-method="getMapOfHandler" class="com.mapper.HandlerMappingFactory">
<property name="configFilePath" value="WEB-INF/handlerMapEntries.xml"/>
</bean>

The code of my HandlerMappingFactory class is...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ClassPathResource configFileObj = new ClassPathResource(configFilePath);
fileObj = configFileObj.getFile(); // Over here, If path is relative then "File not found" error is coming. If path is absolute then it works fine.
//Remaining code to read XML file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting error while reading XML file from initializing bean from servlet.xml
 
Similar Threads
Spring webflow exception: No bean named 'flowExecutor' is defined
Bean definition found but not found
spring inside eclipse
get ref bean from applicationContext.xml
Spring: Setter Injection on non-public class