Announcement Announcement Module
No announcement yet.
no declaration can be found for element 'tx:annotation-driven Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • no declaration can be found for element 'tx:annotation-driven

    Help please

    In the midst of a project were most all was working with the hibernateTemplate. Then reading that new projects should use the Hibernate3 API and not the hibernateTemplate, so I decided to eliminate it. When I add the "<tx:annotation-driven />" attribute to my Spring config file I get the following:

    INFO: Loading XML bean definitions from class path resource [springBeans.xml]
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from class path resource [springBeans.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'.
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(
    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'.
    I have seen the error mentioned here several times none of the solutions fit or resolve my problem. I have cut my project to the absolute minimum for testing purposes.

    Jar files included: derbyclient.jar (10.5), spring.jar (2.5.6), commons-dbcp.jar, commons-logging.jar, commons-pool.jar. All from the Spring with dependencies distribution. Java 1.6.

    My Spring config file "springBeans.xml" is:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""
    	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    		<property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
    		<property name="url"
    			value="jdbc:derby://localhost:1527/LessonDB;create=true" />
    		<property name="username" value="app" />
    		<property name="password" value="app" />
    		<property name="initialSize" value="2" />
    		<property name="maxActive" value="5" />
    	<bean id="jdbcCourseDAO" 
    		<property name="dataSource" ref="dataSource" />
    	<tx:annotation-driven />
    	<bean id="transactionManager"
    		<property name="dataSource" ref="dataSource" />
    Domain Class:
    package examples;
    public class CourseT {
    	private Long id;
    	private String meetWkDays;		
    	private String poolArea;
    	private Integer version;
    	public CourseT(Long id, String poolArea) {
    		super(); = id;
    		this.poolArea = poolArea;
    	public String getMeetWkDays() {
    		return meetWkDays;
    	public void setMeetWkDays(String meetWkDays) {
    		this.meetWkDays = meetWkDays;
    	public Long getId() {
    		return id;
    	public void setId(Long id) { = id;
    	public String getPoolArea() {
    		return poolArea;
    	public void setPoolArea(String poolArea) {
    		this.poolArea = poolArea;
    	public Integer getVersion() {
    		return version;
    	public void setVersion(Integer version) {
    		this.version = version;
    DAO Class:
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import javax.sql.DataSource;
    public class JdbcCourseDAOImpl implements JdbcCourseDAO {
    	private DataSource dataSource;
    	public void setDataSource(DataSource dataSource) {
    		this.dataSource = dataSource;
    	public CourseT findAllCourses() {
    		String sql = "Select * From Course where id = ?";
    		Connection conn = null;
    		try {
    			conn = dataSource.getConnection();
    			PreparedStatement ps = conn.prepareStatement(sql);
    			ps.setLong(1, 11L);
    			CourseT courseT = null;
    			ResultSet rs = ps.executeQuery();
    			if ( {
    				courseT = new CourseT(rs.getLong("ID"), rs
    			return courseT;
    		} catch (SQLException sqle) {
    			System.out.println("didn't work " + sqle.getMessage());
    		} finally {
    			if (conn != null) {
    				try {
    				} catch (SQLException sqle) {
    					System.out.println("conn not closed " + sqle.getMessage());
    		return null;
    Testing Class:
    package examples;
    import org.springframework.context.ApplicationContext;
    public class Main {
    	public static void main(String[] args) {
    		ApplicationContext context = new ClassPathXmlApplicationContext(
    		JdbcCourseDAOImpl dao = (JdbcCourseDAOImpl) context.getBean("jdbcCourseDAO");
    		CourseT t = dao.findAllCourses();
    		System.out.println("here some stuff " + t.getPoolArea());
    Any guidance would be greatly appreciated. Thank you.

  • #2
    Problem found, or Fixed

    In reality, spelling is a beautiful thing, I wish I could do it. My xmlns:tx="" should have been xmlns:tx="". Adding the "e" to springframework made all the difference.

    Have a good day
    Last edited by rusty.hinge; Nov 1st, 2009, 11:14 AM.