Announcement Announcement Module
Collapse
No announcement yet.
Do EJBs implemented with Spring need a EJB container Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Do EJBs implemented with Spring need a EJB container

    Hi,
    I read over here in spring docs http://static.springsource.org/sprin...rence/ejb.html that you can implement EJBs. Does this require to be deployed on a application server /EJB container. Or does the spring container manage these EJBs. ?

    2) If a app server/ EJB container is required. Does it mean that 2 containers are started by the appserver (the EJB container and the Spring container.) Can beans in the spring application context call EJBs managed by the EJB container.

    thanks,
    Parag

  • #2
    For EJBs (implemented with or without spring) you need an EJB container. So yes you need a full blown J2EE server...

    EJB Container != Spring Container (there is no such thing as a Spring Container, there is an applicationcontext which can be started by yourself, an ejb or war)...

    Comment


    • #3
      If you have to use EJB, then you can still use Spring to reference those beans and you can also delegate to Spring from an EJB. The real question is: do you need EJBs? there's nothing that you can do in an EJB that you can't do in Spring (transactions, remoting, business logic, etc.) (and usually with more flexibility!). Additionally, once you've started keeping your business logic in Spring, then you no longer need a full blow JavaEE/J2EE server. Heck, you don't even *need* a server! - just Java and maybe Tomcat, too ;-)

      Comment


      • #4
        thanks for the reply, the reason I had asked this question was we were trying to find out if there was a way to integrate a big chunk of legacy EJB code in our spring based application without having to rewrite it. You say "you can still use Spring to reference those beans" . Can references to EJBs managed by a container other than spring's be injected into my Spring beans.

        Comment


        • #5
          Yeah - of course. You can simply use the <jee:local-slsb id="myComponent" jndi-name="ejb/myBean" business-interface="com.mycom.MyComponent"/>, <jee:remote-slsb id="myComponent" jndi-name="ejb/myBean" business-interface="com.mycom.MyComponent"/> namespace elements and inject an EJB that way. Alternatively, if the bean is an EJB 3.0 bean, then you could also more than likely get it to work on Spring directly pretty easily, as Spring supports the transaction annotations and can be made to treat other annotations as stereotypes for Spring beans. If you're using JPA, then you can use @PersistenceContext in both Spring and EJB and the result is effectively the same, too. Also, @EJB-style injection can easily be find-and-replaced with @javax.inject.Inject or Spring's @Autowired. Let me know if this helps.

          Comment


          • #6
            This is as close as i have found something to be related to my problem. I have pretty much the same question, only i've realized that i'm to use jee:local-slsb, but i can't access my bean via jndi! On the bad side, i'm using jaxws definition of service(i wrote a web service, my serviceImpl is a spring bean, but my business logic is EJB3.0, and i can't seem to get EJB's injected into serviceImpl. Even worse is that i'm not sure whether or not i am allowed to do that jee:local-slsb, and then pass that bean as a property to service bean...). I would much appreciate any sort of help regarding the issue...I am also using smart context, so maybe there could be the glitch...i have no idea...i'm as stuck as you can get...

            Comment

            Working...
            X