This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi, Sort of strange this...I've written some java code which accesses a mysql database and it works absolutely perfect.However when i put the same code into a servlet the servlet throws a classnotfound exception.Is there any specific reason for this because as far as i can gather if it runs normally as independent java code without throwing any exceptions it should run in a servlet also .Do let me know if im missing out anything here? Thanks Arvind
Application servers ignore the classpath. There is an important reason why they have to, but the short answer is that you probably need to place the mysql driver jar in the web-inf/lib directory to get it to work.
App servers are designed to run several applications at the same time and pretend that each is the only one running - ie it should minimise conflicts and crossovers between applications. To assist this, some ClassLoader tricks are used to make sure App A can't see App B or related classes. If they all ran off the class path this wouldn't work, so applciation servers pretend to create a separate classpath for each application running in the application server.
Joined: Jun 19, 2004
Hi david, Thnx man...ill try that...though i didnt get the reason ...sorry...guess im just real new to java.. Arvind