the_negao 20 de jul. de 2006
1º) Essa informações só precisam constar em um lugar apenas
2º) O arquivo de configuração do Hibernate é o hibernate.cfg.xml e não .hbm.xml
3º) Configurando ele basta colocar no seu código a SessionFactory recebendo as configurações, tipo:
sessionFactory = new Configuration().configure("/PACOTE/hibernate.cfg.xml").buildSessionFactory();
the_negao 20 de jul. de 2006
Outra coisa, verifique se dentro do seu /WEB-INF/lib/ ou no seu CLASSPATH está o .jar do Driver do Oracle.
fhsantiago:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at org.apache.catalina.loader.WebappClassLoader.loadClass fhsantiago 20 de jul. de 2006
Brigado pessoal. mas me responda uma coisa. o driver oracle é esse aqui
ojdbc14.zip???
presisa de mais algo,alem dos arquivos do hibernate claro…
the_negao 20 de jul. de 2006
Não me recordo agora os .jar do Oracle…
Mas o ojdbc14.jar com certeza deve estar presente, não sei outros .jar devem estar presente também.
Após teste, foi solicitado mais alguma class que não foi encontrada?
fhsantiago 20 de jul. de 2006
INFO : Reloading this Context has started
2006 -07 -20 10 : 34 : 54 , 531 INFO hibernate . cfg . Environment -> Hibernate 3.0.5
2006 -07 -20 10 : 34 : 54 , 546 INFO hibernate . cfg . Environment -> loaded properties from resource hibernate . properties : { hibernate . connection . username = ibict_fs , hibernate . default_schema = IBICT_FS , hibernate . connection . password =**** , hibernate . cglib . use_reflection_optimizer = true , hibernate . dialect = org . hibernate . dialect . OracleDialect , hibernate . connection . url = jdbc : oracle : thin : @192.168.0.254 : 1521 : sigmab , hibernate . connection . driver_class = oracle . jdbc . driver . OracleDriver }
2006 -07 -20 10 : 34 : 54 , 546 INFO hibernate . cfg . Environment -> using CGLIB reflection optimizer
2006 -07 -20 10 : 34 : 54 , 546 INFO hibernate . cfg . Environment -> using JDK 1.4 java . sql . Timestamp handling
2006 -07 -20 10 : 34 : 54 , 750 INFO hibernate . cfg . Configuration -> configuring from resource : hibernate . cfg . xml
2006 -07 -20 10 : 34 : 54 , 750 INFO hibernate . cfg . Configuration -> Configuration resource : hibernate . cfg . xml
2006 -07 -20 10 : 34 : 54 , 937 INFO hibernate . cfg . Configuration -> Mapping resource : demo / TbEventos . hbm . xml
2006 -07 -20 10 : 34 : 55 , 140 INFO hibernate . cfg . HbmBinder -> Mapping class : hibernate . TbEventos -> TB_EVENTOS
2006 -07 -20 10 : 34 : 55 , 203 INFO hibernate . cfg . Configuration -> Configured SessionFactory : null
2006 -07 -20 10 : 34 : 55 , 218 INFO hibernate . cfg . Configuration -> processing extends queue
2006 -07 -20 10 : 34 : 55 , 218 INFO hibernate . cfg . Configuration -> processing collection mappings
2006 -07 -20 10 : 34 : 55 , 218 INFO hibernate . cfg . Configuration -> processing association property references
2006 -07 -20 10 : 34 : 55 , 218 INFO hibernate . cfg . Configuration -> processing foreign key constraints
2006 -07 -20 10 : 34 : 55 , 406 INFO hibernate . connection . C3P0ConnectionProvider -> C3P0 using driver : oracle . jdbc . driver . OracleDriver at URL : jdbc : oracle : thin : @192.168.0.254 : 1521 : sigmab
2006 -07 -20 10 : 34 : 55 , 406 INFO hibernate . connection . C3P0ConnectionProvider -> Connection properties : { user = ibict_fs , password =**** }
2006 -07 -20 10 : 34 : 55 , 406 INFO hibernate . connection . C3P0ConnectionProvider -> autocommit mode : false
2006 -07 -20 10 : 34 : 55 , 437 FATAL hibernate . connection . C3P0ConnectionProvider -> JDBC Driver class not found : oracle . jdbc . driver . OracleDriver
java . lang . ClassNotFoundException : oracle . jdbc . driver . OracleDriver
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1340 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1189 )
sempre o erro do oracle…
o meu arquivo ta assim
factory = new Configuration().configure(“hibernate.cfg.xml”).buildSessionFactory();
e o hibernate.cfg.xml ta na raiz…
Fontes\proj\JavaSource
the_negao 20 de jul. de 2006
Anteriormente você colocou que o arquivo lib do Oracle JDBC era um .zip, se for isso mesmo, renomei a extensão para .jar, talvez possa ser isso!
fhsantiago 20 de jul. de 2006
cara… parece que funcionou aqui…mas olha o erro…
org . apache . jasper . JasperException : Not able to obtain connection
org . apache . jasper . servlet . JspServletWrapper . service ( JspServletWrapper . java : 372 )
org . apache . jasper . servlet . JspServlet . serviceJspFile ( JspServlet . java : 292 )
org . apache . jasper . servlet . JspServlet . service ( JspServlet . java : 236 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 802 )
root cause
org . hibernate . HibernateException : Not able to obtain connection
org . hibernate . jdbc . ConnectionManager . getConnection ( ConnectionManager . java : 113 )
org . hibernate . jdbc . AbstractBatcher . prepareQueryStatement ( AbstractBatcher . java : 88 )
org . hibernate . loader . Loader . prepareQueryStatement ( Loader . java : 1162 )
org . hibernate . loader . Loader . doQuery ( Loader . java : 390 )
org . hibernate . loader . Loader . doQueryAndInitializeNonLazyCollections ( Loader . java : 218 )
org . hibernate . loader . Loader . doList ( Loader . java : 1593 )
org . hibernate . loader . Loader . list ( Loader . java : 1577 )
org . hibernate . loader . hql . QueryLoader . list ( QueryLoader . java : 395 )
org . hibernate . hql . ast . QueryTranslatorImpl . list ( QueryTranslatorImpl . java : 271 )
org . hibernate . impl . SessionImpl . list ( SessionImpl . java : 844 )
org . hibernate . impl . QueryImpl . list ( QueryImpl . java : 74 )
demo . TbEventosFacade . getEventos ( TbEventosFacade . java : 21 )
org . apache . jsp . pages . inputname_jsp . _jspService ( inputname_jsp . java : 112 )
org . apache . jasper . runtime . HttpJspBase . service ( HttpJspBase . java : 94 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 802 )
org . apache . jasper . servlet . JspServletWrapper . service ( JspServletWrapper . java : 324 )
org . apache . jasper . servlet . JspServlet . serviceJspFile ( JspServlet . java : 292 )
org . apache . jasper . servlet . JspServlet . service ( JspServlet . java : 236 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 802 )
the_negao 20 de jul. de 2006
O que está presente no seu código nessa parte?
demo.TbEventosFacade.getEventos(TbEventosFacade.java:21)
O Hibernate não está conseguindo estabelecer uma conexão!
fhsantiago 20 de jul. de 2006
package demo ;
import java.util.List ;
import org.hibernate.Query ;
import org.hibernate.Session ;
import org.hibernate.Transaction ;
public class TbEventosFacade {
public List getEventos (){
Session sessao = HibernateUtility . getSession ();
Transaction tx = sessao . beginTransaction ();
Query select = sessao . createQuery ( "from TbEventos" );
List objetos = select . list ();
System . out . println ( objetos );
tx . commit ();
sessao . close ();
return select . list ();
}
}
brigadao pela força ai cara…
the_negao 20 de jul. de 2006
Mas diz qual é a linha 21 do código, assim não dá para saber!
Ah! E por que você não dá um return objetos no lugar de return select.list() ?
fhsantiago 20 de jul. de 2006
hahahahahaahahaahahah… Brigadao…Funcionou aqui.