• 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

Class Not Found Exception on Loading a Class from a Property file

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am getting the Class Not Found Exception when i tried to load a particular class based on the property value.Please find the details.
app.properties
Controller.java
At line 3 of Controller.java I am gettting

Class Not Found Exception.


I have included /WEB-INF/classes directory in the classpath but unable to resolve the problem.
But if I modify the code as mentioned below and instead of supplying the property value to the class loader, give the class name manually, then the code is working fine
Controller.java
Please suggest me in understanding the above problem.
Thanks in advance.
Regards,
Sultan.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen something like this caused by leading or trailing spaces in the property value.

Try the String trim() method on the value retrieved.

Bill
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd also question your methodology: there are better ways to implement similar functionality (DI/IoC via Spring or similar come to mind immediately).
 
Sultan Khadar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
This is a practice assignment for MVC design , where we were told not to use Any popular design techniques and frameworks.
William, thanks for your post. I will trim the property value and test the application.
Thanks.
Sultan.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic