• 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

Digester Revisited...

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again, Everyone. Sorry to keep hammering this board, but I'm in unexplored territory. As part of my continuing implementation of the Digester class, I'm now facing a problem to which the answer has been elusive, to say the least.

I'm using an Abstract Factory pattern to set up my web application. Basically, I have an abstract DaoFactory class which reads an XML file and instantiates the proper concrete DaoFactory (in this case, a MySqlDaoFactory instance).

Now, all is fine on my local machine however, when I run the app in the Tomcat context on the web, I get the inevitable <i>ClassNotFoundException</i>.

Consider the following a small example of my XML config file:


I have a DispatchServlet which calls DaoFactory.getInstance(). The getInstance() method parses the above XML file and instantiates the proper DaoFactory class. However, the class com.mypackage.MySqlDaoFactory cannot be found. My webapp directory structure is as follows:

webapps/myApp/com/mypackage

All classes are in the above package. Is it something with the Digester? Why can it not find the class? Tomcat is loading myApp fine, so I assume all my classes are loaded. Any ideas? Thanks again for your continued attention!
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UPDATE -- I've grabbed the ClassLoader from Digester using getClassLoader(), and it appears to be looking only at the Tomcat\common\* directory. Perhaps this is the issue. The Digester does not recognize my package, eventhough the Digester is being called from one of my classes. I'll now look at how to load my classes into the Digester. If you have any tips, let me know!
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Haha, don't mind me, I enjoy having conversations with myself! Anyhow, I found the problem and I just wanted to close out this thread with a solution should anyone do a search and dig this up.

A call to digester.setUseContextClassLoader(true) will cause the Digester instance (digester) to load classes in the current context (in my case, WEB-INF/classes).
 
reply
    Bookmark Topic Watch Topic
  • New Topic