Announcement Announcement Module
Collapse
No announcement yet.
TomcatInstrumentableClassLoader Only Works Sporadically Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:

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

    Code:
    <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.

    Thanks,
    Gordon

  • #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.

    G

    Comment


    • #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?

      Thanks

      Comment


      • #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.

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

        Comment


        • #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.

          Thanks

          Comment

          Working...
          X