错误提示----SSH篇

来源:互联网 发布:手机投屏软件 编辑:程序博客网 时间:2024/05/18 13:26

 一、java.lang.ClassNotFoundException:org.springframework.web.struts.ContextLoaderPlugIn错误

原因:少sping.jar包,myeclipse加入spring功能时,经常会漏掉加sping.jar包

解决办法:导入sping.jar包

 

----------------------------------------------------

二、java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass

Problem with Spring 1.2.6 and Hibernate 3.1 : HbmBinder$SecondPass

今天又遇到了这个问题,真是让人郁闷了老半天。一心揪出它的根本原因,经过了好半天的刺挠终于找到了就是(hibernate3.jar和hibernate-annotations.jar)的问题,简单主法把hibernate-annotations.jar直接干掉就OK了。
好果有用到这个包就得去找个高点version的去用了。
不知道大家有没有更好的解决方法呀

Exceptionin thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in classpath resource [applicationContext-hibernate.xml]: Initialization ofbean failed; nested exception is java.lang.NoClassDefFoundError:org/hibernate/cfg/HbmBinder$SecondPass
 
reason is:It seems that org/hibernate/cfg/HbmBinder$SecondPass.class no longer exists in hibernate3.jar.
Specifically,the hibernate3.jar that ships with Spring 1.2.7 appears to be Hibernatev3.0.5. This version of the jar does indeed include theorg/hibernate/cfg/HbmBinder$SecondPass class. When I remove thisversion of hibernate3.jar and replace it with the latest and greatesthibernate3.jar this problem arises. The latest version of Hibernate(hibernate3.jar) is v3.1.3.

By simply inspecting the contents of the hibernate3.jar files you will see this problem.

Thisleads me to believe that we must use the hibernate3.jar that ships withSpring v.1.2.7 (or whatever version people are using with respect to1.2.x).

My immediate concern is that itermixing Hibernate3.1.3 support/dependency jars with a v3.0.5 hibernate3.jar may causeissues. I suppose I will need to download and use Hibernate 3.0.5 to besafe but I'd like very much to use Hibernate 3.1.3 w/o concern.

Any ideas on whether a patch/update will be made available to get around this issue.

 
Seeif there's been any issue raised on this topic. I know this topic hasbeen discussed several times but always the solution was using theproper jars (and eliminating old ones which were used as dependenciesas already noted in this thread).
I've used spring with HB 3.1.3 and3.0.5 without problems and by looking at the stacktrace, the problem iswith hibernate (which actually calls the missing class) and not withSpring.
-----------------------------------------------------

 

三、org.apache.commons.dbcp.SQLNestedException: Cannot createJDBC driver of class 'com.microsoft.jdbc.sqlserver.SQLServerDriver' for connectURL '……

搞的我郁闷的很,反复检查测试,在不使用Spring时,数据库连接正常,一用Spring时就报找不到驱动,在网上不断翻阅资料都未果,最后无意间复制了一段代码,放上去就好了,经过和之前我写的代码比对,代码都没什么问题,就是差在一个回车上

改动前:

applicationContext.xml dataSource部分代码

<bean id="dataSource"  

  class="org.apache.commons.dbcp.BasicDataSource">   

  <property name="driverClassName">   

    <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>   

  </property>   

  <property name="url">   

<!—

<value>   

jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hiber

</value>     //就是这里的换行惹的祸  

--> 

//修改为下面红色代码<value></value>标签和URL同一行

 <value>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hiber</value>

        </property>   

        <property name="username">   

            <value>sa</value>   

        </property>   

        <property name="password">   

            <value>123456</value>   

        </property>   

    </bean>  

看到这里真的有让人无奈的感觉,XML里面我好象以前也遇到过这样的情况,不能进行分段读数据,哎,以后这样的问题一定要记住。

     以上是我的一点点小经验,希望各位不要见笑,其实也没什么,就是在平时写程序的时候多注意下就不会出现这样的问题了。

 

-------------------------------------------------------

四、org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy5] to required type [] for property ''

 

似乎参数类型不对吧,应该是接口类型

 

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import dao.IUsersDAO;
import struts.form.UserForm;

public class LoginAction extends Action {
   
    public IUsersDAO usersDao;
    //此处必须是接口,如果为UsersDAO则会抛出异常
    public void setUsersDao(IUsersDAO usersDao){
        this.usersDao= usersDao;
    }

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 耳朵被耳屎堵了怎么办 油耳朵被堵住了怎么办 棉签掏耳朵堵了怎么办 耳朵被气堵住了怎么办 掏耳朵发炎了疼怎么办 掏耳朵掏深了疼怎么办 耳朵里进了虫子怎么办? 耳朵里飞进小虫怎么办 一只耳朵听力差怎么办 62岁耳朵有点聋怎么办 一支耳朵有点聋怎么办 80岁老人耳朵聋怎么办 被nlp课程洗脑了怎么办 手上张了个鸡眼怎么办 手上长了个鸡眼怎么办 6岁儿童手指脱皮怎么办 手指骨折后关节僵硬怎么办 手指外伤后关节肿大僵硬怎么办 胳膊骨折了手肿怎么办 耳朵被肘了耳鸣怎么办 耳朵鼓膜外显的怎么办 耳膜破了怎么办为好 耳朵的鼓膜破了怎么办 被打耳鼓膜穿孔怎么办 两只耳朵嗡嗡响怎么办 耳朵长了个脓包怎么办 胸一个大一个小怎么办 把耳朵掏出血了怎么办 掏耳朵戳出血了怎么办 耳朵戳伤流血了怎么办 耳朵挖破出血了怎么办 耳朵让耳屎堵了怎么办 手被牙齿划破了怎么办 耳朵掏伤了很痛怎么办 掏伤耳朵发炎了怎么办 耳朵被掏发炎了怎么办 打的耳洞化脓了怎么办 打了耳洞流脓了怎么办 打了耳洞发炎怎么办 打了耳洞化脓了怎么办 3岁宝宝耳朵流脓怎么办