Facing a issue while trying to have a EJB communicate with a Spring Bean
Scenario:
I have implemented an EJB in the EJB module and want it to communicate with the Spring bean (I followed the instructions in the article - http://static.springsource.org/sprin...rence/ejb.html) i.e.
<beans>
<bean id="ejbSpringIOC" class="org.springframework.context.support.ClassPa thXmlApplicationContext">
<constructor-arg>
<list><value>com/sample/utility/samplecontext.xml</value></list>
</constructor-arg>
</bean>
</beans>
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.clas s)
public class SampleSessionEJB implements SampleSessionEJBRemote, SampleSessionEJBLocal {
@Autowired
private OneBean oneBean;
public SampleSessionEJB() {
System.out.println("AAAAA::>> Constructing SampleSessionEJB");
}
public EmployeeDTO getEmployee(EmployeeSearchDTO empSearchDTO){
System.out.println("AAAAA::>> Inside SampleSessionEJB.getEmployee");
EmployeeDTO responseDTO = new EmployeeDTO();
responseDTO.setEmpId(101);
responseDTO.setEmpName("AHMAD");
System.out.println("AAAAA::>>Calling Spring Bean - OneBean");
System.out.println(oneBean.addNumbers(4, 5));
System.out.println("AAAAA::>> Exiting SampleSessionEJB.getEmployee");
return responseDTO;
}
}
The Result:
During the startup, there is no issue, the application starts up perfectly.
But, when I access the EJB from a client application, I can see
a. the constructor of EJB getting invoked
b. but immediately after that, I get few more Spring Framework related log messages which loads the beans
c. and then I get the following error (please see the error trace, for understanding sake, I have given the call trace here)
/************************************************** */
SystemOut O EJB Lookup successful
SystemOut O Invoking the EJB Business method
SystemOut O AAAAA::>> Constructing SampleSessionEJB
00000020 XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions Loading XML bean definitions from URL [wsjar:file:/E:/Program Files/IBM/SDP/runtimes/base_v7/profiles/AppSrv01/installedApps/gh-vdikcisv41Node03Cell/Sample.ear/SampleEJB.jar!/beanRefContext.xml]
00000020 ClassPathXmlA I org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=1517771383]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [ejbSpringIOC]; root of BeanFactory hierarchy
00000020 ClassPathXmlA I org.springframework.context.support.AbstractApplic ationContext refresh 1 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=1517771383]
00000020 ClassPathXmlA I org.springframework.context.support.AbstractApplic ationContext initMessageSource Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@697e697e]
00000020 ClassPathXmlA I org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@5e705e70]
00000020 DefaultListab I org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [ejbSpringIOC]; root of BeanFactory hierarchy]
00000020 XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions Loading XML bean definitions from class path resource [com/sample/utility/samplecontext.xml]
00000020 ClassPathXmlA I org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=86902062]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [twoBean,oneBean]; root of BeanFactory hierarchy
00000020 ClassPathXmlA I org.springframework.context.support.AbstractApplic ationContext refresh 2 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=86902062]
[1/4/11 19:58:06:757 IST] 00000020 ClassPathXmlA I org.springframework.context.support.AbstractApplic ationContext initMessageSource Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@47744774]
[1/4/11 19:58:06:757 IST] 00000020 ClassPathXmlA I org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@4f594f59]
00000020 DefaultListab I org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [twoBean,oneBean]; root of BeanFactory hierarchy]
00000020 FFDCJanitor I com.ibm.ws.ffdc.impl.FFDCJanitor doCleanupIfNeeded FFDCJANITOR_DELETED_FILES
00000020 DMAdapter I com.ibm.ws.ffdc.impl.DMAdapter getAnalysisEngine FFDC1009I: Analysis Engine using data base: E:\Program Files\IBM\SDP\runtimes\base_v7\profiles\AppSrv01\p roperties\logbr\ffdc\adv\ffdcdb.xml
00000020 FfdcProvider I com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on E:\Program Files\IBM\SDP\runtimes\base_v7\profiles\AppSrv01\l ogs\ffdc\server1_18ce18ce_11.01.04_19.58.06.907172 70.txt com.ibm.ejs.container.EJSHome.createBeanO 1023
00000020 BusinessExcep E CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "getEmployee". Exception data: javax.ejb.EJBException: session bean post construct failure; nested exception is: java.lang.IllegalArgumentException: Name must not be null
java.lang.IllegalArgumentException: Name must not be null
at org.springframework.util.Assert.notNull(Assert.jav a:113)
at org.springframework.beans.factory.BeanFactoryUtils .transformedBeanName(BeanFactoryUtils.java:59)
at org.springframework.beans.factory.support.Abstract BeanFactory.transformedBeanName(AbstractBeanFactor y.java:674)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:183)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:642)
at org.springframework.beans.factory.access.Singleton BeanFactoryLocator.useBeanFactory(SingletonBeanFac toryLocator.java:393)
at org.springframework.ejb.interceptor.SpringBeanAuto wiringInterceptor.getBeanFactoryReference(SpringBe anAutowiringInterceptor.java:139)
at org.springframework.ejb.interceptor.SpringBeanAuto wiringInterceptor.getBeanFactory(SpringBeanAutowir ingInterceptor.java:120)
at org.springframework.ejb.interceptor.SpringBeanAuto wiringInterceptor.autowireBean(SpringBeanAutowirin gInterceptor.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at com.ibm.ejs.container.interceptors.InterceptorProx y.invokeInterceptor(InterceptorProxy.java:227)
Environment: IBM WebSphere 7.0, JDK 1.5, EJB 3.0, Spring 2.5.5
Can somebody please let me know If I am doing something wrong ?
(For additional reference, I have attached the complete problem details as this site was not allowing more than 10000 characters)