Thanks Craig,

I installed rc2 but still get the same NoClassDefFoundError problem.  The
problem is with a static comparator object that I use to sort the results of
a jdbc call.  Maybe I have my classpath somehow different in 3.2.1 so that
it finds it OK, but not in 4.0 rc2, but it looks like the application jar
file is only in .....webapps/app/WEB-INF/lib in both cases.

Can you tell what is causing the GROSS_ORDER comparator to not be found? It
is finding the other classes in the jar file -- is there some problem
because the GROSS_ORDER "object" is static (You said that the Repository$1
in the traceback indicates that the problem might be an inner class called
within Repository -- is GROSS_ORDER an inner class of sorts?).

I vaguely recall some warnings about proper use of static comparators when
learning how to use them from the Java tutorial.

Thanks much,

Jeff Pittman

p.s., just in case you were wondering, the reason for
"java.lang.NoClassDefFoundError: com/company/project/Repository$1" in the
traceback below is because of my mistake of typing slashes in camoflaging
the real path names.

---------------------------------
  Repository class, generisized
---------------------------------
import java.util.*;
import java.sql.*;

public class Repository {
  private static Repository instance;

  private static final String driver = "org.postgresql.Driver";
  private static final String user= "postgres";
  private static final String pass = "";
  private static final String dbURL = "jdbc:postgresql://localhost/app";

  private Connection connection;
  private PreparedStatement getStatement;

  // many more prepared statements.....

  public static Repository getInstance()
    throws RepositoryException {
    if (instance == null)
      instance = new Repository();
    return instance;
  }

  private Repository() throws RepositoryException {
    String get="SELECT * FROM List WHERE ID=?";

    // many more SQL statement strings....

    try {
      Class.forName(driver);
      connection = DriverManager.getConnection(dbURL, user, pass);
      getStatement = connection.prepareStatement(get);

      // many more prepared statement calls....

    }
    catch (ClassNotFoundException e) {
      throw new RepositoryException("No Driver Available!");
    }
    catch (SQLException se) {
      throw new RepositoryException(se.getMessage());
    }
  }

  // inside the body of the class there are methods for setting
  // the parameters of the prepared statements and calling them, but
  // one of the error reports indicated that the following is the culprit:

  // If you look at the traceback below, this line is line 304:
  static final Comparator GROSS_ORDER = new Comparator() {
    public int compare(Object o1, Object o2) {
      ResultsBean r1 = (ResultsBean) o1;
      ResultsBean r2 = (ResultsBean) o2;
      Integer g1 = new Integer(r1.getValue());
      Integer g2 = new Integer(r2.getValue());
      return g1.compareTo(g2);
    }
  };

  // here's where the comparator is used:

  public ResultsBean[] getResults()
    throws RoundListRepositoryException {

    ResultsBean[] day1Results = getResultsForDay(2);
    ResultsBean[] day2Results = getResultsForDay(3);
    ArrayList combinedResults = new ArrayList();
    for (int i=0; i<day1Results.length; i++) {
      ResultsBean day1ResultsBean = day1Results[i];
      ResultsBean day2ResultsBean = getDay2ResultsBean(day2ResultsBean);
      if (day2ResultsBean != null) {
        ResultsBean resultsRecord = new ResultsBean();
        resultsRecord.setName(day1ResultsBean.getName());

        // more parameter sets here

        combinedResults.add(resultsRecord);
      }
    }
    Collections.sort(combinedResults,GROSS_ORDER);
    return (ResultsBean[])combinedResults.toArray(new ResultsBean[0]);
  }
}

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Craig R.
McClanahan
Sent: Saturday, September 15, 2001 12:59 PM
To: [EMAIL PROTECTED]
Subject: Re: moving webapps from tc 3.2.1 to 4.0-b7




On Sat, 15 Sep 2001, geojeff wrote:

> Date: Sat, 15 Sep 2001 12:28:26 -0500
> From: geojeff <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: moving webapps from tc 3.2.1 to 4.0-b7
>
> Greetings,
>
> My problem is that under 4.0-b7 _some_ of my application classes are not
> getting found.
>

There have been some changes in class loading since beta-7 -- please try
it with RC2.

> The webapp works fine under 3.2.1.  Classes are held in a single jar,
which
> is placed in /usr/local/jakarta-tomcat/webapps/app/WEB-INF/lib.
>
> I installed 4.0-b7 (I know that rc2 is newest, but assume that isn't
> problem), and then copied webapp directories from the 3.2.1 webapps
> directory into the 4.0-b7 webapps directory
> (/usr/local/jakarta-tomcat-4.0-b7/webapps).  I recompiled are rejarred
> first, using the servlet.jar for 4.0-b7 in my compile classpath.

Although there is nothing wrong with this, it is not necessary.  Tomcat 4
will run webapps built for servlet 2.2 / JSP 1.1 as well as those compiled
against the new servlet.jar file.

> CATALINA_HOME set fine, etc., as 4.0-b7 does work initially for my
webapp --
> Stopping 3.2.1 and restarting 4.0-b7 works fine on the first call to a
> servlet, but there is a class-not-found error for a servlet class called
on
> the next click.  The class that isn't getting found is a repository class
> for jdbc.
>
> Another odd thing, is that once I start attempting the upgrade to 4.0-b7,
> and then punt and go back to running 3.2.1, I also get the same
> class-not-found error under 3.2.1, but it goes away if I recompile, rejar,
> and redeploy the jar, and then restart 3.2.1.
>
> Anyway, eager to make the upgrade, but I'm having to step back to 3.2.1
each
> time I try.
>

Note that NoClassDefFoundError does *not* mean that the named class is not
found (com/company/project/Repository$1) -- why the slashes instead of
dashes in your class names? -- instead, it means a class *referenced* by
that class cannot be found.  The $1 implies that it's an inner class you
create somewhere inside Repository, which should help you track down what
reference is not being found.

Make sure there is nothing in your system extensions directory, either
($JAVA_HOME/jre/lib/ext).

> The traceback is included below.
>
> Thanks for any help,
>
> Jeff Pittman
>

Craig

> --------------------
>  StandardWrapperValve[resultslist]: Servlet.service() for servlet
> resultslist threw exception
> javax.servlet.ServletException: Servlet execution threw an exception
>         at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:269)
>         at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:193)
>         at
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:243)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:215)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2314)
>         at
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
> )
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :163)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
>
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> 1000)
>         at
>
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1093
> )
>         at java.lang.Thread.run(Thread.java:484)
> ----- Root Cause -----
> java.lang.NoClassDefFoundError: com/company/project/Repository$1
>         at com.company.project.Repository.<clinit>(Repository.java:304)
>         at
> com.company.project.GetResultsCommand.execute(GetResultsCommand.java:19)
>         at
com.company.project.ServerServlet.service(ServerServlet.java:102)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:247)
>         at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:193)
>         at
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:243)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:215)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2314)
>         at
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
> )
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :163)
>         at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
>         at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
>         at
>
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> 1000)
>         at
>
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1093
> )
>
>

Reply via email to