错误提示----SSH篇

 一、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的去用了。
不知道大家有没有更好的解决方法呀

Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-hibernate.xml]: Initialization of bean 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 Hibernate v3.0.5. This version of the jar does indeed include the org/hibernate/cfg/HbmBinder$SecondPass class. When I remove this version of hibernate3.jar and replace it with the latest and greatest hibernate3.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.

This leads me to believe that we must use the hibernate3.jar that ships with Spring v.1.2.7 (or whatever version people are using with respect to 1.2.x).

My immediate concern is that itermixing Hibernate 3.1.3 support/dependency jars with a v3.0.5 hibernate3.jar may cause issues. I suppose I will need to download and use Hibernate 3.0.5 to be safe 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.

 
See if there's been any issue raised on this topic. I know this topic has been discussed several times but always the solution was using the proper jars (and eliminating old ones which were used as dependencies as already noted in this thread).
I've used spring with HB 3.1.3 and 3.0.5 without problems and by looking at the stacktrace, the problem is with hibernate (which actually calls the missing class) and not with Spring.
-----------------------------------------------------

 

三、org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.microsoft.jdbc.sqlserver.SQLServerDriver' for connect URL '……

搞的我郁闷的很,反复检查测试,在不使用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;
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值