Announcement Announcement Module
No announcement yet.
How to call Roo project jar in another project. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to call Roo project jar in another project.


    I have created a JAR for one of the Spring roo project, now i want to include this jar into another Spring project, so when i include this jar and call the controller Spring roo project it is throwing me an exception saying "Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)",
    the controller in Roo project is like this
    @RequestMapping(value = "/services/getContacts/", method = RequestMethod.GET)
    public List<BIService> getContacts(@Valid Service biService) {

    List<Service> ServiceList = biService.findContacts(
    biService.getLoginName(), biService.getEmailAddress(),

    return biServiceList;

    Please help me out as in how i can make a successful call to this controller.

  • #2
    You can wait to the next release of Roo (1.2) that will come with Maven multimodule support.

    In the meantime, You can import a Roo project into another if you export the former as JAR, then use it in the later as a Maven dependency, for instance.

    Take into account that Roo builds projects with annotation driven, AspectJ and a lot of features that you'll have to configure if the first project wasn't built using Roo.

    You also have to consider the nrxt issues:
    - persistence.xml: remove the one in the JAR created with Roo and use one in your main project. Otherwise, the JPA scanning of annotated entities will use the JAR as classpath and your annotated entities within the main application won't be found.
    - In order to find the JPA entities within the JAR, you have to add <class> entries in the persistance.xml of your main project.
    - It's recommended to rename the application contrxt files in the JAR. You can even remove them provided the main application has the appropriate configuration.
    - The Roo entities have to be autowired. Include them in the autowiring classpath.

    Maybe it's the cause of the problem that you've reported.

    - In a web application a conversionService could be needed. In a main Roo project just copy the code from your ApplicationSetviceFactoryBean files (both .aj and .java) to the java one in your project. If your project was not built with Roo, configure irs mvc tag to use the conversionService within theexternal Roo JAR. I asume you're using Spring 3.
    - I forgot to mention that the Roo JAR file should be created using MAVEN, in order to let the aspectj-pluging to generate the corresponding aop.xml files.

    I hope it helps you.

    If you share your project (backup with Roo or similar) I could see something else.


    NOTE to the Roo team: importing a Roo project into another projects is a very interesting feature. It allows an organization to create a library of sharable Java code.

    That's why I'm looking forward the new Roo release, 1.2.

    Regards (and good job in any case)


    • #3
      Using Roo project as a jar dependency in another project does not work


      I am using a Roo 1.1.5 project to create a JPA setup.

      This project I am adding into a second Maven project as a dependency.

      When trying to do use the JPA stuff in the second project, I receive
      the error " Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)".
      In the second project, I used in the beginning of my main method:
      ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath*:**/applicationContext.xml");

      So the spring things seems to be started up.

      And I added the dependency:

      But when doing something like oneOfMyObjects.persist() the mentioned error
      " Entity manager has not been injected ..." pops up.

      I was thinking the Roo project uses compile time weaving,
      so the roo project .jar includes everything that is needed.

      But this seems not to be the case?

      How to solve this error?

      Adding extra weaving in the second projects?
      What maven dependencies to add?

      Thanks for helping here,


      • #4
        Try the steps I mentioned in my post. They worked for me.

        However, the best option is to use the new Roo version, 1.2, and take advantage of the maven multi-module feature.

        It works without the need of manually change the configuration files. You only need to install (mvn install) the modules that you depend on before making use of them.