1 Reply Latest reply on Aug 27, 2007 11:31 PM by geeraghav

    when i deployed a Spring project on jboss ,i encoutered a er

    bill.cheng

      i deployed a project on jboss-4.2.when i started jboss,i encoutered a error.Below is the error. But i use JUnit for testing , all testcases run well.
      My project includes two projects ,one is ejb project ,another is web project.I place ApplicationContext.xml and *.hbm.xml file on the root of ejb project. i added item of "contextConfigLocation" and "org.springframework.web.context.ContextLoaderList ener" to web.xml.
      In test environment,I used a ClassPathXmlApplicationContext for obtaining a bean. TestCases run well.

      Exception:

      18:36:05,562 INFO [STDOUT] 18:36:05,546 ERROR [ContextLoader] Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'partnerInfoDao' defined in file [C:\jboss-4.2.0.CR1.by.bnet3\jboss-4.2.0.CR1\server\default\deploy\bsr.ear\bsrEJB.jar\spring\dao.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy79] to required type [org.hibernate.SessionFactory] for property 'sessionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy79] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found
      Caused by:
      org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy79] to required type [org.hibernate.SessionFactory] for property 'sessionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy79] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found
      Caused by:
      java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy79] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found
       at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:227)
       at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
       at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)



      application context
      <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
       default-autowire="byName">
      
       <aop:config>
       <aop:pointcut id="defaultServiceOperation"
       expression="execution(* com.gsww.bnet..*service.impl.*Impl.*(..))"/>
       <aop:advisor pointcut-ref="defaultServiceOperation" advice-ref="defaultTxAdvice"/>
       </aop:config>
      
       <tx:advice id="defaultTxAdvice" transaction-manager="transactionManager">
       <tx:attributes>
       <tx:method name="get*" read-only="true"/>
       <tx:method name="*"/>
       </tx:attributes>
       </tx:advice>
      
       <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="locations">
       <list>
       <value>classpath:jdbc.properties</value>
       </list>
       </property>
       </bean>
      
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
       <property name="driverClassName">
       <value>${jdbc.driverClassName}</value>
       </property>
       <property name="url">
       <value>${jdbc.url}</value>
       </property>
       <property name="username">
       <value>${jdbc.username}</value>
       </property>
       <property name="password">
       <value>${jdbc.password}</value>
       </property>
       </bean>
      
       <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
       <property name="dataSource" ref="dataSource"/>
       <property name="hibernateProperties">
       <props>
       <prop key="hibernate.dialect">${hibernate.dialect}</prop>
       </props>
       </property>
       <property name="mappingDirectoryLocations">
       <list>
       <value>classpath*:hibernate</value>
       </list>
       </property>
       </bean>
      
       <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
       <property name="sessionFactory" ref="sessionFactory"/>
       </bean>
      
       <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory"/>
       </bean>
       <bean id="partnerInfoDao" class="com.gsww.bnet.bsr.partner.dao.PartnerInfoDao" />
       <bean id="partnerUserDao" class="com.gsww.bnet.bsr.partner.dao.PartnerUserDao" />
       <bean id="partnerAppDao" class="com.gsww.bnet.bsr.marketing.app.dao.PartnerAppDao" />
       <bean id="applealingOrderDao" class="com.gsww.bnet.bsr.cs.dao.AppealingOrderDao" />
      


      Java class:
      I defined a Class like below for supporting generic type ?
      import org.apache.commons.beanutils.PropertyUtils;
      import org.hibernate.Criteria;
      import org.hibernate.FlushMode;
      import org.hibernate.Query;
      import org.hibernate.criterion.CriteriaSpecification;
      import org.hibernate.criterion.MatchMode;
      import org.hibernate.criterion.Projection;
      import org.hibernate.criterion.Projections;
      import org.hibernate.criterion.Restrictions;
      import org.hibernate.impl.CriteriaImpl;
      import org.springframework.orm.ObjectRetrievalFailureException;
      import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
      import org.springframework.util.Assert;
      
      
      import java.io.Serializable;
      import java.lang.reflect.InvocationTargetException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.regex.Matcher;
      import java.util.regex.Pattern;
      
      public class HibernateGenericDao extends HibernateDaoSupport {
      
       public <T> T get(Class<T> entityClass, Serializable id) {
       T o = (T) getHibernateTemplate().get(entityClass, id);
       if (o == null)
       throw new ObjectRetrievalFailureException(entityClass, id);
       return o;
       }
      ........
      


      and defined another abstract class for some methods ,
      import org.apache.log4j.Logger;
      import org.hibernate.Criteria;
      import com.gsww.util.GenericsUtils;
      import java.io.Serializable;
      import java.util.List;
      abstract public class HibernateAbstractDao<T> extends HibernateGenericDao {
       protected Logger log = Logger.getLogger(getClass().getName());
      
       protected Class<T> entityClass;
       ......
      


      public class PartnerAppDao extends HibernateAbstractDao<PartnerApp> {
      
      }
      


      i deleted the hibernate.jar that jboss ships and added another hibernate.jar to jboss_home/server/default/lib. i guess it's not the problem of version .

      Thank you very much!

        • 1. Re: when i deployed a Spring project on jboss ,i encoutered
          geeraghav

          Bill,

          I encountered a similar problem when deploying the application in jboss. The problem for us was that we were using a jar file for our webapplication and that jar file was wrongly placed under server/default/lib. We moved the jar file to server/default/deploy/app.war/WEB-INF/lib and it started working.

          Hope this helps.

          Regards,
          Raghavan G