costin      2002/12/10 13:29:59

  Modified:    jasper2/src/share/org/apache/jasper/compiler Tag:
                        tomcat_4_branch Compiler.java
  Log:
  A small fix that may help resolving the ant test failures and
  debug the compile errors related with javac.
  
  In case of a compile error we'll log the config used for
  compilation ( classpath, etc ) as well as the full exception thrown
  by ant while compiling.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.18.2.8  +25 -3     
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.18.2.7
  retrieving revision 1.18.2.8
  diff -u -r1.18.2.7 -r1.18.2.8
  --- Compiler.java     24 Oct 2002 11:55:57 -0000      1.18.2.7
  +++ Compiler.java     10 Dec 2002 21:29:59 -0000      1.18.2.8
  @@ -249,6 +249,10 @@
           String javaFileName = ctxt.getServletJavaFileName();
           String classpath = ctxt.getClassPath(); 
   
  +        StringBuffer info=new StringBuffer();
  +        info.append("Compile: javaFileName=" + javaFileName + "\n" );
  +        info.append("    classpath=" + classpath + "\n" );
  +        
           String sep = System.getProperty("path.separator");
   
           StringBuffer errorReport = new StringBuffer();
  @@ -269,12 +273,15 @@
               String pathElement = tokenizer.nextToken();
               File repository = new File(pathElement);
               path.setLocation(repository);
  +            info.append("     cp=" + repository + "\n");
           }
   
           // Initializing sourcepath
           Path srcPath = new Path(project);
           srcPath.setLocation(options.getScratchDir());
   
  +        info.append("     work dir=" + options.getScratchDir() + "\n");
  +
           // Configure the compiler object
           javac.setEncoding(javaEncoding);
           javac.setClasspath(path);
  @@ -282,21 +289,28 @@
           javac.setSrcdir(srcPath);
           javac.setOptimize(! ctxt.getOptions().getClassDebugInfo() );
   
  +        info.append("    srcDir=" + srcPath + "\n" );
  +
           // Set the Java compiler to use
           if (options.getCompiler() != null) {
               javac.setCompiler(options.getCompiler());
  +            info.append("    compiler=" + options.getCompiler() + "\n");
           }
   
           // Build includes path
           PatternSet.NameEntry includes = javac.createInclude();
           includes.setName(ctxt.getJspPath());
  +        info.append("    include="+ ctxt.getJspPath() + "\n" );
   
  +        BuildException error=null;
           try {
               synchronized(javacLock) {
                   javac.execute();
               }
           } catch (BuildException e) {
               success = false;
  +            error=e;
  +            info.append("Exception compiling "  + e.toString() + "\n");
           }
   
           errorReport.append(logger.getReport());
  @@ -316,8 +330,16 @@
           if (!success) {
               Constants.jasperLog.log( "Error compiling file: " + javaFileName + " " 
+ errorReport,
                                        Logger.ERROR);
  +            Constants.jasperLog.log( "Info: " + info.toString(),
  +                                     Logger.ERROR);
  +            if( error != null ) {
  +                Constants.jasperLog.log( "Exception: ", error );
  +                error.printStackTrace();
  +            }
  +            
               errDispatcher.javacError(errorReport.toString(), javaFileName, 
pageNodes);
           }
  +
       }
   
       /** 
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to