• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

getServletContext() getRealPath() problem in packaged J2EE application

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What java code do I need to write to find files for my application dynamically as resources i.e. under the WEB-INF/classes directory of my web app installation (war file)?
The issue of virtual paths within the archive files used to package J2EE applications has thrown my application off kilter. Previously the application was deployed as an exploded directory under Apache Tomcat. As I move to deploy it on WebLogic 7.0 it falls over because it uses "getServletContext().getRealPath("/")" to construct the searchpath for the files which are located below the web application root. As this call fails to return anything the
If anyone has an answer to the specific question above or any alternative useful suggestions as to how to approach solving this problem I would be very grateful!
Thanks in advance....
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the classloader to load your resources from your war file (the files must be in the classpath, like all your .class files).
getResourceAsStream from java.lang.Class is a good place to start looking for how to do this.
 
This tiny ad is guaranteed to be gluten free.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic