Announcement Announcement Module
Collapse
No announcement yet.
2.5.5 LTW Silently Failing in Tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2.5.5 LTW Silently Failing in Tomcat

    Hello all,

    So I have been working on this all day and I'm hoping somebody can shed some light on the situation. I have an application that runs fine in Tomcat 5.5.20 using Spring 2.5.0 and LTW. The way the project is laid out I'm able to run unit-tests without many configuration changes between the configuration as deployed in tomcat and when it is being exercised with the unit-tests.

    Today was upgrade day and I started with moving to Spring 2.5.5. I literally dropped the new Spring files listed below over the old ones.

    tomcat/webapps/ROOT/WEB-INF/lib/aspectjrt.jar
    tomcat/webapps/ROOT/WEB-INF/lib/spring-webmvc.jar
    tomcat/webapps/ROOT/WEB-INF/lib/spring-aspects.jar
    tomcat/webapps/ROOT/WEB-INF/lib/spring.jar
    tomcat/server/lib/spring-tomcat-weaver.jar
    tomcat/additional/lib/aspectjweaver.jar


    My unit-tests run fine but when I start Tomcat the application appears to work until I try to access it and I'm hit with NullPointerExceptions on the dependencies that Spring/AspectJ is supposed to inject with the @Configurable annotations.

    My setenv.sh is unchanged from Spring 2.5.0:

    JAVA_OPTS="-XX:MaxPermSize=128m -Xmx768m -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=29001 -Dcom.sun.management.jmxremote.ssl=false -javaagent:$CATALINA_HOME/additional/lib/aspectjweaver.jar"

    and Tomcat echos the correct command line back to me when it starts up.

    My context.xml is still set as:
    Code:
    <?xml version='1.0' encoding='utf-8'?>
    <Context path="/" debug="9" reloadable="true">
            <ResourceLink global='jdbc/dev' name='jdbc/dev' type="javax.sql.Datasource" />
            <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
                    useSystemClassLoaderAsParent="false" />
    </Context>
    What changed with LTW in Spring 2.5.5?

    Any help would be greatly appreciated.

    Thanks,
    Stan
    Last edited by stan.carney; Aug 23rd, 2008, 12:31 AM. Reason: The f'ing thing thought I was pasting URLs to other sites. Just replacing the content with my original

  • #2
    It seems (as you may have already realized) that the aspects are not getting woven.

    Can you try modifying your aop.xml to get more detailed weaver information:
    Code:
    <weaver options="-verbose -showWeaveInfo">
    -Ramnivas

    Comment


    • #3
      Thanks for your response Ramnivas. So I started over again reverting all my changes and started the process of upgrading taking smaller steps. After upgrading the libraries I ended up with the exact inverse situation I had above, Tomcat would run fine but my unit-tests would NPE on injected resources when run from Ant but not in Eclipse. I tracked the issue, well what fixed my problem, down to the fact that aspectjweaver.jar was provided as the -javaagent in both eclipse and ant it was only part of the eclipse project classpath, not the ant target that runs the unit-tests. Placing aspectjweaver.jar on the ant targets classpath caused things to work as normal.

      So ignoring my first attempt as I might have botched something when copying and upgrading the libs it appears with Spring 2.5.5 aspectjweaver.jar needs to be on the classpath and not just listed as the -javaagent?

      Thanks again,
      Stan

      Comment


      • #4
        Hi,

        I'm having basically the same problem, injection of beans into non-spring managed objects is working fine when I run unit tests, but not when running the application in appserver (Resin).
        Both executions are within my IDE (Eclipse), I am running Resin as a regular java app in Eclipse for simplicity, and the aspectj jars are on the classpath in both cases.
        When starting the unit test I have to provide the VM arg : -javaagent:${MAVEN_REPO}/org.springframework/jars/spring-agent-2.5.5.jar , otherwise there is an error message.

        In the resin execution, it picks up the ReflectiveLoadTimeWeaver automatically, however unless I supply the javaagent there is no aspectj related log output - very odd?

        Here is output from the unit test excecution (some trimming of unrelated stuff in logs to make it readable)
        Code:
        2008-10-14 18:35:51,132 INFO [main] org.springframework.context.weaving.DefaultContextLoadTimeWeaver - Found Spring's JVM agent for instrumentation
        [AppClassLoader@9fbe93] info AspectJ Weaver Version 1.6.0 built on Wednesday Apr 23, 2008 at 20:27:36 GMT
        [AppClassLoader@9fbe93] info register classloader sun.misc.Launcher$AppClassLoader@9fbe93
        [AppClassLoader@9fbe93] info using configuration file:/Users/christian/.maven/repository/org.springframework/jars/spring-aspects-2.5.5.jar!/META-INF/aop.xml
        [AppClassLoader@9fbe93] info register aspect org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect
        [AppClassLoader@9fbe93] info register aspect org.springframework.transaction.aspectj.AnnotationTransactionAspect
        2008-10-14 18:35:54,870 INFO [main] org.springframework.jdbc.datasource.DriverManagerDataSource - Loaded JDBC driver: com.mysql.jdbc.Driver
        [AppClassLoader@9fbe93] weaveinfo Extending interface set for type 'estalea.ir.am.member.domain.Member' (Member.java) to include 'org.springframework.beans.factory.aspectj.AbstractInterfaceDrivenDependencyInjectionAspect$ConfigurableDeserializationSupport' (D:\projects\spring\spring\aspectj\src\org\springframework\beans\factory\aspectj\AnnotationBeanConfigurerAspect.aj)
        [AppClassLoader@9fbe93] weaveinfo Extending interface set for type 'estalea.ir.am.member.domain.Member' (Member.java) to include 'org.springframework.beans.factory.aspectj.ConfigurableObject' (D:\projects\spring\spring\aspectj\src\org\springframework\beans\factory\aspectj\AnnotationBeanConfigurerAspect.aj)
        [AppClassLoader@9fbe93] weaveinfo Type 'estalea.ir.am.member.domain.Member' (Member.java) has intertyped method from 'org.springframework.beans.factory.aspectj.AbstractInterfaceDrivenDependencyInjectionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\beans\factory\aspectj\AbstractInterfaceDrivenDependencyInjectionAspect.aj:'java.lang.Object org.springframework.beans.factory.aspectj.AbstractInterfaceDrivenDependencyInjectionAspect$ConfigurableDeserializationSupport.readResolve()')
        [AppClassLoader@9fbe93] weaveinfo Join point 'initialization(void org.springframework.beans.factory.aspectj.ConfigurableObject.<init>())' in Type 'estalea.ir.am.member.domain.Member' (Member.java:101) advised by before advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\beans\factory\aspectj\AbstractDependencyInjectionAspect.aj:78) [with runtime test]
        [AppClassLoader@9fbe93] weaveinfo Join point 'initialization(void org.springframework.beans.factory.aspectj.ConfigurableObject.<init>())' in Type 'estalea.ir.am.member.domain.Member' (Member.java:101) advised by afterReturning advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\beans\factory\aspectj\AbstractDependencyInjectionAspect.aj:87) [with runtime test]
        and corresponding from the resin execution, with the -javaagent flag: (note the lack of "Member.java" weaving)
        Code:
        2008-10-14 19:11:05,275 INFO [main] org.springframework.context.weaving.DefaultContextLoadTimeWeaver - Found Spring's JVM agent for instrumentation
        2008-10-14 19:11:17,512 INFO [main] org.springframework.orm.hibernate3.HibernateTransactionManager - Using DataSource [DBPool[jdbc/iramDS]] of Hibernate SessionFactory for HibernateTransactionManager
        [EnvironmentClassLoader@32b694] info AspectJ Weaver Version 1.6.0 built on Wednesday Apr 23, 2008 at 20:27:36 GMT
        [EnvironmentClassLoader@32b694] info register classloader com.caucho.loader.EnvironmentClassLoader@32b694
        [EnvironmentClassLoader@32b694] info using configuration file:/Users/christian/.maven/repository/org.springframework/jars/spring-aspects-2.5.5.jar!/META-INF/aop.xml
        [EnvironmentClassLoader@32b694] info register aspect org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect
        [EnvironmentClassLoader@32b694] info register aspect org.springframework.transaction.aspectj.AnnotationTransactionAspect
        2008-10-14 19:11:31,657 INFO [main] org.springframework.security.intercept.AbstractSecurityInterceptor - Validated configuration attributes
        2008-10-14 19:11:31,777 WARN [main] org.springframework.security.intercept.AbstractSecurityInterceptor - Could not validate configuration attributes as the ObjectDefinitionSource did not return a ConfigAttributeDefinition collection
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(int $Proxy68.hashCode())' in Type '$Proxy68' (no debug info available) advised by before advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:60) [with runtime test]
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(int $Proxy68.hashCode())' in Type '$Proxy68' (no debug info available) advised by afterThrowing advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:67) [with runtime test]
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(int $Proxy68.hashCode())' in Type '$Proxy68' (no debug info available) advised by afterReturning advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:77) [with runtime test]
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(int $Proxy68.hashCode())' in Type '$Proxy68' (no debug info available) advised by after advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:82) [with runtime test]
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(estalea.base.entity.PersistentEntity $Proxy68.get(long))' in Type '$Proxy68' (no debug info available) advised by before advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:60) [with runtime test]
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(estalea.base.entity.PersistentEntity $Proxy68.get(long))' in Type '$Proxy68' (no debug info available) advised by afterThrowing advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:67) [with runtime test]
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(estalea.base.entity.PersistentEntity $Proxy68.get(long))' in Type '$Proxy68' (no debug info available) advised by afterReturning advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:77) [with runtime test]
        [EnvironmentClassLoader@32b694] weaveinfo Join point 'method-execution(estalea.base.entity.PersistentEntity $Proxy68.get(long))' in Type '$Proxy68' (no debug info available) advised by after advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (D:\projects\spring\spring\aspectj\src\org\springframework\transaction\aspectj\AbstractTransactionAspect.aj:82) [with runtime test]
        Here is the corresponding resin output *without* the -javaagent flag - no aspectj related stuff at all even though log output flags set..
        Code:
        2008-10-14 19:19:48,562 INFO [main] org.springframework.context.weaving.DefaultContextLoadTimeWeaver - Using a reflective load-time weaver for class loader: com.caucho.loader.EnvironmentClassLoader
        2008-10-14 19:19:59,525 INFO [main] org.springframework.orm.hibernate3.HibernateTransactionManager - Using DataSource [DBPool[jdbc/iramDS]] of Hibernate SessionFactory for HibernateTransactionManager
        coming_file_cache,ir_ap_incoming_file_cache_mon,ir_ap_status_page,ir_ap_conversion_file_loader]; root of factory hierarchy
        2008-10-14 19:20:01,912 INFO [main] org.springframework.ui.velocity.VelocityEngineFactoryBean - Loading Velocity config from [class path resource [velocity.properties]]
        Any help greatly appreciated,

        / Christian

        Comment


        • #5
          ok, I was able to verify that it works fine when running "pure" appserver, i.e. using a Resin installation and a war.
          So there is something in the classloading in my Eclipse/Resin setup that messes this up..

          Comment


          • #6
            I am experiencing the same issues and have not yet resolved them.

            I'm using tomcat 6.0.18, Spring 2.5, and CXF.

            I want to add the @Configurable annotations to my domain classes that are created through JAX-B.

            I have:
            tomcat/webapps/CxfPrototype/META-INF/aop.xml
            tomcat/webapps/CxfPrototype/WEB-INF/classes ... [all service class files]
            tomcat/webapps/CxfPrototype/WEB-INF/lib/Beans.jar ... [domain classes to be woven]
            tomcat/webapps/CxfPrototype/WEB-INF/lib/spring*.jar
            tomcat/lib/spring-tomcat-weaver.jar
            tomcat/lib/aspectjweaver.jar

            TOmcat is started with -javaagent:/path/to/spring-agent.jar

            Is aop.xml deployed to the correct place? Do I need a context.xml? Where exactly should it be deployed?
            Does it need to contain the line:
            <ResourceLink global='jdbc/dev' name='jdbc/dev' type="javax.sql.Datasource" />
            This is specific to Stan's application, right?

            When I turn on verbose weaving I see no difference in the log files.

            Any help is appreciated.
            Last edited by HamletDRC; Apr 9th, 2009, 12:42 PM. Reason: added startup agent info

            Comment


            • #7
              Your aop.xml isn't in the right place. It should be either:
              - In tomcat/webapps/CxfPrototype/WEB-INF/classes/META-INF/aop.xml
              or
              - In a jar file under tomcat/webapps/CxfPrototype/WEB-INF/lib (as META-INF/aop.xml)

              -Ramnivas

              Comment


              • #8
                LTW in Tomcat

                I'm having a similar problem; I have a Spring service, and I want a GWT client to be able to work with it without modifying the service's source code. The service already implements all the methods of the GWT interface; it's a matter of duck-typing.

                The Spring AOP @DeclareParents() annotation fails here, as it requires a defaultImpl argument, and none is necessary or required. So, I need to use Load Time Weaving. I have added the <context:load-time-weaving/> tag to my spring-servlet.xml file, and I have created an aop.xml file in META-INF/. (I did not put it in WEB-INF/classes/META-INF/ -- is that really necessary?)

                So, I have a HelloServiceImpl class as a Spring service, wired with some arguments in the spring-context xml file.

                Code:
                <bean name="helloService" class="com.mantech.HelloServiceImpl">
                    <property .../>
                    <property .../>
                </bean>
                
                <bean name="helloController" class="...GwtRpcController">
                    <property name="remoteService" ref="helloService"/>
                </bean>
                Code:
                public class HelloServiceImpl {
                    // This will be in a separate jar file.
                }
                changed from

                Code:
                public class HelloServiceImpl implements HelloService {
                
                }
                I have a HelloServiceIntroduction aspect:

                Code:
                @Aspect
                public class HelloServiceIntroduction {
                    @DeclareParents("HelloServiceImpl") 
                    private HelloService Service;
                }
                I have an aop.xml file

                Code:
                <aspectj>
                    <weaver>
                        <include within="com.mantech.aop.*" />
                    </weaver>
                    <aspects>
                        <aspect name="com.mantech.aop.HelloServiceIntroduction"/>
                    </aspects>
                </aspectj>
                I have modified my Tomcat definition in Eclipse to use -javaagent:.../spring-agent.jar.

                I do not get errors in the load-time-weaving process, but the wiring of helloService to helloController fails with a ClassCastException.

                Can anyone help me? Shouldn't it be easy to do duck-typing in Spring AOP?

                Comment

                Working...
                X