4 Replies Latest reply on Sep 15, 2006 1:00 PM by alesj

    does spring deployer _require_ ejb?

    ddouglass

      I think I'm having a disconnect somewhere between reading the deployer docs and my execution.

      Is it possible to use the deployed/bound NamedXmlApplicationContext outside of an EJB? Specifically, is it possible for a servlet in a war to lookup the NamedXmlApplicationContext and use it to get Spring configured beans?

      TIA,
      Doug

        • 1. Re: does spring deployer _require_ ejb?
          alesj

          Sure.
          Simply do a JNDI lookup.

          Use the same jndi name as you use in @Spring annotation.

          • 2. Re: does spring deployer _require_ ejb?
            ddouglass

            Thanks for the reply Ales, and for Jboss Spring deployer ;)

            That's what I've been trying to do via unit test -- the JNDI lookup gets me back a Reference object that refers to the NamedXmlApplicationContext, but any attempt to use the object (casting to ApplicationContext or BeanFactory) fails down in the Spring AOP layers with IllegalArgumentException: object not of declared type.

            I've culled the forums (this one and others, JBoss and Spring) but have failed to find the magic to actual make use of the bound context in any meaningful way. I'm sure I'm just missing something.

            Note that the unit test I refer to is running out-of-container, but a similar "test" done via a simple deployed war is giving similar results, though I haven't configured any resource/resource-ref in web.xml, etc., yet.

            I've got several backup plans: write a simple stateless EJB wrapper that just delegates to injected deps. from the context and have the webapps use the EJB (though I'm trying to avoid EJB altogether); or, for now, I can package the context/services directly into the war and work out these details for my next iteration.

            Thanks for any help/pointers,
            Doug

            • 3. Re: does spring deployer _require_ ejb?
              ddouglass

              Never mind...for my in-container tests the problem was class loader related -- I had duplicate jars in both my .spring and .war. Removing the duplicates fixed my problems.

              Cheers,
              Doug

              • 4. Re: does spring deployer _require_ ejb?
                alesj

                 

                "ddouglass" wrote:

                That's what I've been trying to do via unit test -- the JNDI lookup gets me back a Reference object that refers to the NamedXmlApplicationContext, but any attempt to use the object (casting to ApplicationContext or BeanFactory) fails down in the Spring AOP layers with IllegalArgumentException: object not of declared type.


                Just in the process of replying to you - about class loader issues with your problem.

                Glad you fixed it. :-)