Bugs On J2EE

1. java.lang.Exception: Socket bind failed: [730048] ?????????×???(Э?é/???????/???)????í??

原因:tomcat端口被佔用。

解決方法通過命令行找到是哪個程序佔用了該端口,並關閉相應的程序。

開始–運行–cmd 進入命令提示符 輸入netstat –ano|findstr “端口號”

圖片

果然8080端口被一個PID爲4128的進程佔用了,我們去任務管理器下看看到底是什麼程序

圖片

我們將它結束掉,重新啓動Tomcat,OK了

原因Tomcat6在wepapps下面會有一些tomcat自帶的項目(root、manager、host- manager等幾個)被刪掉了。
解決方法conf/Catalina/localhost裏面有兩個xml文件host-manager.xml、manager.xml刪掉,然後重啓Tomcat就沒問題了。 
或Catalina裏面其它的文件夾中也可能存在host-manager.xml,manager.xml這樣的文件, 把它們都刪除了就可以了。

4org.hibernate.HibernateException: No CurrentSessionContext configured! 

原因:hibernate.cfg.xml配置文件中current_session_context_class屬性配置不正確

解決方法:在集成Hibernate的環境下(例如Jboss),要在hibernate.cfg.xml中session-factory段加入:

Xml代碼 複製代碼 收藏代碼
  1. <property name="current_session_context_class">jta</property>
  1. <span style="font-size:14px;"><property name="current_session_context_class">jta</property></span>  


在不集成Hibernate的環境下(例如使用JDBC的獨立應用程序),在hibernate.cfg.xml中session-factory段加入:

Xml代碼 複製代碼 收藏代碼
  1. <property name="current_session_context_class">thread</property>
  1. <span style="font-size:14px;"><property name="current_session_context_class">thread</property></span>  

5. resource: org.hibernate.tutorial.domain.Event.hbm.xml not found

原因:hibernate.cfg.xml配置文件中的mapping標籤中的resource屬性的值填寫錯誤

解決方法:hibernate.cfg.xml配置文件中的mapping標籤中的resource屬性的值一般對應的是domain對象的映射文件*.hbm.xml,注意前面的包名之間用‘/’分隔開


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