Announcement Announcement Module
Collapse
No announcement yet.
Spring Roo application deployed on OSGi container Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Roo application deployed on OSGi container

    Does anyone know how I can deploy a Spring Roo generated application on an OSGi container? What I've done so far is create an application with just one domain object (say Customer) and a corresponding service class (CustomerService). Persistence is handled by Hibernate to a MySQL DB. I've created a bundle and exported Customer and CustomerService packages. Since Roo already created an application context for me I've added the relevant OSGi parts to expose my service. When I deploy and start my bundle everything looks OK even to the point that the Customer table in MySQL is created for me.

    The problem comes when I try execute the CustomerService.saveCustomer(customer) from a consumer bundle, I receive the error
    java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)

    I'm using Karaf (2.3.1 - with a custom feature set for Spring extender 1.2.1 and Spring 3.2.1) over Felix (but have also tried with Equinox), Roo 1.2.3, Spring 3.2.1, Hibernate (4.1.8). It would seem that the entity manager is not injected when a new instance of Customer is created on the providing bundle. Does anyone know how I can get this to work?
    Last edited by tedp; Mar 13th, 2013, 04:43 AM. Reason: add version numbers

  • #2
    Hi Tedp,

    Originally posted by tedp View Post
    The problem comes when I try execute the CustomerService.saveCustomer(customer) from a consumer bundle, I receive the error
    java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
    Any luck on this. I'm considering the same thing (but then with active records).

    Comment


    • #3
      Originally posted by HJLebbink View Post
      Hi Tedp,
      Any luck on this. I'm considering the same thing (but then with active records).
      Hoping this helps, have you looked into the Gemini Blueprint project? It was called Spring-dm. This allows you to mount your Spring beans in an OSGi container. I'm not sure if Roo can support this, but here are the docs:

      http://static.springsource.org/osgi/...-reference.pdf

      and the project:

      http://www.eclipse.org/gemini/blueprint/download/

      Bottom line, you want to extend your dependency injection into OSGi so you can expose Spring Beans, and then inject them into other Spring Beans using dynamic modules. It is rather complicated (ok, quite complicated) but once you get it working you have the ability to modularly update your bundles and inject them with Spring Beans served by other bundles. I think that's what you are going for.

      Best of luck.

      Ken

      Comment


      • #4
        Also, another quick note - Springsource used to sell a server called 'dm-server' that is now Eclipse Virgo. I have a good friend at Chariot who is a committer (Dmitry Sklyut) and this project is active.

        Virgo is an Equinox-based container with everything installed to support Spring-dm modules (Gemini), and is open source. See:

        http://www.eclipse.org/virgo/

        They have versions for deployment in tomcat, running in their own Jetty, etc...

        There is a tool that properly packages your bundle, called Bundlor, usable in the command line, ant, maven, etc... That will help you with the build.

        That will get you started a LOT quicker than hand-assembly of an OSGi container to get Spring started. See the http://www.eclipse.org/virgo/samples/ download page for completed functional samples of just what you're trying to achieve.

        Ken

        Comment

        Working...
        X