The matching wildcard is strict, but no declaration can be found for element 'tx:anno
bonjour,
je lis actuellement un tuto de S.Tahé (du site developpez.com) sur J2EE, et je rencontre une erreur avec un des programmes, voici l'erreur:
Citation:
FAILED CONFIGURATION: @BeforeClass init
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 54 in XML document from class path resource [spring-config-dao.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'.
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'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
at dao.InitDB.init(InitDB.java:37)
... Removed 22 stack frames
SKIPPED CONFIGURATION: @BeforeMethod clean
SKIPPED: initDB
elle se produit lors de l'exécution d'une classe initDB, dont voici un extrait:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
public class InitDB {
@PersistenceContext
private EntityManager em;
private IEmployéDao employeDao = null;
private ICotisationDao cotisationDao = null;
private IIndemnitéDao indemniteDao = null;
@BeforeClass
public void init() {
// configuration de l'application
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config-dao.xml");
// couches dao
employeDao = (IEmployéDao) ctx.getBean("employéDao");
cotisationDao = (ICotisationDao) ctx.getBean("cotisationDao");
indemniteDao = (IIndemnitéDao) ctx.getBean("indemnitéDao");
}
@Test
public void initDB() {
// on remplit la base
indemnité une_ind=new indemnité(0, 0, 2.38, 1.03, 15.0, 5.0);
indemnité deux_ind=new indemnité(0,0,1.43, 2.0, 10.0, 7.0);
indemniteDao.create(une_ind);
indemniteDao.create(deux_ind);
employé un_employé=new employé("174075746304472", "SAINT-EVE", "Olivier", 57050, "12 impasse des genêts", "metz", une_ind);
employeDao.create(un_employé);
cotisation une_cot=new cotisation(1.3, 2.7, 2.1, 1.0);
cotisationDao.create(une_cot);
// on affiche le contenu de la base
System.out.println("*** AFFICHAGE DU CONTENU DE JPA2 ***");
System.out.println("*** TABLE indemnité ***");
for (Object ind : em.createQuery("select i from indemnité i").getResultList()) {
System.out.println(ind);
}
System.out.println("*** TABLE cotisation ***");
for (Object cot : em.createQuery("select c from cotisation c").getResultList()) {
System.out.println(cot);
}
System.out.println("*** TABLE employé ***");
for (Object emp : em.createQuery("select e from employé e").getResultList()) {
System.out.println(emp);
}
} |
et le fichier où se trouve l'erreur est le fichier de configuration de spring:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-
2.0.xsd">
<!-- couches applicatives -->
<bean id="dao" class="dao.Dao" />
<bean id="service" class="service.Service">
<property name="dao" ref="dao" />
</bean>
<bean id="employéDao" class="intro_j2ee.dao.employé_dao" />
<bean id="cotisationDao" class="intro_j2ee.dao.cotisation_dao" />
<bean id="indemnitéDao" class="intro_j2ee.dao.indemnité_dao" />
<!-- couche de persistance JPA -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<!--
<property name="showSql" value="true" />
-->
<property name="databasePlatform"
value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="generateDdl" value="true" />
</bean>
</property>
<property name="loadTimeWeaver">
<bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>
<!-- la source de donnéees DBCP -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/jpa2" />
<property name="username" value="jpa2" />
<property name="password" value="jpa2" />
</bean>
<!-- le gestionnaire de transactions -->
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>
<!-- traduction des exceptions -->
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- annotations de persistance -->
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
</beans> |
netbeans n'aime pas l'annotation "<tx:annotation-driven ..."... mais je ne comprends pas pourquoi.
lolveley.