tomcat jdbc and spring version compatability

痴心易碎 提交于 2019-12-12 04:38:11

问题


I am using apache-tomcat-6.0.37, spring 2.5.6 and tomcat-jdbc-7.0.19.When configuring org.apache.tomcat.jdbc.pool.DataSource in xml file, I am getting this error:

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.tomcat.jdbc.pool.DataSource].

Does spring 2.5.6 does not support tomcat-jdbc-7.0.19? Do it need higher version of spring? At this current moment I can not shift to higher version. Do I need to get conform?


回答1:


Your JARs are outdated first of all.

  1. Update to the most recent Tomcat JDBC Pool
  2. Put that JAR and your driver into $CATALINA_*/lib and nowhere else (* == HOME or BASE)
  3. Declare your DataSource in your context.xml
  4. Retrieve that DataSource from your beans.xml with a JNDI lookup

Tomcat JDBC Pool works flawlessly with Tomcat 6 as long as your run Java 6.

Here is a very similar question.




回答2:


Right now the error you are getting is Cannot find class, this means that the following class is not in the classpath. You should check if jar is present in classpath or not.

Probable location (Since it doesn't get shipped with tomcat-6.x):

  1. WEB-INF/lib directory of war file.

By reading from the documentation, I guess tomcat-jdbc is something introduced in tomcat-7.x not in tomcat-6.x so I doubt if it will work as expected.

Link of interest: http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html




回答3:


These two stack overflow links will solve your problems.

  1. org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class

  2. Spring Web App - CannotLoadBeanClassException caused by Java.lang.ClassNotFoundException




回答4:


The problem is solved .Though the class path of jar was present in .class file generated by ecclipse .I have forgotten to include in build.xml.So the jar was missing in lib of tomcat.



来源:https://stackoverflow.com/questions/17037509/tomcat-jdbc-and-spring-version-compatability

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!