Fórum Erro ao usar JPA em projeto web #413920

11/03/2012

0

quando vou testar meu programa junit me retorna isso:


Mar 11, 2012 4:24:36 PM org.hibernate.cfg.annotations.Version <clinit>
Informações: Hibernate Annotations 3.3.1.GA
Mar 11, 2012 4:24:36 PM org.hibernate.cfg.Environment <clinit>
Informações: Hibernate 3.2.5
Mar 11, 2012 4:24:36 PM org.hibernate.cfg.Environment <clinit>
Informações: hibernate.properties not found
Mar 11, 2012 4:24:36 PM org.hibernate.cfg.Environment buildBytecodeProvider
Informações: Bytecode provider name : cglib
Mar 11, 2012 4:24:36 PM org.hibernate.cfg.Environment <clinit>
Informações: using JDK 1.4 java.sql.Timestamp handling
Mar 11, 2012 4:24:37 PM org.hibernate.ejb.Version <clinit>
Informações: Hibernate EntityManager 3.3.2.GA
Mar 11, 2012 4:24:37 PM org.hibernate.cfg.AnnotationBinder bindClass
Informações: Binding entity from annotated class: br.com.Modelo.ModeloBanco
Mar 11, 2012 4:24:37 PM org.hibernate.cfg.annotations.EntityBinder bindTable
Informações: Bind entity br.com.Modelo.ModeloBanco on table banco
Mar 11, 2012 4:24:37 PM org.hibernate.cfg.AnnotationConfiguration secondPassCompile
Informações: Hibernate Validator not found: ignoring
Mar 11, 2012 4:24:37 PM org.hibernate.util.NamingHelper getInitialContext
Informações: JNDI InitialContext properties:{}
Mar 11, 2012 4:24:54 PM org.hibernate.connection.DatasourceConnectionProvider configure
Grave: Could not find datasource: adinstar
javax.naming.NamingException: Lookup failed for adinstar in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NameNotFoundException: adinstar not found]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
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.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at br.com.Controller.JPAUtil.<init>(JPAUtil.java:21)
at br.com.Controller.JPAUtil.getInstance(JPAUtil.java:27)
at br.com.Controller.ControllerBanco.addBanco(ControllerBanco.java:21)
at br.com.Controller.ControllerBancoTest.testAddBanco(ControllerBancoTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
Paulo Gomes

Paulo Gomes

Responder

Posts

11/03/2012

Robson Teixeira

pelo log postado parece que o servidor no caso o glassfish não encontrou o data-source especificado no persistence.xml de sua app.

espero ter ajudado.
att
robson
Responder

Gostei + 0

11/03/2012

Paulo Gomes

eu sinceramente não entendo

pra desktop eu faço da mesma forma e funciona
Responder

Gostei + 0

11/03/2012

Robson Teixeira

como assim??? mesma coisa???
gostaria contar mais detalhes????
e para ver o problema do Hibernate com o servidor e simples no seu persistence.xml tem a tag <jta-data-source> e o valor inserido nessa tag deve está identico no seu servidor na parte de contextos de persistencia. se tiver divergencia pode ser isso que não permite o lookup de persistencia.

espero ter ajudado.
att
robson
Responder

Gostei + 0

11/03/2012

Paulo Gomes

meu xml de persistence

obs troquei o servidor para tomcat

<?xml version=1.0 encoding=UTF-8?>
<persistence version=2.0 xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd>
<persistence-unit name=PostgreWeb2PU transaction-type=JTA>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>postgree</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>

Responder

Gostei + 0

11/03/2012

Paulo Gomes

bom resolvi pessoal

acreditei ou não era problema com o servidor tomcat, instalei de novo e funciono perfeitamente
Responder

Gostei + 0

11/03/2012

Paulo Gomes

como sou novo no forum n sei finalizar o topico se alguem poder ajudar agradeço.
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar