Announcement Announcement Module
Collapse
No announcement yet.
Bean Instantiation Error within RCP OSGI Environent when using AOP Pointcuts Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bean Instantiation Error within RCP OSGI Environent when using AOP Pointcuts

    Hi all,

    Im doing a Project where we build an Eclipse RCP Application using Spring. Were using Gemini Blueprint for registering OSGI Services as Spring Beans. We use AOP for intercepting method invocations on Services which are hosted withn a Web Application.

    After upgrading to Spring 3.1.1 I face an Exception when loading the Spring Application Context. The context definition is

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      	xmlns:context="http://www.springframework.org/schema/context"
      	xmlns:osgi="http://www.springframework.org/schema/osgi"
      	xmlns:aop="http://www.springframework.org/schema/aop"
      
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
                http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
    
    	<bean id="dummyServiceImpl" class="service.DummyServiceImpl" />
    
    	<osgi:service id="dummyService" interface="service.IDummyService" ref="dummyServiceImpl" />
    
    	<bean class="remote.impl.MyRemoteServiceImpl" id="remoteService"/>
    
    	<bean class="handler.MyMethodInterceptor" id="myInterceptor" />
    
    	<aop:config>
    	        <aop:advisor
                advice-ref="myInterceptor"
                pointcut="execution(* remote.impl.MyRemoteServiceImpl.*(..))" />
    	</aop:config>
    </beans>
    where
    • MyRemoteService is some type that should be intercepted
    • service.IDummyService is an Interface that is exported as an OSGI Service and
    • handler.MyMethodInterceptor an MethodInterceptor that intercepts invocations on MyRemoteService

    When running the application an exception with the following stacktrace is thrown
    Code:
    Caused by: java.lang.IllegalArgumentException: warning no match for this type name: remote.impl.MyRemoteServiceImpl [Xlint:invalidAbsoluteTypeName]
    	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:302)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:255)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:209)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263)
    	at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

    This works with Spring 3.0.2. Does anyone know this Problem and can help?

  • #2
    Can I suggest enabling the log "org.springframework.aop.aspectj" to debug?

    I faced a similar problem recently in JBoss. Basically I had a datasource bean which came back as an instance of an ironjacammar class. Aspectj tried to check the class hierarchy of every bean and failed on the datasource because the classloader of aspectj couldn't see the class of the datasource. Then apparently aspectj tried to evaluate the pointcut expression using the classloader of the datasource and it gave me the same error as you (because my beans weren't in the classpath of the datasource it couldn't find any of my classes and said nothing matched the expression). See AspectJExpressionPointcut.matches() for code.

    My solution was to let my application see the class hierarchy of the datasource object by adding the datasource library as a dependency (i.e. putting the offending class in my classpath). In your case, does the osgi return a bean with class which is not in your application? Maybe you can check what type it has and if you can do some reflection on it. Either way, the above log should give you more information to debug.

    Originally posted by Rijndael View Post
    Hi all,

    Im doing a Project where we build an Eclipse RCP Application using Spring. Were using Gemini Blueprint for registering OSGI Services as Spring Beans. We use AOP for intercepting method invocations on Services which are hosted withn a Web Application.

    After upgrading to Spring 3.1.1 I face an Exception when loading the Spring Application Context. The context definition is

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      	xmlns:context="http://www.springframework.org/schema/context"
      	xmlns:osgi="http://www.springframework.org/schema/osgi"
      	xmlns:aop="http://www.springframework.org/schema/aop"
      
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
                http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
    
    	<bean id="dummyServiceImpl" class="service.DummyServiceImpl" />
    
    	<osgi:service id="dummyService" interface="service.IDummyService" ref="dummyServiceImpl" />
    
    	<bean class="remote.impl.MyRemoteServiceImpl" id="remoteService"/>
    
    	<bean class="handler.MyMethodInterceptor" id="myInterceptor" />
    
    	<aop:config>
    	        <aop:advisor
                advice-ref="myInterceptor"
                pointcut="execution(* remote.impl.MyRemoteServiceImpl.*(..))" />
    	</aop:config>
    </beans>
    where
    • MyRemoteService is some type that should be intercepted
    • service.IDummyService is an Interface that is exported as an OSGI Service and
    • handler.MyMethodInterceptor an MethodInterceptor that intercepts invocations on MyRemoteService

    When running the application an exception with the following stacktrace is thrown
    Code:
    Caused by: java.lang.IllegalArgumentException: warning no match for this type name: remote.impl.MyRemoteServiceImpl [Xlint:invalidAbsoluteTypeName]
    	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:302)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:255)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:209)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263)
    	at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

    This works with Spring 3.0.2. Does anyone know this Problem and can help?

    Comment

    Working...
    X