PDA

View Full Version : LocalSessionFactoryBean & multiple EAR in WebSphere



markash
Nov 9th, 2004, 08:23 AM
Good Day,

I have two EARs deployed to WebSphere 5.1. The one EAR has an ejb that uses the services of another ejb deployed in the second EAR.

I get the following error


java.lang.reflect.InvocationTargetException: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'hibernateApplicationDAO' defined in class path resource [context-application.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.hsbc.spring.LocalSessionFactoryBean] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory']

PropertyAccessExceptionsException (1 errors)
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.hsbc.spring.LocalSessionFactoryBean] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory'
at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:905)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:673)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:588)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:720)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:747)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:736)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:840)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:662)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:270)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:205)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:236)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:284)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationContext.java:80)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationContext.java:65)
at org.springframework.context.access.ContextJndiBean FactoryLocator.createBeanFactory(ContextJndiBeanFa ctoryLocator.java:40)
at org.springframework.beans.factory.access.JndiBeanF actoryLocator.useBeanFactory(JndiBeanFactoryLocato r.java:69)
at org.springframework.ejb.support.AbstractEnterprise Bean.loadBeanFactory(AbstractEnterpriseBean.java:1 15)
at org.springframework.ejb.support.AbstractStatelessS essionBean.ejbCreate(AbstractStatelessSessionBean. java:63)
at java.lang.reflect.Method.invoke(Native Method)

markash
Nov 10th, 2004, 01:00 AM
Has anyone have experience packaging common application code in a EJB jar deployed as an EAR and then calling the EJB from another EAR / EJB project.

Important is how to do this with WebSphere 5.1 + Spring 1.1.1 + Hibernate 2.1.6.

markash
Nov 11th, 2004, 06:48 AM
The problem is that the two ejb applications have different classloaders. The one loads the interface and the other loads the implementation and when the one is assigned to the other then because they were loaded by two different classloaders they are treated as different classes and produce the ClassCastException.

A possible solution is to have the common code accesible on the classloader one level above the two ear applications, say on the WAS\lib folder.


Just a thought....