2014-07-23 25 views
0

如果有人能夠找出我的問題,我將不勝感激。我搜索並發現了很多類似的問題。但無法找到解決方案。我很抱歉問同樣的問題。但是我對這個問題感到困惑和沮喪。Spring Web App - CannotLoadBeanClassException找不到名爲'somename'的bean的類[package]

我有一個在eclipse上部署了很多項目的web應用程序。我正在使用spring框架。一切工作正常。我在eclipse中清理了所有的項目,並啓動了服務器。而我的瀏覽器正在拋出這個錯誤。我試圖重新啓動服務器和所有可能的修復,但沒有任何工作。

SEVERE: Context initialization failed 
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class[org.company.ain.authenticate.AuthenticateUser] for bean with name 'authenticate' 

這是我的.xml文件

<bean name="authenticate" class="org.company.ain.authenticate.AuthenticateUser"> 
     <property name="dataSource" ref="dataSource"/> 
    </bean> 

我想知道兩件事情。

  • eclipse是否會在我清除所有項目後擦除我的類路徑?
  • 上述問題的解決辦法是什麼?
+0

如果解決問題,請嘗試重新部署。並檢查org.company.ain.authenticate.AuthenticateUser實際上是否存在。 –

+0

試了兩個。是的,它在那裏。沒有工作。它引發同樣的錯誤。 – user123

+0

比你不得不發佈導致問題的代碼。 –

回答

0

我的工作例子是針對多重hibernate,我希望它對您有用。

數據源

<!-- DATA SOURCE --> 
    <bean id="_dataSourceProxy" 
     class="org.springframework.jndi.JndiObjectFactoryBean"> 
     <property name="resourceRef" value="true" /> 
     <property name="jndiName" value="${connection.jndiName}"></property> 
     <property name="lookupOnStartup" value="false"></property> 
     <property name="cache" value="false"></property> 
     <property name="proxyInterface" value="javax.sql.DataSource"></property> 
    </bean> 

休眠

<!-- HIBERNATE --> 
<bean id="_hibernateSessionFactory" 
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 

    <property name="dataSource"> 
     <ref bean="_dataSourceProxy"></ref> 
    </property> 

    <property name="hibernateProperties"> 
     <props> 
      <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> 
      <prop key="hibernate.connection.SetBigStringTryClob">true</prop> 
      <prop key="hibernate.jdbc.batch_size">0</prop> 
      <prop key="hibernate.jdbc.use_streams_for_binary">false</prop> 
      <prop key="javax.persistence.validation.mode">none</prop> 
      <prop key="connection.useUnicode">true</prop> 
      <prop key="connection.characterEncoding">utf-8</prop> 


      <prop key="hibernate.connection.defaultNChar">true</prop> 
      <prop key="hibernate.show_sql">true</prop> 

     </props> 
    </property> 

    <property name="mappingResources"> 
     <list> 
      <value>hibernate/content/Content.hbm.xml</value> 
      <value>hibernate/content/ContentMeta.hbm.xml</value> 
     </list> 
    </property> 

</bean> 

休眠CONF爲多

<!-- Content Repo --> 
    <bean id="_contentRepository" 
     class="XXXX"> 
     <aop:scoped-proxy/> 
     <property name="_senderEmail" value="${smtp.senderEmail}"></property>  
     <property name="_hibernateSessionFactory"> 
      <ref bean="_hibernateSessionFactory"></ref> 
     </property> 
     <property name="_authService"> 
      <ref bean="_authService"></ref> 
     </property> 
     <property name="_languageRepository"> 
      <ref bean="_languageRepository"></ref> 
     </property> 
     <property name="_locationRepository"> 
      <ref bean="_locationRepository"></ref> 
     </property>   
     <property name="_velocityEngine"> 
      <ref bean="_velocityEngine"></ref> 
     </property> 
     <property name="_mailSender"> 
      <ref bean="_mailSender"></ref> 
     </property>             
    </bean> 

例回購:

<!-- Location Repo --> 
    <bean id="_locationRepository" 
     class="XXXX"> 
     <property name="_hibernateSessionFactory"> 
      <ref bean="_hibernateSessionFactory"></ref> 
     </property> 
    </bean> 
相關問題