Results 1 to 6 of 6

Thread: unable to determine parameter names for method

  1. #1

    Default unable to determine parameter names for method

    Hi,

    I've got the simplest throwAdvice defined:

    Code:
    <aop:config>
      <aop:pointcut id="integrationMethods" expression="execution(* my.package..integration..*(..))" />
      <aop:aspect ref="theAdvice">
          <aop:after-throwing pointcut-ref="integrationMethods" throwing="exception" method="wrapException" />
      </aop:aspect>
    </aop:config>
    
    <bean id="theAdvice" class="my.package.IntegrationLayerExceptionAdvice"/>
    the advice:

    Code:
    public class IntegrationLayerExceptionAdvice {
    
        public void wrapException(Exception exception) {
            exception = new IntegrationLayerException(exception.getMessage(), exception.getCause());
        }
    }
    The idea is to automatically wrap all exceptions coming from the integration layer.

    Deploying this under weblogic 8.1sp5 i get:

    Code:
    2006-11-08 11:37:28,842 DEBUG [org.springframework.core.LocalVariableTableParameterNameDiscoverer] - IOException whilst attempting to read .class file for class [my.package.IntegrationLayerExceptionAdvice] - unable to determine parameter names for method wrapException
    java.io.IOException: Class not found
            at org.objectweb.asm.ClassReader.a(Unknown Source)
            at org.objectweb.asm.ClassReader.<init>(Unknown Source)
            at org.objectweb.asm.ClassReader.<init>(Unknown Source)
            at org.springframework.core.LocalVariableTableParameterNameDiscoverer.visitMethod(LocalVariableTableParameterNameDiscoverer.java:98)
            at org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:50)
            at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:54)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.bindArgumentsByName(AbstractAspectJAdvice.java:370)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.calculateArgumentBindings(AbstractAspectJAdvice.java:331)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.afterPropertiesSet(AbstractAspectJAdvice.java:297)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
    The problem seems rather obscure, i could only find one related post (http://forum.springframework.org/sho...d.php?p=75684). The asm* and cglib jars are in WEB-INF/lib so i don't think the solution offered there applies.

    Thanks
    Jorg

  2. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    Try compiling IntegrationLayerExceptionAdvice with '-g' flag.

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  3. #3

    Default

    I was compiling from eclipse to WEB-INF/classes, with full debugging enabled (lines,var,source). Apparently this is the same as -g.

    However to be sure i recompiled that one class using javac -g, and it doesn't work either.

    Any other ideas what could be causing this? (before i start stepping through the ASM source *shrug*)

  4. #4
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    Your code itself looks fine. So it must be your environment (most likely conflicting versions of a library).

    As an aside: Note that your wrapException method is merely modifying the parameter so you won't get the effect of wrapping. You will need to throw the wrapped exception from your advice.

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  5. #5

    Default

    You mean conflicting versions of the ASM library? But if that was the case i wouldn't be getting a NoClassDefFound error when i remove the asm libs from my WEB-INF/lib right ?

    Actually I think now i'm getting stung by Weblogic's classloading of the EAR, i'll do some more research.

  6. #6

    Default

    Right, i've done some more digging.

    During aop init, spring calls
    Code:
    LocalVariableTableParameterNameDiscoverer.getParameterNames()
    which eventually tries to construct an instance of org.objectweb.asm.ClassReader using the full name of the class
    Code:
        public ClassReader(final String name) throws IOException {
            this(ClassLoader.getSystemResourceAsStream(name.replace('.', '/')
                    + ".class"));
        }
    The ClassLoader.getSystemResourceAsStream returns null, causing the IOException later on.

    Now getSystemResourceAsStream() uses the system classloader to find a resource, and according to http://e-docs.bea.com/wls/docs81/pro...ssloading.html WLS uses a classloader hierarchy to load eg the WAR and EJB resources. Given the visibility principle of classloaders (classes loaded by parent classloaders are visible to child classloaders but not vice versa) this would mean that the aop:config can not ever work out of the box (perhaps with MANIFEST Class-Path entries, haven't tried that yet)

    Can anyone who is more seasoned in classloader trickery confirm my findings?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •