renato_ramos 19 de out. de 2009
hmm… talvez eu tenha me expressado errado,
meu problema é que na hora de testar, os comandos xml não são reconhecidos.
devo ter feito algo errado… mas a questão é o que?
já fize e refiz ess tutorial várias vezes… sempre dá esse erro.
obrigado
[]'s
novato22 19 de out. de 2009
Qual a versão do Spring que você está utilizando? Fez a importação dos .jar do Spring? Cole o erro que está dando aqui. Outra coisa, sua aplicação é web ou desktop?
renato_ramos 19 de out. de 2009
valeu a atenção novato22
eu arrumei mas não sei o que eu arrumei… eu peguei um outro modelo de coniguração para o spring da internet e tem umas urls a mais na tag do beans
agora o meu erro é na conexão com o banco
vo colar o codigo aki
<beans xmlns= "http://www.springframework.org/schema/beans"
xmlns:context= "http://www.springframework.org/schema/context"
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf= "http://cxf.apache.org/core"
xmlns:jaxws= "http://cxf.apache.org/jaxws" xmlns:tx= "http://www.springframework.org/schema/tx"
xmlns:p= "http://www.springframework.org/schema/p" xmlns:jaxrs= "http://cxf.apache.org/jaxrs"
xsi:schemaLocation= "
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd" >
<bean id= "propertyConfigurer" class= "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name= "location" value= "classpath:/jdbc.properties"/ >
</bean>
<bean id= "dataSource" class= "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "close" >
<property name= "jdbcUrl" value= " ${ jdbc . driverClassName } "/ >
<property name= "user" value= " ${ jdbc . username } "/ >
<property name= "password" value= " $ {jdbc.password"/ >
</bean>
<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= "generateDdl" value= "false"/ >
<property name= "databasePlatform" value= "org.hibernate.dialect.PostgreSQLDialect"/ >
</bean>
</property>
</bean>
<bean id= "transactionManager" class= "org.springframework.orm.jpa.JpaTransactionManager" >
<property name= "entityManagerFactory" ref= "entityManagerFactory"/ >
</bean>
<tx:annotation -driven />
<bean class= "org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/ >
<bean class= "org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/ >
<bean id= "usuario" class= "dominio.Usuario" scope= "session"/ >
<bean id= "usuarioDao" class= "dao.UsuarioDao"/ >
<bean id= "usuarioFacade" class= "facade.UsuarioFacade" >
<property name= "usuarioDao" ref= "usuarioDao"/ >
</bean>
</beans>
o erro ta dando nessa linha
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
meu arquivo de propriedades do banco é esse
jdbc.driverClassName= org.postgresql.Driver
jdbc.url = jdbc:postgresql://localhost:5432/Projeto
jdbc.username=postgres
jdbc.password=admin
minha aplicação é pra web e estou utilizando o Spring 2.5.6SEC01 junto com o hibernate
mt obirgado…
[]'s
renato_ramos 19 de out. de 2009
não sei c ajuda mas esse é o erro que está na hora do teste
tem mais coisa… mas não sei se é viavel colocar …
mt obrigado
[]'s
19 / 10 / 2009 13 : 49 : 53 org . springframework . context . support . AbstractApplicationContext prepareRefresh
INFO : Refreshing org . springframework . context . support . ClassPathXmlApplicationContext @1 be0f0a : display name [ org . springframework . context . support . ClassPathXmlApplicationContext @1 be0f0a ]; startup date [ Mon Oct 19 13 : 49 : 53 BRST 2009 ]; root of context hierarchy
19 / 10 / 2009 13 : 49 : 53 org . springframework . beans . factory . xml . XmlBeanDefinitionReader loadBeanDefinitions
INFO : Loading XML bean definitions from class path resource [ applicationContext . xml ]
19 / 10 / 2009 13 : 49 : 54 org . springframework . context . support . AbstractApplicationContext obtainFreshBeanFactory
INFO : Bean factory for application context [ org . springframework . context . support . ClassPathXmlApplicationContext @1 be0f0a ] : org . springframework . beans . factory . support . DefaultListableBeanFactory @10721 b0
19 / 10 / 2009 13 : 49 : 54 org . springframework . core . io . support . PropertiesLoaderSupport loadProperties
INFO : Loading properties file from class path resource [ jdbc . properties ]
19 / 10 / 2009 13 : 49 : 54 com . mchange . v2 . log . MLog < clinit >
INFO : MLog clients using java 1.4 + standard logging .
19 / 10 / 2009 13 : 49 : 54 com . mchange . v2 . c3p0 . C3P0Registry banner
INFO : Initializing c3p0 -0.9.1.2 [ built 21 - May -2007 15 : 04 : 56 ; debug ? true ; trace : 10 ]
19 / 10 / 2009 13 : 49 : 54 org . springframework . context . support . AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO : Bean ' dataSource ' is not eligible for getting processed by all BeanPostProcessors ( for example : not eligible for auto - proxying )
19 / 10 / 2009 13 : 49 : 54 org . springframework . context . support . AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO : Bean ' org . springframework . orm . jpa . vendor . HibernateJpaVendorAdapter # b33d0a ' is not eligible for getting processed by all BeanPostProcessors ( for example : not eligible for auto - proxying )
19 / 10 / 2009 13 : 49 : 54 org . springframework . orm . jpa . LocalContainerEntityManagerFactoryBean createNativeEntityManagerFactory
INFO : Building JPA container EntityManagerFactory for persistence unit ' Questionario - jarPU '
19 / 10 / 2009 13 : 49 : 54 org . hibernate . cfg . annotations . Version < clinit >
INFO : Hibernate Annotations 3.3.1 . GA
19 / 10 / 2009 13 : 49 : 54 org . hibernate . cfg . Environment < clinit >
INFO : Hibernate 3.2.5
19 / 10 / 2009 13 : 49 : 54 org . hibernate . cfg . Environment < clinit >
INFO : hibernate . properties not found
19 / 10 / 2009 13 : 49 : 54 org . hibernate . cfg . Environment buildBytecodeProvider
INFO : Bytecode provider name : cglib
19 / 10 / 2009 13 : 49 : 54 org . hibernate . cfg . Environment < clinit >
INFO : using JDK 1.4 java . sql . Timestamp handling
19 / 10 / 2009 13 : 49 : 54 org . hibernate . ejb . Version < clinit >
INFO : Hibernate EntityManager 3.3.2 . GA
19 / 10 / 2009 13 : 49 : 54 org . hibernate . ejb . Ejb3Configuration configure
INFO : Processing PersistenceUnitInfo [
name : Questionario - jarPU
...]
19 / 10 / 2009 13 : 49 : 54 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . TipoLogradouro
19 / 10 / 2009 13 : 49 : 54 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : TipoLogradouro . findAll => SELECT t FROM TipoLogradouro t
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . TipoLogradouro on table tbl_tipo_logradouro
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Cidade
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Cidade . findAll => SELECT c FROM Cidade c
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Cidade on table tbl_cidade
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Estado
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Estado . findAll => SELECT e FROM Estado e
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Estado on table tbl_estado
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Logradouro
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Logradouro . findAll => SELECT l FROM Logradouro l
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Logradouro on table tbl_logradouro
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Usuario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Usuario . findAll => SELECT u FROM Usuario u
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Usuario on table tbl_usuario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Resposta
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Resposta . findAll => SELECT r FROM Resposta r
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Resposta on table tbl_resposta
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Questionario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Questionario . findAll => SELECT q FROM Questionario q
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Questionario on table tbl_questionario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . ModeloQuestionario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : ModeloQuestionario . findAll => SELECT m FROM ModeloQuestionario m
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . ModeloQuestionario on table tbl_modelo_questionario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Objeto
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Objeto . findAll => SELECT o FROM Objeto o
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Objeto on table tbl_objeto
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationBinder bindClass
INFO : Binding entity from annotated class : dominio . Questao
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . QueryBinder bindQuery
INFO : Binding Named query : Questao . findAll => SELECT q FROM Questao q
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . EntityBinder bindTable
INFO : Bind entity dominio . Questao on table tbl_questao
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Cidade . logradouroCollection -> tbl_logradouro
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Estado . cidadeCollection -> tbl_cidade
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Logradouro . objetoCollection -> tbl_objeto
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Usuario . respostaCollection -> tbl_resposta
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Questionario . modeloQuestionarioCollection -> tbl_modelo_questionario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Questionario . respostaCollection -> tbl_resposta
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Objeto . respostaCollection -> tbl_resposta
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . annotations . CollectionBinder bindOneToManySecondPass
INFO : Mapping collection : dominio . Questao . modeloQuestionarioCollection -> tbl_modelo_questionario
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . AnnotationConfiguration secondPassCompile
INFO : Hibernate Validator not found : ignoring
19 / 10 / 2009 13 : 49 : 55 org . hibernate . connection . ConnectionProviderFactory newConnectionProvider
INFO : Initializing connection provider : org . hibernate . ejb . connection . InjectedDataSourceConnectionProvider
19 / 10 / 2009 13 : 49 : 55 org . hibernate . ejb . connection . InjectedDataSourceConnectionProvider configure
INFO : Using provided datasource
19 / 10 / 2009 13 : 49 : 55 com . mchange . v2 . c3p0 . impl . AbstractPoolBackedDataSource getPoolManager
INFO : Initializing c3p0 pool ... com . mchange . v2 . c3p0 . ComboPooledDataSource [ acquireIncrement -> 3 , acquireRetryAttempts -> 30 , acquireRetryDelay -> 1000 , autoCommitOnClose -> false , automaticTestTable -> null , breakAfterAcquireFailure -> false , checkoutTimeout -> 0 , connectionCustomizerClassName -> null , connectionTesterClassName -> com . mchange . v2 . c3p0 . impl . DefaultConnectionTester , dataSourceName -> 1 hge0zz84udo2zc9x8alb | 1 cf7491 , debugUnreturnedConnectionStackTraces -> false , description -> null , driverClass -> null , factoryClassLocation -> null , forceIgnoreUnresolvedTransactions -> false , identityToken -> 1 hge0zz84udo2zc9x8alb | 1 cf7491 , idleConnectionTestPeriod -> 0 , initialPoolSize -> 3 , jdbcUrl -> jdbc : postgresql : //localhost:5432/Projeto, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
19 / 10 / 2009 13 : 49 : 55 org . hibernate . cfg . SettingsFactory buildSettings
WARNING : Could not obtain connection metadata
java . sql . SQLException : No suitable driver
at java . sql . DriverManager . getDriver ( DriverManager . java : 243 )
at com . mchange . v2 . c3p0 . DriverManagerDataSource . driver ( DriverManagerDataSource . java : 223 )
at com . mchange . v2 . c3p0 . DriverManagerDataSource . getConnection ( DriverManagerDataSource . java : 134 )
at com . mchange . v2 . c3p0 . WrapperConnectionPoolDataSource . getPooledConnection ( WrapperConnectionPoolDataSource . java : 182 )
at com . mchange . v2 . c3p0 . WrapperConnectionPoolDataSource . getPooledConnection ( WrapperConnectionPoolDataSource . java : 171 )
at com . mchange . v2 . c3p0 . impl . C3P0PooledConnectionPoolManager . ensureFirstConnectionAcquisition ( C3P0PooledConnectionPoolManager . java : 845 )
at com . mchange . v2 . c3p0 . impl . C3P0PooledConnectionPoolManager . createPooledConnectionPool ( C3P0PooledConnectionPoolManager . java : 733 )
at com . mchange . v2 . c3p0 . impl . C3P0PooledConnectionPoolManager . getPool ( C3P0PooledConnectionPoolManager . java : 257 )
at com . mchange . v2 . c3p0 . impl . C3P0PooledConnectionPoolManager . getPool ( C3P0PooledConnectionPoolManager . java : 249 )
at com . mchange . v2 . c3p0 . impl . AbstractPoolBackedDataSource . getConnection ( AbstractPoolBackedDataSource . java : 134 )
at org . hibernate . ejb . connection . InjectedDataSourceConnectionProvider . getConnection ( InjectedDataSourceConnectionProvider . java : 44 )
at org . hibernate . cfg . SettingsFactory . buildSettings ( SettingsFactory . java : 84 )
at org . hibernate . cfg . Configuration . buildSettings ( Configuration . java : 2009 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1292 )
at org . hibernate . cfg . AnnotationConfiguration . buildSessionFactory ( AnnotationConfiguration . java : 859 )
at org . hibernate . ejb . Ejb3Configuration . buildEntityManagerFactory ( Ejb3Configuration . java : 669 )
at org . hibernate . ejb . HibernatePersistence . createContainerEntityManagerFactory ( HibernatePersistence . java : 132 )
wilds87 19 de out. de 2009
renato_ramos 19 de out. de 2009
novato22 19 de out. de 2009
Renato,
faz o seguinte: Copia o driver do banco para a pasta lib do tomcat.
em outras palavras: copia o driver do banco (Exemplo-mysql: mysql-connector-java-3.1.14-bin.jar) que está na sua aplicação para a pasta lib do tamcat (exemplo de caminho: C:\Arquivos de programas\Apache Software Foundation\Tomcat 6.0\lib), e testa.
Acho que seu primeiro exemplo não funcionou porque estava configurado para Spring-2.0, mas vc já corrigiu.
renato_ramos 19 de out. de 2009
mais uma vez obrigado pela atenção novato22
então acho que agora eu arrumei mas ainda não está bom
agora o problema é uma exeção de SQL … olhando na internet eu vi q pra configurar o sprign pro postgre é diferente e como o livre que eu peguei é pro MySql,não sei se tem alguma coisa a ver…
a exeção é essa
19 / 10 / 2009 15 : 50 : 40 or g . hibernate . util . JDBCExceptionReporter log Exceptions
WARNING : SQL Error : 0 , SQLState : 42 P01
19 / 10 / 2009 15 : 50 : 40 or g . hibernate . util . JDBCExceptionReporter log Exceptions
SEVERE : ERRO : relação "hibernate_sequence" não existe
caso vc tenha alguma tutorial de spring para e hibernate pro postgres posta aih… fazendo favor
valeeeeu!
[]'s
renato_ramos 19 de out. de 2009
muito obrigado pelas dicas novato22
consegui resolver na tentativa erro
o problema estava sendo causado por causa da difrenca dos bancos
na classe gerada pelo hibernate o livro fala para colocar na frente do @id da classe de entidade
@GeneratedValue ( strategy = GenerationType . AUTO )
aih tentando estrategias diferentes… eu encontrei a estrategia
@GeneratedValue ( strategy = GenerationType . IDENTITY )
e finalmente após 7h de tentativas… o teste funciono \o/
como eu coloco resolvido? xD
[]'s
novato22 19 de out. de 2009
Renato,
Que bom que conseguiu resolver. Para colocar resolvido você vai no primeiro post deste tópico e clica no botão editar na barrinha azul. Então é só editar acrescentando [resolvido].
Valeu.