开发者

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 no开发者_如何学Ct 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!)


I was having this same issue and fixed it by doing Spring Tools | Enable Spring Aspects Tooling on my project.

My classes were generated by Roo and pushed in (I was having way too many issues with it), and I simply added them to a brand new Google Web Application Project I created (so it uses GAE's app layout with a war directory, and no Maven for anything, at least not yet).


You have to create the repository for the indicate domain.

In roo-terminal run the follow script

es.

 repository jpa --interface ~.dao.MyDomainDAO --entity ~.domain.MyDomain
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜