java WEB高手快来啊!Myeclipse中Name jdbc is not bound in this Context异常怎么解决

用的是spring+webwork开发框架
在tomcat发布的时候就报这个异常
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
我把那些jar包都放进去了 现在成了这个异常了,这是怎么回事了 有点郁闷啊
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration
Caused by: java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration[org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration
Caused by: java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration

这个可能是在web.xml或者是tomcat的server.xml中的配置不匹配导致的。
web.xml中配置如下:
<resource-ref>
<res-ref-name>数据库名</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
在tomcat中配置如下:
<Context path="/web的根目录名">
<Resource name="数据库名"
type="javax.sql.DataSource"
username="root" //用户名
password="root" //密码
driverClassName="com.mysql.jdbc.Driver"//数据库类型
maxIdle="10"
url="jdbc:mysql://localhost:3306/tarena" //数据库实例
maxActive="10"/>
</Context>
备注:以上配置是固定用法,可根据实际情况修改相应的参数值,但是参数类型请不要乱配。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-03-14
是不是hibernate的jar没有放入,还要注意是不是已经配置了jndi
第2个回答  2008-03-15
你的包加载的有错误,是不是把hibernate.jar和context.jar都加入到工程中了呢?还有你写的程序类的创建可能也有些问题本回答被提问者采纳
第3个回答  2008-03-14
看你的包中有没有spring-context.jar
第4个回答  2008-03-13
bu dong

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网