& ldquo; matching joker is strict, but no statement can be found & rdquo; error and & ldquo; failed to read schema & rdquo; Error

advertisements

I'm training myself with spring and mybatis exercises.

I'm trying to solve these two errors since yesterday:

1)

Description Resource Path Location Type cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'. ApplicationContext.xml /Example/WebContent/WEB-INF line 14 XML Problem

for these lines:

<context:component-scan base-package="Controller" />
<context:component-scan base-package="service"/>
<context:component-scan base-package="test.dao.samp"/>
<context:component-scan base-package="test.model.samp"/>

and this:

2)

Description Resource Path Location Type

schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context-4.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . ApplicationContext.xml /Exemple/WebContent/WEB-INF line 14 XML Problem

schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx-4.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . ApplicationContext.xml /Exemple/WebContent/WEB-INF line 51 XML Problem

Here is my ApplicationContext.xml

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

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

             <context:annotation-config/>

        <context:component-scan base-package="Controller" />
        <context:component-scan base-package="service"/>
        <context:component-scan base-package="test.dao.samp"/>
        <context:component-scan base-package="test.model.samp"/>

         <bean id='dataSource'
            class='org.springframework.jdbc.datasource.SimpleDriverDataSource'>
            <property name='driverClass' value='org.apache.derby.jdbc.EmbeddedDriver' />
            <property name='url'
                value='jdbc:derby:C:\Users\XXX\IBM\rationalsdp\workspace\.metadata\.plugins\com.ibm.datatools.db2.cloudscape.driver\SAMPLE;create=true' />
            <property name='username' value='admin' />
            <property name='password' value='admin' />
        </bean>

        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="configLocation" value="WEB-INF\psaIbatisConf.xml" />
        </bean>

        <bean id="sqlMapClient" class="org.mybatis.spring.SqlSessionTemplate">
            <constructor-arg ref="sqlSessionFactory" />
        </bean>

        <!-- TRANSACTION MANAGER -->
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
          <property name="dataSource" ref="dataSource"/>
        </bean>

        <!-- ANNOTATION DRIVEN TRANSACTIONS -->
        <tx:annotation-driven transaction-manager="transactionManager" />

</beans>

How I have understood, the errors come from the wrong xsd declaration, but I checked them a lot of times.

The jars I'm using are all 4.0.4 version.

I'm using RAD, Websphere, spring e myBatis with myBatis generator.

Edit:

I changed the version schema in the beans tag in this way:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

The firsts errors has disappeared, but the last one (line 51) remained.


take a look at this example of contex, maybe can help you. I use the same transaction manager.

<?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:jee="http://www.springframework.org/schema/jee"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:mockito="http://www.mockito.org/spring/mockito"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.mockito.org/spring/mockito https://bitbucket.org/kubek2k/springockito/raw/tip/springockito/src/main/resources/spring/mockito.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:annotation-config />
    <tx:annotation-driven/>
    <context:component-scan base-package="cat.base.gpt.logica" />

    <import resource="classpath:tip-appConfiguration.xml" />

    <bean id="gptServei" class="cat.base.gpt.logica.serveis.impl.ServeiGpt">
        <property name="serveiSubjecte" ref="serveiSubjecte"/>
        <property name="vwGptVBasicDAO" ref="vwGptVBasicDAO" />
        <property name="vwGptVExpMSDAO" ref="vwGptVExpMSDAO" />
        <property name="vwGptVObjectesBasicDAO" ref = "vwGptVObjectesBasicDAO"/>

        <!--
            Propietat per falicilitar el filtratge cat.base.gpt.multiens
            true:Recuperem tots els ens
            false: filtrem  per ens
        -->
        <property name="filtratgeEns" value="${cat.base.gpt.multiens}"/>

        <qualifier type="cat.base.gpt.domini.serveis.IServeiGpt" value="gptServei" />
    </bean>

    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="connexioJdbctemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
        <constructor-arg type="javax.sql.DataSource" ref="dataSource"/>
    </bean>

    <bean id="preparadorJdbctemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <constructor-arg type="javax.sql.DataSource" ref="dataSource"/>
    </bean>

    <bean id="vwGptVBasicDAO" class="cat.base.gpt.logica.dao.impl.VwGptVBasicDao">
        <property name="template" ref="connexioJdbctemplate" />
    </bean>

    <bean id="vwGptVExpMSDAO" class="cat.base.gpt.logica.dao.impl.VwGptExpMSDao">
        <property name="template" ref="connexioJdbctemplate" />
    </bean>

    <!-- DAO referent a objectes bĂ sics -->
    <bean id="vwGptVObjectesBasicDAO" class="cat.base.gpt.logica.dao.impl.VwGptObjecteBasicDao">
        <property name="template" ref="connexioJdbctemplate" />
    </bean>

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${cat.base.gpt.driverClassName}" />
        <property name="url" value="${cat.base.gpt.url}" />
        <property name="username" value="${cat.base.gpt.username}"/>
        <property name="password" value="${cat.base.gpt.password}"/>
    </bean>

    <bean id="postprocess" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath*:cat/base/gpt/serveis/impl/logica.properties</value>

                <value>classpath*:entorn-servidor.properties</value>
            </list>
        </property>
        <property name="ignoreResourceNotFound" value="false" />
    </bean>

 </beans>