Announcement Announcement Module
No announcement yet.
TomcatInstrumentableClassLoader Only Works Sporadically Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • TomcatInstrumentableClassLoader Only Works Sporadically

    I am using aspect-j load time weaving to enable Transactional annotations for our application, however my classes are only woven roughly 40% of the time I start tomcat and it is very frustrating.

    In my META-INF context file I have the following:

    <?xml version="1.0" encoding="UTF-8"?>
    	<Loader loaderClass="org.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" />
    And then in my spring xml config file I have:

    <context:load-time-weaver aspectj-weaving="on" />
    Due to some legacy code restraints, we are unable to shutdown tomcat gracefully. Could this be the cause? Anyone else have any other ideas? I find it really bizarre that it works fine 40% of the time and doesn't do any weaving the rest of the time.


  • #2
    Yes, this could be the cause. Can you enable some debug logs, to see what the aspectj output is on tomcat restart?

    Have you tried to use the tomcat admin application? You don 't have to restart Tomcat to install a new web application or to restart an existing application.

    I would suggest that you try to restart the offending application a couple of times via the admin page and see if the problem still occurs.



    • #3
      Thanks for your response. I tried enabled debug logging for several packages, however I do not see any noticeable errors or discrepancies between the times when the classes are woven correctly and when they are not. In fact, I am not seeing any specific messages about the weaving, do you know what packages (spring or otherwise) I should enable debug logging for?

      This is not a normal webapp as it has several background threads that currently do not have any clean way to terminate when the webapp is updated and requires that tomcat be restarted.

      In any case, I have it reduced down to a very basic scenario:

      1) Stop tomcat
      2) Delete everything in the work and webapp folders
      2) Add ROOT.war to the webapps folder
      3) Start tomcat

      The problem reproduces in the above scenario so I am not sure what to do. The fact that it is sporadic is really throwing me off. It seems to happen less often when I do this from eclipse rather than from the command line, but I have no idea how that would change things.

      Any other idea?



      • #4
        Just looked back at your initial post, where you say that you are using load-time weaving for transactional annotations.

        You don't need load-time weaving for @Transactional, just add <tx:annotation-driven/>

        Anyway, if you still have issues and need AspectJ woven aspects; have you considered compile-time weaving? Can be done with Ant, Maven and most IDEs.

        Last edited by Goran; Dec 11th, 2008, 08:48 PM.


        • #5
          Thanks, I will look into compile time weaving.

          The original reason why I went with load time aspect j weaving instead of the cglib proxy route was that I was havng trouble getting the transactional attribute to inherit and I want to be able to only define the transactional attribute on the base class.