Announcement Announcement Module

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Problem of Spring DM + aspectj, can anyone help me? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem of Spring DM + aspectj, can anyone help me?

    Hi guys!
    My osgi-based app structure lists below:
    bundle 1:, the interface definition of the business logic;
    bundle 2:, the implementation of the bisiness logic;
    bundle 3: WebExtension2, the web tier of the app;
    bundle 4: cn.nfs.demo.springaop, the aspects of the business logci.

    i want to weave the aspect of bundle4 into bundle2, but it fails.

    The aspect definition in bundle 4:
    package cn.nfs.demo.springaop;
    import org.aspectj.lang.ProceedingJoinPoint;
    import org.aspectj.lang.annotation.Around;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Pointcut;
    public class HelloAspect {
    	public void pointUserName(){}
    	public Object performAspect(ProceedingJoinPoint jp) throws Throwable {
    		System.out.println("In aspects!" );
    		return jp.proceed();
    The aop-beans.xml in the path: /META-INF/spring of bundle 4:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""
    	<bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator">
    		<property name="proxyTargetClass" value="true"></property>
    	<bean class="cn.nfs.demo.springaop.HelloAspect" />
    The MANIFEST.MF of bundle 4:
    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Springaop Plug-in
    Bundle-SymbolicName: cn.nfs.demo.springaop
    Bundle-Version: 1.0.0
    Bundle-Activator: cn.nfs.demo.springaop.Activator
    Bundle-RequiredExecutionEnvironment: JavaSE-1.6
    Bundle-ClassPath: .

    The biz interface definition in bundle1:

    import java.util.List;
    public interface IUserMgr {	
    	void printUserName();
    The biz implementation in bundle 2:
    public class UserMgrImpl implements IUserMgr{
    	public void printUserName() {
    		String msg = "  OiuNt   xOiuNt  ";
    id	State       Bundle
    0	ACTIVE      org.eclipse.osgi_3.4.0.v20080605-1900
    37	ACTIVE      org.eclipse.osgi.services_3.1.200.v20071203
    38	ACTIVE      cn.nfs.demo.mvc_1.0.0
    39	ACTIVE      org.eclipse.equinox.jsp.jasper_1.0.100.v20080427-0830
    40	ACTIVE      org.apache.commons.el_1.0.0.v200806031608
    41	ACTIVE      org.apache.commons.logging_1.0.4.v20080605-1930
    42	ACTIVE      WebExtension1_1.0.0
    43	ACTIVE      com.springsource.javax.servlet.jsp.jstl_1.1.2
    44	ACTIVE
    45	ACTIVE      org.springframework_2.5.6.SEC01
    46	ACTIVE      com.springsource.javax.servlet.jsp_2.1.0
    47	ACTIVE      org.springframework.osgi.extender_1.2.0.rc1
    48	ACTIVE      org.eclipse.equinox.common_3.4.0.v20080421-2006
    49	ACTIVE      org.eclipse.equinox.http.jetty_1.1.0.v20080425
    50	ACTIVE      com.springsource.javax.servlet_2.5.0
    51	ACTIVE      org.springframework.osgi.core_1.2.0.rc1
    53	ACTIVE      WebExtension2_1.0.0
    54	ACTIVE      cn.nfs.demo.mvc.util_1.0.0
    55	ACTIVE      org.eclipse.equinox.jsp.jasper.registry_1.0.0.v20080427-0830
    56	ACTIVE      org.eclipse.equinox.http.registry_1.0.100.v20080427-0830
    57	ACTIVE
    58	ACTIVE      org.mortbay.jetty_5.1.14.v200806031611
    59	ACTIVE      com.springsource.javax.el_1.0.0
    60	ACTIVE      org.apache.jasper_5.5.17.v200806031609
    61	ACTIVE      org.springframework.web.servlet_2.5.6.SEC01
    62	ACTIVE      org.eclipse.equinox.registry_3.4.0.v20080516-0950
    63	ACTIVE      org.springframework.osgi.web_1.2.0.rc1
    64	ACTIVE      org.springframework.osgi.io_1.2.0.rc1
    65	ACTIVE      org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830
    66	ACTIVE
    67	ACTIVE      org.eclipse.osgi.util_3.1.300.v20080303
    69	ACTIVE
    72	ACTIVE      org.springframework.aspects_2.5.6.SEC01
    73	ACTIVE      cn.nfs.demo.springaop_1.0.0

    When i invoke the method UserMgrImpl.printUserName() in web tier, the HelloAspect of bundle 4 does not execute.
    In addition, i implement another aspejct bundle using eclipse aspectj, and it works. However, i think maybe it's hard to incorporate with spring based apps, so i try to use the spring aop form of aspectj.
    Could anyone help me to find out the problem? If the information isn't enough, i will send more information or the whole application.
    Thanks very much!


  • #2
    I haven't actually used AspectJ myself, only other technologies that use it, but I'd guess that the annotations don't get picked up by the AspectJAutoproxyCreator. Do you have set any <context:component-scan> in your configuration?
    Also, what environment do you run your application in? I found that component-scan sometimes doesn't work correctly when run from Eclipse. To get this to work, you may try to add the folder containing the compiled classes ('bin' by default, but may also be called 'target/classes', 'build' or such) to the bundles manifest.

    Best regards


    • #3
      Thanks, Marcus!
      i have tried your suggestion, but it doesn't work.


      • #4
        Osgi with Spring DM and Spring AOP problem


        has anyone tried out load time weaving in an osgi environment using org.eclipse.equinox.weaving.springweaver and not the aspectj weaver? I have managed to make things work with org.eclipse.equinox.weaving.aspectj plugin but not with the springweaver alternative. I need this because I'm using Spring DM and I want to weave, in some bundles, services created by Spring DM. I have read that its possible to do so. Is there any configuration I'm missing at the bundle that needs to be weaved? For the time I only have configured the bundle that contains the aspects with: <context:load-time-weaver weaver-class="org.eclipse.equinox.weaving.springweaver.Eq uinoxAspectsLoadTimeWeaver" /> and I have added a required plugin dependency to this plugin from the one that needs to be weaved.

        Thanks in advance! Any help will be highly appreciated (I've been searching for weeks)