• 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

Tomcat classloader never loads

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had an application which has a JSP which accesses a POJO.

The POJO in turn parses a CSV file and returns a String[] for the JSP to consume.

I had the following directory structure.

css
html
images
jsp
WEB-INF
|---------classes
|-----------------com
|----------------------dca
|-------------------------delegate
|-------------------------------CSVDelegate.class
|---------resources
|----------------dcalist.csv


and in the CSVDelegate.class , I am trying to access the CSV file as follows:




I tried to make a 'jar' file that contains the path "resources/dcalist.csv" and placed it in the WEB-INF/lib.

and nothing works. I did work on stuff like this earlier, but never had an problems.
Not sure if I did something wrong or just the tomcat is just misbehaving.

I did delete the entire tomcat folder recreated it, recreated the server and tried several options of the path as well.

Annoyingly nothing works.
 
Meghana Reddy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Further , I tried passing the realpath from the JSP's application object to the Delegate's Constructor.




I had a sys out in the Delegate to print the path and I see the following on the server console.


C:\btobdev_ws\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\btobweb\resources\dcalist.csv (The system cannot find the path specified)


the btobweb folder is the my eclipse project folder. Not sure why the real path is pointing to the project root instead of the WEB-INF/classes since the "resources" folder is in the WEB-INF/classes folder.

Is there any explanation?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Relative file paths generally do not work in web apps. Use a path starting with "/" and the ServletContext's getRealPath() or getResourceAsStream() methods to access files within the web app.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic