Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring + Maven: The matching wildcard is strict, but no declaration can be found for element 'jdbc:embedded-database'

i am currently trying to build a little webapp that uses Spring, Hibernate and Maven (running on a tomcat). It works quite fine, except that i cannot get my embedded-database to work. I hope you can help me.

I am always facing this error, when i am deploying the webapp to the Tomcat:

The matching wildcard is strict, but no declaration can be found for element 'jdbc:embedded-database'

During my investigations i learned that this message is pointing towards missing libraries. Therefore i added my pom.xml, where i added the artifact spring-jdbc.

Can you help me finding the error? Thanks a lot!


This is my spring-configuration-file, which causes the error during initialization of the webapp:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:jdbc="http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/tx 
   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
   http://www.springframework.org/schema/jdbc 
   http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd">
   <bean id="sessionFactory" class=
    "org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
       <property name="dataSource" ref="embeddedDatasource" />
       <property name="packagesToScan" value="org.rest" />
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
                hibernate.hbm2ddl.auto=update
                hibernate.show_sql=false
            </value>
        </property>
    </bean>

    <jdbc:embedded-database id="embeddedDatasource" type="HSQL"/>

    <bean id="txManager" class=
        "org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <tx:annotation-driven transaction-manager="txManager" />
</beans>

This is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.marcus</groupId>
  <artifactId>maven-webapp-archetype</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>maven-webapp-archetype Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>javax.servlet.jsp.jstl-api</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.6.10.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>maven-webapp-archetype</finalName>
    <plugins>
        <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat6-maven-plugin</artifactId>
          <version>2.0-beta-1</version>
          <configuration>
            <url>http://localhost:8080/manager/html</url>
            <server>tomcat7</server>
          </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0-beta-1</version>
            <configuration>
                <url>http://localhost:8080/manager/html</url>
                <server>tomcat7</server>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>
like image 714
mavilein Avatar asked Apr 10 '12 17:04

mavilein


1 Answers

This line in your Spring context file:

xmlns:jdbc="http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd"

should be changed to :

xmlns:jdbc="http://www.springframework.org/schema/jdbc"

Not sure what IDE you're using but with some (IntelliJ for example) this would be flagged as an error and save a lot of headache!

like image 71
darrengorman Avatar answered Oct 02 '22 16:10

darrengorman