Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Injecting Stateless EJB 3 with Spring 2.x

  1. #11
    Join Date
    Aug 2007
    Posts
    18

    Default

    Something happened (!) and I finally got it to work. As expected, you guys were right in terms of using the "jee:jndi-lookup" bean to inject an EJB 3. As I mentioned before, I've already tried that and it didn't work for me. The only plausible explanation for the error involves the way my EAR was packaged: I used the MyEclipse default which put every dependent class in the EJB jar. The classpath in the manifest file also refered to some jars within the EAR which contained some overlapping classes which could have caused the "ClassCastException"-type exception.

    However, there's one thing that I learned from this and suspect it to be true: the "jee:slsb-local" and "jee:slsb-remote" beans only work with EJB 2.x and not EJB 3. Is this correct ?

    Now, everything seems to be working fine but I still have one question: if the WAR containing the Spring MVC controller which is injected with the stateless EJB3 is packaged and deployed on a physical server separate from the server where the EJB jar is deployed, would the "jee:jndi-lookup" bean still work fine to inject the remote EJB into the controller ?

  2. #12
    Join Date
    Sep 2007
    Posts
    1

    Default

    I love these silly forum wars sooo much! Whenever there is a question regarding spring-ejb integration, there always will be 2 people in topic, "throw-away-ejb" guy and "throw-away-spring" guy. What about us, we are happy with both spring and ejb, having all needed features of JBoss server on our hosting (like clustering, JTA, transactional cache, load balancing and remote calls optimization), while having unbeleivable developers performance here, in the office - they are running lightweight Spring container with embedded Jetty directly from their IDEs and do not have to deal with endless "build-deploy-wait" cycle from the EJB world.

    tirzaman, the JndiObjectFactoryBean works like a charm with EJB3, it looks like you did not specified the proxy interface in your mapping:

    Code:
    	<bean id="beanManagerRemote"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="BeanManagerJndiName/remote" />
    		<property name="proxyInterface" value="com.company.component.BeanManager" />	
    </bean>
    You possibly missed the line in bold text.

  3. #13
    Join Date
    Mar 2006
    Posts
    11

    Default

    Hi,

    I don't know if you have solved your problem but have you tried the proxyInterface thing?

    Code:
    <bean id="clsUserDetailsService" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="xxxxx/YyyEJB/local"/>
    		<property name="lookupOnStartup" value="false"></property>
    		<property name="proxyInterface" value="com.hoi.MyClass"></property>
    	</bean>
    Cheers,
    Bora.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •