2012-03-29 3 views
0

안녕하세요, apache-cxf v 2.5.2, 2.5.6 및 hibernate v v 3.2.1을 기반으로하는 프로젝트가 있습니다. 특수 효과를 사용하여 유닛과 객체를 표시하고 전쟁을 전개 할 때 문제가 발생합니다. 다음 예외가 발생했습니다 : org.springframework.beans.factory.BeanCreationException : 'storeService'라는 이름의 빈을 만드는 중 오류가 발생했습니다 : 생성자 인수를 설정하는 동안 'storeService'bean에 대한 참조를 확인할 수 없습니다. 중첩 예외는 org.springframework.beans.factory.BeanCurrentlyInCreationException입니다 : 'storeService'라는 이름으로 빈을 생성하는 중 오류가 발생했습니다 : 요청 된 빈이 현재 생성 중입니다 : 해결할 수없는 루프 참조가 있습니까?BeanCurrentlyInCreationException, 해결할 수없는 순환 참조

두 파일이 모두 web.xml을

이에 포함되어

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jaxws="http://cxf.apache.org/jaxws" 
    xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> 
    <import resource="classpath:META-INF/cxf/cxf.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> 
     <!-- DECLARACION DE LOS ENDPOINTS DE LOS WEB SERVICES--> 
     <jaxws:endpoint 
     id="storeService" implementor="#storeService" 
     implementorClass="com.aironman.core.cxf.service.StoreServiceImpl" 
     address="/Store" /> 
</beans> 

beans.xml 환경이있는 applicationContext.xml 파일

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:jee="http://www.springframework.org/schema/jee" 
    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.5.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd 
     http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
     "> 
    <context:component-scan base-package="com.aironman.core" /> 
    <tx:annotation-driven transaction-manager="txManager"/> 
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
     <property name="sessionFactory" ref="sessionFactory"/> 
    </bean> 
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="location" value="classpath:hibernate.properties"/> 
    </bean> 
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
     <property name="driverClassName" value="${database.driverClassName}"/> 
     <property name="url" value="${database.url}"/> 
     <property name="username" value="sa"/> 
     <property name="password" value=""/> 
    </bean> 
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
     <property name="dataSource" ref="dataSource"/> 
     <property name="hibernateProperties"> 
      <value> 
       hibernate.dialect=${database.hibernate.dialect} 
       hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider 
       hibernate.show_sql=true 
       hibernate.use_sql_comments=true 
       hibernate.jdbc.batch_size=0 
       hibernate.hbm2ddl.auto=create-drop 
       hibernate.default_schema=${hibernate.default_schema} 
       hibernate.generate_statistics=true 
       hibernate.cache.use_structured_entries=true 
      </value> 
     </property> 
    <property name="annotatedClasses"> 
      <list> 
       <value>com.aironman.core.pojos.Usuario</value> 
       <value>com.aironman.core.pojos.Item</value> 
       <value>com.aironman.core.pojos.Persona</value> 
      </list> 
     </property> 
    </bean> 
</beans> 

입니다 구현 en입니다. D 포인트 웹 서비스, storeService : 당신이 볼 수 있듯이

package com.aironman.core.service; 
**@Service("servicioUsuarios") 
public class ServicioUsuariosImpl implements ServicioUsuarios** { 
    private static ConcurrentHashMap <String,Usuario>hashMapUsuarios = new ConcurrentHashMap <String,Usuario>() ; 
    private Log log = LogFactory.getLog(ServicioUsuariosImpl.class); 
    @Autowired 
    @Qualifier("servicioEncriptacion") 
    private ServicioEncriptacion     servicioEncriptacion; 
    @Autowired 
    @Qualifier("servicioPersistenciaUsuarios") 
    private ServicioPersistenciaUsuarios   servicioPersistenciaUsuarios; 
    public ServicioUsuariosImpl(){ 
     log.info("Constructor SIN tipo ServicioUsuariosImpl..."); 
     //TODO pendiente cargar el mapa con una llamada al servicioPersistencia 
    } 
    @PostConstruct 
    public void init() 
    { 
     log.info("init method on ServicioUsuariosImpl. Initializing hashMap..."); 
     //i need to call persistence layer to fill the hashMap   
    } 
    some methods, getters and setters 
} 

,이 서비스가 기본적으로 DAO는 @Repository로 표시 사용 servicioPersistenciaUsuarios라는 지속적인 서비스를 inyected했습니다

**@Service("storeService") 
@WebService(endpointInterface = "com.aironman.core.cxf.service.StoreService") 
public class StoreServiceImpl implements StoreService** { 

    private Log log = LogFactory.getLog(StoreServiceImpl.class); 
    @Autowired 
    @Qualifier("servicioUsuarios") 
    private ServicioUsuarios   servicioUsuarios; 
    @Autowired 
    @Qualifier("servicioItems") 
    private ServicioItems    servicioItems; 
    @Autowired 
    @Qualifier("servicioApuntes") 
    private ServicioApuntesContables servicioApuntesContables; 
    [B]public StoreServiceImpl()[/B]{ 
     log.info("CONSTRUCTOR SIN tipo StoreServiceImpl..."); 
    } 
some methods... getters and setters ... 
} 

이 ServicioUsuariosImpl 파일입니다 .

package com.aironman.core.service; 
**@Service("servicioPersistenciaUsuarios") 
public class ServicioPersistenciaUsuariosImpl implements ServicioPersistenciaUsuarios** { 
    @Autowired 
    @Qualifier("usuarioHibernateDao") 
    private UsuarioHibernateDao usuarioHibernateDao; 
    private Log log = LogFactory.getLog(ServicioPersistenciaUsuariosImpl.class); 
    public ServicioPersistenciaUsuariosImpl() 
    { 
     log.info("Constructor ServicioPersistenciaUsuariosImpl..."); 
    } 
    some methods, getters and setters 
} 

이이 usuarioHibernateDao 구현 파일입니다 :

이 ServicioPersistenciaUsuariosImpl 구현 파일입니다

package com.aironman.core.hibernate; 
**@Repository 
public class UsuarioHibernateDao extends HibernateGenericDao<Usuario, String> implements UsuarioDao** 
{ 
      private Log log = LogFactory.getLog(UsuarioHibernateDao.class); 
     [B]@Autowired 
     public UsuarioHibernateDao(@Qualifier("sessionFactory") SessionFactory sessionFactory) [/B]{ 
      super(sessionFactory); 
     } 
     some methods...   
} 

ServicioUsuariosImpl 다른 dependencie, servicioEncriptacion을 가지고 있으며, 당신이 볼 수 있으므로,이 구현은 다음과 같습니다

package com.aironman.core.service; 
@Service("servicioEncriptacion") 
public class ServicioEncriptacionImpl implements ServicioEncriptacion 
{ 
     private static final String algoritmo = "SHA-256"; 
     private Log log = LogFactory.getLog(ServicioEncriptacionImpl.class); 
     private static java.security.MessageDigest diggest ; 
     [B]public ServicioEncriptacionImpl()[/B] 
     {some code... 
     } 
     some methods... 
    } 

이것은 ServicioItemsImpl 구현 파일이며 다른 Dependent는 StoreServiceImpl에 속합니다.

package com.aironman.core.service; 
**@Service("servicioItems") 
public class ServicioItemsImpl implements ServicioItems**{ 
    private static final ConcurrentHashMap 
      <String,com.aironman.core.pojos.Item> 
      //La pk es el isbn del item 
      hashMapItems = new ConcurrentHashMap<String,com.aironman.core.pojos.Item>() ; 
    private Log log = LogFactory.getLog(ServicioItemsImpl.class); 
    @Autowired 
    @Qualifier("servicioPersistenciaItems") 
    private ServicioPersistenciaItems servicioPersistenciaItems; 
    [B]public ServicioItemsImpl()[/B] 
    { 
     log.info("Constructor SIN TIPO ServicioItemsImpl");  
    } 
    [B]@PostConstruct 
    public void init()[/B] 
    { 
     log.info("init method on ServicioItemsImpl. Initializing hashMap..."); 
    } 
    some methods, getters and setters 
} 

이 servicioPersistenciaItems 구현 파일입니다

package com.aironman.core.service; 

@Service("servicioPersistenciaItems") 
public class ServicioPersistenciaItemsImpl implements ServicioPersistenciaItems 
{ 
    @Autowired 
    @Qualifier("itemHibernateDao") 
    private ItemHibernateDao itemHibernateDao; 
    private Log log = LogFactory.getLog(ServicioPersistenciaItemsImpl.class);  
    [B]public ServicioPersistenciaItemsImpl()[/B] 
    { 
     log.info("Constructor SIN tipo ServicioPersistenciaItemsImpl..."); 
    } 
some methods, getters and setters... 
} 

마무리, ServicioApuntesContablesImpl 구현 파일, 봄이를 인스턴스화 할 때 짧은

package com.aironman.core.service; 
[B]@Service("servicioApuntes") 
public class ServicioApuntesContablesImpl implements ServicioApuntesContables[/B]{ 

    private Log log = LogFactory.getLog(ServicioApuntesContablesImpl.class); 
    private static ConcurrentHashMap <ClaveApunteContable,ApunteContable> mapaApuntesContables 
         = new ConcurrentHashMap <ClaveApunteContable,ApunteContable>(); 

    //TODO al final tendre que persistir los apuntes contables, por ahora los mantendre en memoria... 
    [B]public ServicioApuntesContablesImpl()[/B] 
    {} 
    some methods 
} 

이 문제가 일어나고 종속물 종점 구현 파일 storeService 및 파일, getter 및 setters 중 하나에 형식화 된 생성자가 없기 때문에 그것을 이해하지 못한다. 그는 어떤 의존성이라도 서로에게 익숙하다. 누군가 나를 도우 려하고 무슨 일이 일어 났는지 설명 할 수 있습니까?대단히 감사합니다.

PD 가독성 문제를 해결하기위한 몇 가지 코드를 작성하지 않았으며 누군가가 시계를 필요로하는 경우 제한된 캐릭터에게 쉽게 도달합니다.

답변

2

좋아, 나는 이미 내 문제를 해결했다. endpoints.xml 파일 내에서 ID가있는 ws를 선언했고 이미 @Service 주석을 사용하여 구현 ws 파일을 선언 했으므로 이제는 예외가되었습니다.