Ola pessoal, tudo bem.
Estou desenvolvendo uma pequena aplicação, e é a primeira vez que uso o spring.
Assistindo o material do Marcos Souza(Dev Media), ele passa o datasource do Spring com um endereço do contexto do tomcat…
Mas meu server agora é o Jboss-as e eu estou tentando utlizar o MeuDatasource-ds.xml, que carrega normal na inicilização do Server.
Mas quando, chama, da uns erros e não consegue conectar aparentemente. se alguma puder analisar e passar como deve ser eu agradeço.
SofistCarros-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>SofistCarrosDatasource</jndi-name>
<use-java-context>true</use-java-context>
<connection-url>jdbc:postgresql://localhost:5432/sofistcarros</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<user-name>postgres</user-name>
<password>1234</password>
</local-tx-datasource>
</datasources>
components.xml
<?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: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/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
http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.2.xsd">
<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"/>
<persistence:managed-hibernate-session name="hibernateSession" session-factory="#{springSessionFactory}" auto-create="true"></persistence:managed-hibernate-session>
<core:init debug="true" />
<spring:context-loader config-locations="/WEB-INF/applicationContext.xml" />
<spring:spring-transaction platform-transaction-manager="#{transactionManager}"></spring:spring-transaction>
</components>
applicationContext.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:seam="http://jboss.com/products/seam/spring-seam"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://jboss.com/products/seam/spring-seam http://jboss.com/products/seam/spring-seam-2.2.xsd"
default-autowire="byName" default-lazy-init="true">
<bean id="dataSource" destroy-method="close" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:/SofistCarrosDatasource</value>
</property>
</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 id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"></bean>
<tx:annotation-driven proxy-target-class="true"/>
<bean name="sessionFactory" class="org.jboss.seam.ioc.spring.SeamManagedSessionFactoryBean">
<property name="sessionName" value="hibernateSession"></property><?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:seam="http://jboss.com/products/seam/spring-seam"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://jboss.com/products/seam/spring-seam http://jboss.com/products/seam/spring-seam-2.2.xsd"
default-autowire="byName" default-lazy-init="true">
<bean id="dataSource" destroy-method="close" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:/SofistCarrosDatasource</value>
</property>
</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 id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"></bean>
<tx:annotation-driven proxy-target-class="true"/>
<bean name="sessionFactory" class="org.jboss.seam.ioc.spring.SeamManagedSessionFactoryBean">
<property name="sessionName" value="hibernateSession"></property>
</bean>
<!-- Declaração dos DAO`s -->
<bean id="revendaDAO" class="br.com.sofistcarros.dao.RevendaDAO"></bean>
<!-- Declarações Removidas -->
<!-- <property name="sessionFactory" ref="springSessionFactory"></property>-->
<!-- <seam:component/>-->
<!-- <bean id="dataSource" destroy-method="close" class="org.springframework.jdbc.datasource.DriverManagerDataSource">-->
</beans>
</bean>
<!-- Declaração dos DAO`s -->
<bean id="revendaDAO" class="br.com.sofistcarros.dao.RevendaDAO"></bean>
<!-- Declarações Removidas -->
<!-- <property name="sessionFactory" ref="springSessionFactory"></property>-->
<!-- <seam:component/>-->
<!-- <bean id="dataSource" destroy-method="close" class="org.springframework.jdbc.datasource.DriverManagerDataSource">-->
</beans>
Obrigado.