Bugs On J2EE

来源:互联网 发布:粮食安全 大数据 编辑:程序博客网 时间:2024/05/22 01:45

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

原因:tomcat端口被占用。

解决方法通过命令行找到是哪个程序占用了该端口,并关闭相应的程序。

开始–运行–cmd 进入命令提示符 输入netstat –ano|findstr “端口号”

图片

果然8080端口被一个PID为4128的进程占用了,我们去任务管理器下看看到底是什么程序

图片

我们将它结束掉,重新启动Tomcat,OK了

2host-manager does not exist or is not a readable directory
原因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>
[xml] view plaincopy
  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>
[xml] view plaincopy
  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,注意前面的包名之间用‘/’分隔开