raimundo 5 de ago. de 2009
post o hibernate.cfg.xml.
caso utilize o datasource tb.
Rodrigo_Silveira 5 de ago. de 2009
<?xml version="1.0" encoding="UTF-8"?>
org.hibernate.dialect.MySQLDialect
com.mysql.jdbc.Driver
jdbc:mysql://localhost/oficina
root
raimundo 5 de ago. de 2009
adicione isso;
org.hibernate.transaction.JDBCTransactionFactory
o schema está criado?
vc usa annotation?
mostre o seu código de criação da conexão.
Rodrigo_Silveira 6 de ago. de 2009
minha unidade de persistencia esta assim:
<?xml version="1.0" encoding="UTF-8"?>
org.hibernate.ejb.HibernatePersistence
oficina
br.com.oficinanet.ent.Cliente
br.com.oficinanet.ent.Estoque
br.com.oficinanet.ent.Mecanico
br.com.oficinanet.ent.Peca
br.com.oficinanet.ent.Servico
br.com.oficinanet.ent.Veiculo
true
roger_rf 6 de ago. de 2009
Já experimentou colocar os dados de conexão do Hibernate nas propriedades da Persistence Unit?
<?xml version="1.0" encoding="UTF-8"?>
<persistence version= "1.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_1_0.xsd" >
<persistence-unit name= "oficinaPU" transaction-type= "RESOURCE_LOCAL" >
<provider> org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name= "hibernate.dialect" value= "org.hibernate.dialect.MySQLDialect" />
<property name= "hibernate.connection.driver_class" value= "com.mysql.jdbc.Driver" />
<property name= "hibernate.connection.url" value= "jdbc:mysql://localhost/oficina" />
<property name= "hibernate.connection.username" value= "root" />
<property name= "hibernate.connection.password" value= "senha" />
</properties>
</persistence-unit>
</persistence>
A propósito, apesar de minha experiência com aplicações Web e servidores de aplicações ser quase zero, se você usar o item oficina na Persistence Unit, se não me engano é necessário configurar no servidor de aplicações um DataSource com nome correspondente (neste caso, “oficina”).
Rodrigo_Silveira 6 de ago. de 2009
Olá
Não sei se eu sou muito novato no assunto mas agora esta aprensentando o seguinte erro…
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax . servlet . ServletException : javax . persistence . PersistenceException : [ PersistenceUnit : oficinaPU ] Unable to build EntityManagerFactory
org . apache . struts . action . RequestProcessor . processException ( RequestProcessor . java : 520 )
org . apache . struts . action . RequestProcessor . processActionPerform ( RequestProcessor . java : 427 )
org . apache . struts . action . RequestProcessor . process ( RequestProcessor . java : 228 )
org . apache . struts . action . ActionServlet . process ( ActionServlet . java : 1913 )
org . apache . struts . action . ActionServlet . doGet ( ActionServlet . java : 449 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 617 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 390 )
root cause
javax . persistence . PersistenceException : [ PersistenceUnit : oficinaPU ] Unable to build EntityManagerFactory
org . hibernate . ejb . Ejb3Configuration . buildEntityManagerFactory ( Ejb3Configuration . java : 677 )
org . hibernate . ejb . HibernatePersistence . createEntityManagerFactory ( HibernatePersistence . java : 126 )
javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 51 )
javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 33 )
br . com . oficinanet . dao . AbstratoDAO .( AbstratoDAO . java : 24 )
br . com . oficinanet . dao . MecanicoDAO .( MecanicoDAO . java : 21 )
br . com . oficinanet . struts . MecanicoAction . incluir ( MecanicoAction . java : 61 )
br . com . oficinanet . struts . MecanicoAction . execute ( MecanicoAction . java : 43 )
org . apache . struts . action . RequestProcessor . processActionPerform ( RequestProcessor . java : 425 )
org . apache . struts . action . RequestProcessor . process ( RequestProcessor . java : 228 )
org . apache . struts . action . ActionServlet . process ( ActionServlet . java : 1913 )
org . apache . struts . action . ActionServlet . doGet ( ActionServlet . java : 449 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 617 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 390 )
root cause
org . hibernate . HibernateException : Could not find datasource
org . hibernate . connection . DatasourceConnectionProvider . configure ( DatasourceConnectionProvider . java : 56 )
org . hibernate . connection . ConnectionProviderFactory . newConnectionProvider ( ConnectionProviderFactory . java : 124 )
org . hibernate . ejb . InjectionSettingsFactory . createConnectionProvider ( InjectionSettingsFactory . java : 29 )
org . hibernate . cfg . SettingsFactory . buildSettings ( SettingsFactory . java : 62 )
org . hibernate . cfg . Configuration . buildSettings ( Configuration . java : 2009 )
org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1292 )
org . hibernate . cfg . AnnotationConfiguration . buildSessionFactory ( AnnotationConfiguration . java : 859 )
org . hibernate . ejb . Ejb3Configuration . buildEntityManagerFactory ( Ejb3Configuration . java : 669 )
org . hibernate . ejb . HibernatePersistence . createEntityManagerFactory ( HibernatePersistence . java : 126 )
javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 51 )
javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 33 )
br . com . oficinanet . dao . AbstratoDAO .( AbstratoDAO . java : 24 )
br . com . oficinanet . dao . MecanicoDAO .( MecanicoDAO . java : 21 )
br . com . oficinanet . struts . MecanicoAction . incluir ( MecanicoAction . java : 61 )
br . com . oficinanet . struts . MecanicoAction . execute ( MecanicoAction . java : 43 )
org . apache . struts . action . RequestProcessor . processActionPerform ( RequestProcessor . java : 425 )
org . apache . struts . action . RequestProcessor . process ( RequestProcessor . java : 228 )
org . apache . struts . action . ActionServlet . process ( ActionServlet . java : 1913 )
org . apache . struts . action . ActionServlet . doGet ( ActionServlet . java : 449 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 617 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 390 )
root cause
javax . naming . NameNotFoundException : Name oficina is not bound in this Context
org . apache . naming . NamingContext . lookup ( NamingContext . java : 770 )
org . apache . naming . NamingContext . lookup ( NamingContext . java : 153 )
org . apache . naming . SelectorContext . lookup ( SelectorContext . java : 137 )
javax . naming . InitialContext . lookup ( InitialContext . java : 392 )
org . hibernate . connection . DatasourceConnectionProvider . configure ( DatasourceConnectionProvider . java : 52 )
org . hibernate . connection . ConnectionProviderFactory . newConnectionProvider ( ConnectionProviderFactory . java : 124 )
org . hibernate . ejb . InjectionSettingsFactory . createConnectionProvider ( InjectionSettingsFactory . java : 29 )
org . hibernate . cfg . SettingsFactory . buildSettings ( SettingsFactory . java : 62 )
org . hibernate . cfg . Configuration . buildSettings ( Configuration . java : 2009 )
org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1292 )
org . hibernate . cfg . AnnotationConfiguration . buildSessionFactory ( AnnotationConfiguration . java : 859 )
org . hibernate . ejb . Ejb3Configuration . buildEntityManagerFactory ( Ejb3Configuration . java : 669 )
org . hibernate . ejb . HibernatePersistence . createEntityManagerFactory ( HibernatePersistence . java : 126 )
javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 51 )
javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 33 )
br . com . oficinanet . dao . AbstratoDAO .( AbstratoDAO . java : 24 )
br . com . oficinanet . dao . MecanicoDAO .( MecanicoDAO . java : 21 )
br . com . oficinanet . struts . MecanicoAction . incluir ( MecanicoAction . java : 61 )
br . com . oficinanet . struts . MecanicoAction . execute ( MecanicoAction . java : 43 )
org . apache . struts . action . RequestProcessor . processActionPerform ( RequestProcessor . java : 425 )
org . apache . struts . action . RequestProcessor . process ( RequestProcessor . java : 228 )
org . apache . struts . action . ActionServlet . process ( ActionServlet . java : 1913 )
org . apache . struts . action . ActionServlet . doGet ( ActionServlet . java : 449 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 617 )
javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 390 )
lvolgarini 14 de mar. de 2012
Olá pessoa!
Estou desenvolvendo uma applicação web, estou rodando a internet e não acho solução. Está acontecendo o mesmo erro:
javax . persistence . PersistenceException : [ PersistenceUnit : nucleoPU ] Unable to build EntityManagerFactory
at org . hibernate . ejb . Ejb3Configuration . buildEntityManagerFactory ( Ejb3Configuration . java : 892 )
at org . hibernate . ejb . HibernatePersistence . createEntityManagerFactory ( HibernatePersistence . java : 56 )
at javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 78 )
at javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 54 )
at criar . ezaz . codigos . db . nucleo . controles . NucleoController .< init >( NucleoController . java : 17 )
at criar . ezaz . codigos . db . nucleo . controles . UsuariosTblJpaController .< init >( UsuariosTblJpaController . java : 23 )
at criar . ezaz . codigos . operacoes . pa . OpLogin . processar ( OpLogin . java : 30 )
at criar . ezaz . codigos . ws . pa . WsLogin . login ( WsLogin . java : 36 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( NativeMethodAccessorImpl . java : 39 )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( DelegatingMethodAccessorImpl . java : 25 )
at java . lang . reflect . Method . invoke ( Method . java : 597 )
at com . sun . jersey . server . impl . model . method . dispatch . AbstractResourceMethodDispatchProvider $ TypeOutInvoker . _dispatch ( AbstractResourceMethodDispatchProvider . java : 149 )
at com . sun . jersey . server . impl . model . method . dispatch . ResourceJavaMethodDispatcher . dispatch ( ResourceJavaMethodDispatcher . java : 67 )
at com . sun . jersey . server . impl . uri . rules . HttpMethodRule . accept ( HttpMethodRule . java : 259 )
at com . sun . jersey . server . impl . uri . rules . ResourceClassRule . accept ( ResourceClassRule . java : 83 )
at com . sun . jersey . server . impl . uri . rules . RightHandPathRule . accept ( RightHandPathRule . java : 133 )
at com . sun . jersey . server . impl . uri . rules . RootResourceClassesRule . accept ( RootResourceClassesRule . java : 71 )
at com . sun . jersey . server . impl . application . WebApplicationImpl . _handleRequest ( WebApplicationImpl . java : 990 )
at com . sun . jersey . server . impl . application . WebApplicationImpl . handleRequest ( WebApplicationImpl . java : 941 )
at com . sun . jersey . server . impl . application . WebApplicationImpl . handleRequest ( WebApplicationImpl . java : 932 )
at com . sun . jersey . spi . container . servlet . WebComponent . service ( WebComponent . java : 384 )
at com . sun . jersey . spi . container . servlet . ServletContainer . service ( ServletContainer . java : 451 )
at com . sun . jersey . spi . container . servlet . ServletContainer . service ( ServletContainer . java : 632 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 847 )
at org . apache . catalina . core . StandardWrapper . service ( StandardWrapper . java : 1523 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 279 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 188 )
at org . apache . catalina . core . StandardPipeline . invoke ( StandardPipeline . java : 641 )
at com . sun . enterprise . web . WebPipeline . invoke ( WebPipeline . java : 97 )
at com . sun . enterprise . web . PESessionLockingStandardPipeline . invoke ( PESessionLockingStandardPipeline . java : 85 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 185 )
at org . apache . catalina . connector . CoyoteAdapter . doService ( CoyoteAdapter . java : 325 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 226 )
at com . sun . enterprise . v3 . services . impl . ContainerMapper . service ( ContainerMapper . java : 165 )
at com . sun . grizzly . http . ProcessorTask . invokeAdapter ( ProcessorTask . java : 791 )
at com . sun . grizzly . http . ProcessorTask . doProcess ( ProcessorTask . java : 693 )
at com . sun . grizzly . http . ProcessorTask . process ( ProcessorTask . java : 954 )
at com . sun . grizzly . http . DefaultProtocolFilter . execute ( DefaultProtocolFilter . java : 170 )
at com . sun . grizzly . DefaultProtocolChain . executeProtocolFilter ( DefaultProtocolChain . java : 135 )
at com . sun . grizzly . DefaultProtocolChain . execute ( DefaultProtocolChain . java : 102 )
at com . sun . grizzly . DefaultProtocolChain . execute ( DefaultProtocolChain . java : 88 )
at com . sun . grizzly . http . HttpProtocolChain . execute ( HttpProtocolChain . java : 76 )
at com . sun . grizzly . ProtocolChainContextTask . doCall ( ProtocolChainContextTask . java : 53 )
at com . sun . grizzly . SelectionKeyContextTask . call ( SelectionKeyContextTask . java : 57 )
at com . sun . grizzly . ContextTask . run ( ContextTask . java : 69 )
at com . sun . grizzly . util . AbstractThreadPool $ Worker . doWork ( AbstractThreadPool . java : 330 )
at com . sun . grizzly . util . AbstractThreadPool $ Worker . run ( AbstractThreadPool . java : 309 )
at java . lang . Thread . run ( Thread . java : 619 )
Caused by : org . hibernate . HibernateException : The chosen transaction strategy requires access to the JTA TransactionManager
at org . hibernate . impl . SessionFactoryImpl .< init >( SessionFactoryImpl . java : 399 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1385 )
at org . hibernate . cfg . AnnotationConfiguration . buildSessionFactory ( AnnotationConfiguration . java : 954 )
at org . hibernate . ejb . Ejb3Configuration . buildEntityManagerFactory ( Ejb3Configuration . java : 883 )
Eu não faço a mínima ídeia do que está acontecendo. Segue meu Persistence.xml
<?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= "nucleoPU" transaction-type= "JTA" >
<provider> org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source> jdbc/inno_nucleo</jta-data-source>
<properties>
<property name= "transaction.factory_class" value= "org.hibernate.transaction.JDBCTransactionFactory" />
<property name= "hibernate.dialect" value= "org.hibernate.dialect.MySQLDialect" />
<property name= "hibernate.connection.driver_class" value= "com.mysql.jdbc.Driver" />
<property name= "hibernate.connection.url" value= "jdbc:mysql://servidor:3306/nucleo_db" />
<property name= "hibernate.connection.username" value= "username" />
<property name= "hibernate.connection.password" value= "senha" />
</properties>
</persistence-unit>
</persistence>
Segue meu hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name= "transaction.factory_class" > org.hibernate.transaction.JDBCTransactionFactory</property>
<property name= "hibernate.dialect" > org.hibernate.dialect.MySQLDialect</property>
<property name= "hibernate.connection.driver_class" > com.mysql.jdbc.Driver</property>
<property name= "hibernate.connection.url" > jdbc:mysql://servidor:3306/nucleo_db</property>
<property name= "hibernate.connection.username" > username</property>
<property name= "hibernate.connection.password" > senha</property>
</session-factory>
</hibernate-configuration>
Desde já grato.