Spring aspectj jar not configured correctly

I am getting this error when I tried to use a JPA object created by Roo.

Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)

I have followed some online advice to add the spring-aspects.jar to aspectj path in Eclipse but I still get this error. Does anyone know how to solve this?

The environment I am using is Spring 3.0.5, Hibernate 3.6 and JBoss 6.0.0.Final.


Go to STS ROO console (right click in the project in STS, then Spring Tools, then Open Spring Roo) Type in the prompt perform clean (will perform Maven clean) Then type perform eclipse

It should work!


Looks like you haven't injected Entity Manager.

Webapps (possible causes):

  • You didn't add entity manager factory to your applicationContext.xml
  • Java Applications :

  • You didn't add entity manager factory to your applicationContext.xml
  • Wrong application initialization (see below)

    public class SampleApp {
        public static void main(String[] args) {
            SampleApp obj = new SampleApp();
    
            // Injecting dependencies into application
            ConfigurableApplicationContext applicationContext = 
                    new ClassPathXmlApplicationContext("<PATH-TO>/applicationContext.xml");
            applicationContext.registerShutdownHook();
            applicationContext.getBeanFactory().autowireBeanProperties(
                    obj, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
    
            // Do the work
        }
    }
    

  • I had this problem too, and found the answer here: http://whyjava.wordpress.com/2012/02/13/fixing-exception-entity-manager-has-not-been-injected-is-the-spring-aspects-jar-configured-as-an-ajcajdt-aspects-library/

    In my case, I needed to create a file called <classname>_Roo_Configurable.aj with the following content:

    privileged aspect <classname>_Roo_Configurable { declare @type: <classname>: @Configurable; }

    This explained why existing classes worked but new ones that I had created did not. The _Configurable.aj file did not (and still does not) show up in the package explorer in STS.

    (I know this answer is incredibly late but I hope it helps someone else!)

    链接地址: http://www.djcxy.com/p/4330.html

    上一篇: 将一些OpenCV处理添加到gstreamer视频流

    下一篇: Spring的aspectj jar配置不正确