5 Replies Latest reply on Aug 22, 2001 8:23 PM by marc fleury

    ClassNotFoundException

    Aakash Chopra Newbie

      Hi all, I am attempting to call the following code when I get a CNFE:

      Object tempObj = Beans.instantiate (null,actionDelegateName);
      servletActionDelegate = (ServletActionDelegate)Beans.getInstanceOf(tempObj,ServletActionDelegate.class);

      The actual class exists in the appropriate package in the WEB-INF/classes directory (within a war file) but for some reason it still cannot be found....

      I've tried to include the class packaged in a jar in the jboss/lib/ext directory also - still, it cannot be found.

      Here is part of the stacktrace:

      [EmbeddedTomcatSX] java.lang.ClassNotFoundException: x.xx.xxx.actiondelegates.ProfileManagerServletActionDelegate
      [EmbeddedTomcatSX] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      [EmbeddedTomcatSX] at java.security.AccessController.doPrivileged(Native Method)
      [EmbeddedTomcatSX] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      [EmbeddedTomcatSX] at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
      [EmbeddedTomcatSX] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
      [EmbeddedTomcatSX] at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
      [EmbeddedTomcatSX] at java.beans.Beans.instantiate(Beans.java:190)
      [EmbeddedTomcatSX] at java.beans.Beans.instantiate(Beans.java:51)

      Thanks in advance for any advice!

      Buzz

        • 1. Re: ClassNotFoundException
          Atif Umar Newbie

          What Confiuration are u using , i am using jboss2.2.2/tomcat3.2.2 , i also had problems in finding the classes packaged in a jar file Actually when u start jboss-tomcat then its unable to find the jar file ,
          i tackled this problem by including the jar file in the classpath this solves the problem
          here's hwat i did in the run_with_tomcat.bat

          @echo off
          set JBOSS_CLASSPATH=%JBOSS_CLASSPATH%;%JAVA_HOME%/lib/tools.jar;%JBOSS_HOME%/deploy
          .\run.bat tomcat

          if this also dosent work then try setting the full path of ur jar file

          i hope one of the two will work
          bfn

          • 2. Re: ClassNotFoundException
            Aakash Chopra Newbie

            I am also using jboss 2.2.2-tomcat 3.2.2.

            Do you know if there is a definitive document regarding classpaths when dealing with jboss 2.2.2-tomcat 3.2.2. ?

            • 3. Re: ClassNotFoundException
              Aakash Chopra Newbie

              I believe I know what the problem is but I am unsure how to fix it....

              I make the following call:

              Object tempObj = Beans.instantiate (null,actionDelegateName);

              Becuase I pass null as the first argument, a "system classloader" is used.... but that is not necessarily the classloader that has web-inf/classes or web-inf/lib in its classpath...

              so the question is how do I get a reference to the classloader that has web-inf/classes and web-inf/lib in its classpath?

              • 4. Re: ClassNotFoundException
                Aakash Chopra Newbie

                I'm dancing a jig as I write this...

                I used the following to get the appropriate classloader:

                Object tempObj = Beans.instantiate (this.getClass().getClassLoader(),actionDelegateName);

                woo hoo!

                • 5. Re: ClassNotFoundException
                  marc fleury Master

                  That's the context class loader