Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] TOMCAT_CLASSPATH error on proceed()

Hello all,
    I'm having a unique problem with the proceed() call inside of an around() advice.  My problem is that when execution reaches the proceed() call I get an error that a class is not found, even though the class is contained in the same file as main().  I have tried manually adding that specific class to my TOMCAT_CLASSPATH variable and the program will run, but then weaving does not take place.  The real bugger here is that I am running a custom Tomcat which has several startup and variable scripts.  If I run my program on a normal Tomcat instance everything works fine, it is only this custom Tomcat that gives me headaches.  My best guess is that I have competing CLASSPATH variables and that when proceed is called, it calls an empty or near empty classpath variable.  Any ideas?

Thanks for the help!
Tyler

Here is the code I'm using:

ASPECT:
import java.util.Date;

public aspect TimerTest{
    pointcut greeting():
        execution(void com.alhadef.*.*(..));
   

    after() returning() : greeting()
    {
        System.out.println(new Date() + " ASPECT: Exiting: " + thisJoinPoint);
    }

    void around(): greeting()
    {
        System.out.println("DEBUG: In around advice");
        long start = getTime();
        System.out.println("DEBUG: start = " + start);
        proceed();
        System.out.println("DEBUG: proceed comlpete");
        long timeTaken=getTime()-start;
        System.out.println("TIMER: "+ new Date()+" "+ thisJoinPoint + " took: " + timeTaken + "millisec." );
       
       
    }

    public long getTime()
    {
        return System.currentTimeMillis();
    }
     
}


JAVA (this is long, sorry):
/*
 * Simple Struts test webapp.
 */

package com.alhadef;

import java.io.*;
import java.net.*;
import java.util.Date;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import java.util.Vector;

/**
 *
 * @author salhadef
 * @version
 */



public class LifeCycleTest extends HttpServlet implements LifeCycleTestMBean{
   
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     */
   
    MBeanServer mBeanServer = null;
 
   
    //int[] container = new int [10];
    Vector<Object> container = new Vector<Object>();
    public void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
       
        //mBeanServer = MBeanServerFactory.createMBeanServer("com.alhadef");
        //mBeanServer.registerMBean(new );
      
       
       
       
        LifeCycleTest myMain = new LifeCycleTest();
       
    myMain.printOut2000();
    myMain.printOut1000();
       
       
        System.out.println("TYDEWITT: Trying to access containter in main...");
        System.out.println(new Date() + " TYDEWITT: container.size= "+ myMain.container.size());
       
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet LifeCycleTest</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>LifeCycleTest executed at " + new Date() + "</h1>");
        out.println("</body>");
        out.println("</html>");
       
       
        System.out.println("TYDEWITT: About to sleep....");
       
        try
        {
        Thread.sleep(5000);
        }
        catch(Exception e)
        {
        }
       
       
       
        System.out.println("TYDEWITT: Done sleeping....");
        System.out.println("TYDEWITT: At end of main()....");
       
       

        out.close();
    }
   
    public void init(ServletConfig config) throws ServletException
    {
        System.out.println("ALHADEF: init(config) called...");
        System.out.println("TYDEWITT: init(config) called...");
        super.init(config);
    }
   
    public void init() throws ServletException
    {
        System.out.println("ALHADEF: init() called...");
        System.out.println("TYDEWITT: init() called...");
        super.init();
    }
   
    public void destroy()
    {
        System.out.println("ALHADEF: destroy() called...");
        System.out.println("TYDEWITT: destroy() called...");
        super.destroy();
    }
   
    private void printOut2000()
    {
        for(int i=0; i<2000; i++)
        {
            container.add(new MemoryConsumer());
                }
                //System.out.println("TYDEWITT: after Printout 2000: container.size= "+ c.size());
    }
   
    private void printOut1000()
    {
        for(int i=0; i<1000; i++)
        {
            container.add(new MemoryConsumer());
        }
                //System.out.println("TYDEWITT: after Printout 1000: container.size= "+ c.size());
    }
   
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
   
    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
   
    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>
}
class BadBoy{
    public BadBoy()
    {
        new MemoryConsumer();
        //System.out.println("TYDEWITT:In BadBoy");
    }
}

class GoodBoy
{
    public GoodBoy()
    {
        new MemoryConsumer();
        //System.out.println("TYDEWITT:in GoodBoy");
    }
}

class MemoryConsumer
{
    public static final int MEMORY_BLOCK = 1024;
    public long[] memoryHoldingArray;

   MemoryConsumer()
   {
       memoryHoldingArray = new long[MEMORY_BLOCK];
   }
}

class MemoryConsumer2
{
   

   MemoryConsumer2()
   {
       new MemoryConsumer();
   }
}


Back to the top