From kehoe@fortuity.com Wed Feb 16 18:45:51 2000 Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 60171 invoked from network); 16 Feb 2000 18:45:51 -0000 Received: from navis380.navis.com (208.25.78.10) by locus.apache.org with SMTP; 16 Feb 2000 18:45:51 -0000 Received: from [206.14.85.57] (franklin-dhcp57.navis.com [206.14.85.57]) by navis380.navis.com (8.8.8/8.8.8) with ESMTP id KAA50228 for ; Wed, 16 Feb 2000 10:45:23 -0800 Mime-Version: 1.0 X-Sender: kehoe@pop.infoasis.com Message-Id: Date: Wed, 16 Feb 2000 10:30:36 -0800 To: tomcat-dev@jakarta.apache.org From: Daniel Kehoe Subject: can't dynamically load a class? Content-Type: text/plain; charset="us-ascii" ; format="flowed" I'm trying to use the method Class.forName in a servlet and it doesn't work with Tomcat (worked fine with JServ and Jrun). I get a ClassNotFoundException. It should work, right? Daniel kehoe@fortuity.com >Date: Mon, 14 Feb 2000 16:47:17 -0800 >To: tomcat-dev@jakarta.apache.org >From: Daniel Kehoe >Subject: why ClassNotFoundException on attempt to dynamically load a class? > >Why does this code throw an exception >"java.lang.ClassNotFoundException: SpecificReport"? > >String dynamicReportName = "SpecificReport"; >myReport = (myReportInterface)Class.forName(dynamicReportName).newInstance(); > >It works fine if I just instantiate the object: >SpecificReport aSpecificReport = new SpecificReport(); > >And it works fine under Jserv or Jrun. > >I hear someone asking, why does he want to do this? Answer: I want >to load a class dynamically based on a parameter passed from the >browser, like: >String dynamicReportName = request.getParameterValues("report")[0]; > >I'm using Tomcat 3.1M1 with java 1.2.2 Classic VM (build >Linux_JDK_RC3, native threads, sunwjit). What's going on that's >different? > >Thanks! > >--------------------------------------------------------------------- >To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org