Problemas com integração JBoss Seam com Spring

0 respostas
E

Olá pessoal,

Estou tentando integrar o JBoss Seam com o Spring, para que este seja responsável palo gerenciamento das transações da aplicação.

Fiz a configuração no faces-config.xml, adicionando a linha:
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
Meu arquivo components.xml está assim:
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
            xmlns:core="http://jboss.com/products/seam/core"
            xmlns:persistence="http://jboss.com/products/seam/persistence"
            xmlns:drools="http://jboss.com/products/seam/drools"
            xmlns:bpm="http://jboss.com/products/seam/bpm"
            xmlns:security="http://jboss.com/products/seam/security"
        xmlns:spring="http://jboss.com/products/seam/spring"
        xmlns:transaction="http://jboss.com/products/seam/transaction"
        xmlns:ui="http://jboss.com/products/seam/ui"
            xmlns:mail="http://jboss.com/products/seam/mail"
            xmlns:web="http://jboss.com/products/seam/web"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation=
                "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
                 http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
                 http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
                 http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.2.xsd
                 http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
         http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.2.xsd
         http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.2.xsd
                 http://jboss.com/products/seam/ui http://jboss.com/products/seam/ui-2.2.xsd
                 http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
                 http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
                 http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd">

   <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>

   <core:manager concurrent-request-timeout="500"
                 conversation-timeout="120000"
                 conversation-id-parameter="cid"
                 parent-conversation-id-parameter="pid"/>

   <!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
   <web:hot-deploy-filter url-pattern="*.seam"/>

   <spring:context-loader />
   <persistence:managed-hibernate-session name="hibernateSession" session-factory="#{springSessionFactory}" auto-create="true"></persistence:managed-hibernate-session> 
   <spring:spring-transaction platform-transaction-manager="#{transactionManager}" join-transaction="true" auto-create="true"/>
   
   <!-- Install the SpringDispatcher as default -->
   <spring:task-executor-dispatcher schedule-dispatcher="#{threadPoolDispatcher}" task-executor="#{springThreadPoolTaskExecutor}"/> 
    <ui:hibernate-entity-loader session="#{hibernateSession}"/>

   <drools:rule-base name="securityRules">
      <drools:rule-files>
         <value>/security.drl</value>
      </drools:rule-files>
   </drools:rule-base>

   <security:rule-based-permission-resolver security-rules="#{securityRules}"/>

   <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>

   <event type="org.jboss.seam.security.notLoggedIn">
      <action execute="#{redirect.captureCurrentView}"/>
   </event>
   <event type="org.jboss.seam.security.loginSuccessful">
      <action execute="#{redirect.returnToCapturedView}"/>
   </event>

   <mail:mail-session host="localhost" port="25"/>

</components>
Já o applicationContext.xml está assim:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:util="http://www.springframework.org/schema/util" 
    xmlns:seam="http://jboss.com/products/seam/spring-seam"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
                           http://jboss.com/products/seam/spring-seam http://jboss.com/products/seam/spring-seam-2.2.xsd
                           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
    default-lazy-init="false">
    
    <import resource="spring-dao.xml"/> 
    
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <constructor-arg index="0" ref="springSessionFactory"></constructor-arg>
        <constructor-arg index="1" value="true"></constructor-arg>
    </bean>
    
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="url" value="jdbc:postgresql:sciweb"/>
        <property name="username" value="postgres"/>
        <property name="password" value="postgres"/>
    </bean>

    <bean id="springSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="configLocations" value="classpath*:hibernate.cfg.xml"></property>
        <property name="schemaUpdate" value="false"> </property>
        <property name="dataSource" ref="dataSource"> </property>
        <property name="exposeTransactionAwareSessionFactory" value="false"> </property>

    </bean>

    <bean name="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property> 
    </bean>
    
    <bean id="sessionFactory" class="org.jboss.seam.ioc.spring.SeamManagedSessionFactoryBean"> 
        <property name="sessionName" value="hiberanteSession"/>
    </bean>
        
    <!--<tx:annotation-driven proxy-target-class="true"/> -->
    
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
    
</beans>

Do jeito que está, o navegador acusa direcionamento incorreto, com a seguinte mensagem (neste caso uso o FIrefox)

O Firefox detectou que o pedido para este endereço não será concluído devido à forma que o servidor o está redirecionando.

E nenhuma mensagem de erro é mostrada no log do servidor.

Se eu remover a linha abaixo do components.xml:
<spring:spring-transaction platform-transaction-manager="#{transactionManager}" join-transaction="true" auto-create="true"/>
a aplicação funciona corretamente, mas eu queria entender o motivo e se existe algum efeito colateral com a remoção deste trecho de código ou ainda se existe alguma saída para a aplicação funcionar mesmo mantendo o trecho de código acima.

Qualquer ajuda será bem vinda.

Criado 29 de agosto de 2011
Respostas 0
Participantes 1