Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java EE (J2EE) и Spring > @Transactional & annotation-driven


Автор: chaos 8.2.2010, 17:41
Доброго времени суток!
Столкнулся проблемой: необходимо работать с транзакциями.
в конфиге прописываю
Код

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

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:flex="http://www.springframework.org/schema/flex"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:security="http://www.springframework.org/schema/security"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/flex
            http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
            http://www.springframework.org/schema/tx/
            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
            http://www.springframework.org/schema/security
            http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
            destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@ххх.ххх.ххх.ххх:1521:хххххх"/>
        <property name="username" value="хххх"/>
        <property name="password" value="хххх"/>
    </bean>
    
    <bean id="sessionFactory"
            class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan">
            <list>
                <value>ru.ххх.ххххх.хххх.vo</value>
            </list>
        </property>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
                <prop key="show_sql">true</prop>
                <prop key="hibernate.query.factory_class">
                    org.hibernate.hql.classic.ClassicQueryTranslatorFactory
                </prop>
            </props>
        </property>
    </bean>
    
    <bean id="transactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    
    <tx:annotation-driven/>

        <!-- дальше идут сервисы -->
</beans>


дак вот при деплои приложения получаю:
Код

ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 52 in 
XML document from ServletContext resource [/WEB-INF/business-logics-config.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'.



Подскажите в чем может быть проблема.


Заранее благодарен!

Добавлено через 1 минуту и 14 секунд
опять же если удаляю annotation-driven, то все деплоится но транзакции соответственно не робят

Автор: MisterCleric 8.2.2010, 18:03
У тебя парсер не может прочитать xml так как не находит 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/flex
            http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
            http://www.springframework.org/schema/tx/                         ------ зачем тута последний слеш??????
            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
            http://www.springframework.org/schema/security
            http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-2.5.xsd">

Автор: chaos 9.2.2010, 09:14
MisterCleric, спасибо! заработало!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)