4 Replies Latest reply on Aug 8, 2006 12:00 PM by jaboj

    Spring integration and embeddable EJB3

    jaboj

      HI,

      I'm trying to use the spring integration with the embeddable EJB3. How can I make my spring-context available on the JNDI-tree so that this sentence will return an spring wired object:

      @Spring(jndiName="myapp", bean="DaoFactory")

      This injection work fine when running on the application server, but how can I make it work when running from a standalone java app?

      Anyone has an idea?

      Regards
      jaboj

        • 1. Re: Spring integration and embeddable EJB3
          alesj

          You have two options:

          - you must add Spring deployer into the embeddable EJB3 mix.
          And then add SpringInterceptor into ejb3-interceptors-aop.xml (see how this is done in app. server).

          - or include jboss-spring-jdk5.jar into classpath and use Spring<Lifecycle|Passivation>Interceptor as EJB3 uses interceptors.
          But be sure you deploy/bind your spring-context (BeanFactory or ApplicationContext) under specified jndi name (see @Spring jndiName and SpringInjectionSupport).

          • 2. Re: Spring integration and embeddable EJB3
            jaboj

            HI,

            About my first option: I've no clue how to mix the spring deployer into the embeddable EJB3. Anyone?

            The second option seems more easy. However, it seems to be difficult to bind a BeanFactory or ApplicationContext in JNDI, because they're not Serializable. I've tried to use the SpringBeanFactoryDeployerImpl class in the spring-deployer jars, but without luck.

            How can I from my standalone environment load the spring ApplicationContext or BeanFactory?

            Regards
            Jacob Boje

            • 3. Re: Spring integration and embeddable EJB3
              alesj

              For the 2nd option:
              look at NonSerializableFactory.rebind(ctx, name, beanFactory);

              • 4. Re: Spring integration and embeddable EJB3
                jaboj

                HI,

                YES ITS WORKING!. Just the method I needed!

                Actually both options it working (with or without the SpringLifecycleInterceptor), after I mixed the spring-deployer into the embeddable EJB3.

                Thank you very much, especially for your very fast answers.

                Regards
                Jacob Boje