• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic