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:
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!
Joined: Apr 16, 2004
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!
Joined: Apr 16, 2004
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).
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com