File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Class Not Found Exception on Loading a Class from a Property file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Class Not Found Exception on Loading a Class from a Property file" Watch "Class Not Found Exception on Loading a Class from a Property file" New topic
Author

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

Sultan Khadar
Ranch Hand

Joined: Sep 12, 2006
Posts: 75
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.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
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
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Sep 12, 2006
Posts: 75
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Not Found Exception on Loading a Class from a Property file