Hello,
I've tried many solutions so far and I did not succeeded, so I decided to ask you for help because I'm loosing my faith I can do this.
What I have:
- 3 EAR's with: 1) Some Stateless Beans + code which uses those beans 2) Some piece of classes using the same Beans as "1" but attached to this EAR 3) Spring 3 MVC based application + same Beans attached to this project
All three EAR's are deployed to Jboss 5.1.0.GA.
It's great that "2" EAR classes can inject Stateless beans with just "@EJB" annotation.
And now the problem. I would like to use the same beans at "3"'rd EAR - Spring MVC based" - and I would like to inject them as usual using "@EJB" annotation. I'm still failing with error:
I'm usingCode:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myFormController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbController' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ejb not bound org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:927) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) root cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myFormController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbController' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ejb not bound org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117) org.springframework.web.method.HandlerMethod.createWithResolvedBean(HandlerMethod.java:202) org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:223) org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:55) org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:297) org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1091) org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1076) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:896) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) root causeI've triedCode:context:component-scan base-package="..."andCode:<bean id="jndiFactory" class="org.springframework.jndi.support.SimpleJndiBeanFactory"> <property name="resourceRef" value="true" /> </bean>
as well as "AutowiredAnnotationBeanPostProcessor"Code:<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"> <property name="alwaysUseJndiLookup" value="true" /> <property name="jndiFactory" ref="jndiFactory" /> </bean>
andwith different jndiNames, like: "java:comp/env/<beanName>", or "java:module/<beanname>/local", or "java:global/<beanname>"....Code:<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"> <property name="alwaysUseJndiLookup" value="true" /> </bean> <bean id="dbController" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="ejb/dbControllerBean" /> <property name="resourceRef" value="true" /> </bean>
(still not sure what should be the correct name here, "2" EAR classes uses those beans just with name like "dbControllerBean" and that's all)
and few other solutions I found over then net. Still the same exception.
please help me, give me a hint... what I'm doing wrong? How it should be done in the best way?


Reply With Quote