Hibernate4.3.6 Final+Spring3.0.5配置出錯提示及解決方法

1. Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given, please either disable second  level cache or set correct region factory class name to property hibernate.cache.region.factory_class (and make sure the second level cache provider, hibernate-infinispan, for example, is available in the classpath).

    原因在於hibernate4.0在hibernate.cfg.xml配置二級緩存和hibernate3.3有所不同,本例子用的是 Hibernate-core.4.3.6.Final,實際上從4.0開始就不一樣,二級緩存的配置對比如下所示:    

4.0以上配置如下:

<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>

3.3配置如下:

<property name="hibernate.cache.use_second_level_cache">true</property>

<property name="cache.provider_class ">org.hibernate.cache.EhCacheProvider</property>

      但是如果僅僅是修改上述配置的話,還是會出錯,因爲要使用二級緩存的話,還需要引用相應的jar包,即hibernate-release-4.3.6.Final\lib\optional\ehcache下的jar包也要拷貝到lib中,否則會出現Unable to create requested service [org.hibernate.cache.spi.RegionFactory]的錯誤。

2.nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'attendTypeDao' is defined

這個錯誤提示很明顯:沒有定義相應的bean,仔細察看之後發現原來是自己太粗心,在定義bean時將"attendTypeDao"寫成了"attentTypeDao"導致

3.錯誤
!MESSAGE Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.
修改 workspace\.metadata\.plugins\org.eclipse.wst.server.core\servers.xml文件。

<servers>
<server hostname="localhost" id="JBoss v5.0 at localhost" name="JBoss v5.0 at
localhost" runtime-id="JBoss v5.0" server-type="org.eclipse.jst.server.generic.jboss5"
server-type-id="org.eclipse.jst.server.generic.jboss5" start-timeout="1000" stop-
timeout="15" timestamp="0">
<map jndiPort="1099" key="generic_server_instance_properties" port="8090"
serverAddress="127.0.0.1" serverConfig="default"/>
</server>
</servers>
把 start-timeout="45" 改爲 start-timeout="100" 或者更長.

    就醬紫,終於部署成功了。但是實際部署時每個人遇到的問題可能都會有所不同,按它的出錯提示信息仔細分析一般都可以找到原因。






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章