fdiaz2011 21 de jun. de 2013
Olha, se o problema é com o manager não tem nada haver com a query.
Não está passando para o new UsuarioQuery(this.manager) um manager null ??
b10machado 21 de jun. de 2013
isso cara tava null, ai vi que tinha q passar o nome do persistence e fiz assim mais da erro nao acha o arquivo
EntityManagerFactory emf = Persistence.createEntityManagerFactory("SGBanco");
manager = emf.createEntityManager();
o arquivo esta no caminho Projeto >>> src >>> META-INF >>> persistence.xml
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= "SGBanco" transaction-type= "RESOURCE_LOCAL" >
<provider> org.hibernate.ejb.HibernatePersistence</provider>
<exclude-unlisted-classes> false</exclude-unlisted-classes>
<properties>
<property name= "javax.persistence.jdbc.url" value= "jdbc:postgresql://localhost:5432/SG" />
<property name= "javax.persistence.jdbc.password" value= "admin" />
<property name= "javax.persistence.jdbc.driver" value= "org.postgresql.Driver" />
<property name= "javax.persistence.jdbc.user" value= "postgres" />
<property name= "hibernate.cache.provider_class" value= "org.hibernate.cache.NoCacheProvider" />
<property name= "hibernate.hbm2ddl.auto" value= "update" />
</properties>
</persistence-unit>
</persistence>
fdiaz2011 21 de jun. de 2013
Qual erro q ta dando ?
Posta ai.
b10machado 21 de jun. de 2013
Jun 21 , 2013 4 : 14 : 28 AM org . apache . catalina . core . StandardContext listenerStop
SEVERE : Exception sending context destroyed event to listener instance of class com . sun . faces . config . ConfigureListener
java . lang . NoClassDefFoundError : javax / faces / event / PreDestroyApplicationEvent
at com . sun . faces . config . ConfigureListener . contextDestroyed ( ConfigureListener . java : 332 )
at org . apache . catalina . core . StandardContext . listenerStop ( StandardContext . java : 4819 )
at org . apache . catalina . core . StandardContext . stopInternal ( StandardContext . java : 5466 )
at org . apache . catalina . util . LifecycleBase . stop ( LifecycleBase . java : 232 )
at org . apache . catalina . core . StandardContext . reload ( StandardContext . java : 3901 )
at org . apache . catalina . manager . ManagerServlet . reload ( ManagerServlet . java : 949 )
at org . apache . catalina . manager . ManagerServlet . doGet ( ManagerServlet . java : 360 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 621 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 722 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 305 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 393 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 243 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . filters . SetCharacterEncodingFilter . doFilter ( SetCharacterEncodingFilter . java : 108 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 243 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 225 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 169 )
at org . apache . catalina . authenticator . AuthenticatorBase . invoke ( AuthenticatorBase . java : 581 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 168 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 98 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 927 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 407 )
at org . apache . coyote . http11 . AbstractHttp11Processor . process ( AbstractHttp11Processor . java : 999 )
at org . apache . coyote . AbstractProtocol $ AbstractConnectionHandler . process ( AbstractProtocol . java : 565 )
at org . apache . tomcat . util . net . JIoEndpoint $ SocketProcessor . run ( JIoEndpoint . java : 309 )
at java . util . concurrent . ThreadPoolExecutor . runWorker ( ThreadPoolExecutor . java : 1110 )
at java . util . concurrent . ThreadPoolExecutor $ Worker . run ( ThreadPoolExecutor . java : 603 )
at java . lang . Thread . run ( Thread . java : 722 )
Caused by : java . lang . ClassNotFoundException : javax . faces . event . PreDestroyApplicationEvent
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1711 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1556 )
... 31 more
Jun 21 , 2013 1 : 37 : 02 PM org . apache . catalina . core . ApplicationContext log
INFO : Marking servlet Faces Servlet as unavailable
Jun 21 , 2013 1 : 37 : 02 PM org . apache . catalina . core . StandardContext loadOnStartup
SEVERE : Servlet / SGR threw load () exception
java . lang . ClassNotFoundException : javax . faces . webapp . FacesServlet
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1711 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1556 )
at org . apache . catalina . core . DefaultInstanceManager . loadClass ( DefaultInstanceManager . java : 525 )
at org . apache . catalina . core . DefaultInstanceManager . loadClassMaybePrivileged ( DefaultInstanceManager . java : 507 )
at org . apache . catalina . core . DefaultInstanceManager . newInstance ( DefaultInstanceManager . java : 124 )
at org . apache . catalina . core . StandardWrapper . loadServlet ( StandardWrapper . java : 1136 )
at org . apache . catalina . core . StandardWrapper . load ( StandardWrapper . java : 1080 )
at org . apache . catalina . core . StandardContext . loadOnStartup ( StandardContext . java : 5015 )
at org . apache . catalina . core . StandardContext . startInternal ( StandardContext . java : 5302 )
at org . apache . catalina . util . LifecycleBase . start ( LifecycleBase . java : 150 )
at org . apache . catalina . core . ContainerBase . addChildInternal ( ContainerBase . java : 895 )
at org . apache . catalina . core . ContainerBase . addChild ( ContainerBase . java : 871 )
at org . apache . catalina . core . StandardHost . addChild ( StandardHost . java : 615 )
at org . apache . catalina . startup . HostConfig . deployDescriptor ( HostConfig . java : 649 )
at org . apache . catalina . startup . HostConfig $ DeployDescriptor . run ( HostConfig . java : 1585 )
at java . util . concurrent . Executors $ RunnableAdapter . call ( Executors . java : 471 )
at java . util . concurrent . FutureTask $ Sync . innerRun ( FutureTask . java : 334 )
at java . util . concurrent . FutureTask . run ( FutureTask . java : 166 )
at java . util . concurrent . ThreadPoolExecutor . runWorker ( ThreadPoolExecutor . java : 1110 )
at java . util . concurrent . ThreadPoolExecutor $ Worker . run ( ThreadPoolExecutor . java : 603 )
at java . lang . Thread . run ( Thread . java : 722 )
fdiaz2011 21 de jun. de 2013
Cara, esse erro não tem mais a ver com o persistence.
Ele não ta achando a classe
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
Veja se adicionou todas as libs do JSF no projeto.
b10machado 21 de jun. de 2013
deu esse agora
Jun 21 , 2013 1 : 58 : 50 PM com . sun . faces . context . ExceptionHandlerImpl log
SEVERE : JSF1073 : javax . faces . event . AbortProcessingException obtido durante o processamento de INVOKE_APPLICATION 5 : UIComponent - ClientId = principal : j_idt22 , Message =/ login . xhtml @44 , 102 actionListener = "#{UsuarioBean.verificaUser()}" : javax . persistence . PersistenceException : [ PersistenceUnit : SGBanco ] Unable to build EntityManagerFactory
Jun 21 , 2013 1 : 58 : 50 PM com . sun . faces . context . ExceptionHandlerImpl log
SEVERE : / login . xhtml @44 , 102 actionListener = "#{UsuarioBean.verificaUser()}" : javax . persistence . PersistenceException : [ PersistenceUnit : SGBanco ] Unable to build EntityManagerFactory
javax . faces . event . AbortProcessingException : / login . xhtml @44 , 102 actionListener = "#{UsuarioBean.verificaUser()}" : javax . persistence . PersistenceException : [ PersistenceUnit : SGBanco ] Unable to build EntityManagerFactory
at javax . faces . event . MethodExpressionActionListener . processAction ( MethodExpressionActionListener . java : 182 )
at javax . faces . event . ActionEvent . processListener ( ActionEvent . java : 88 )
at javax . faces . component . UIComponentBase . broadcast ( UIComponentBase . java : 769 )
at javax . faces . component . UICommand . broadcast ( UICommand . java : 300 )
at javax . faces . component . UIViewRoot . broadcastEvents ( UIViewRoot . java : 794 )
at javax . faces . component . UIViewRoot . processApplication ( UIViewRoot . java : 1259 )
at com . sun . faces . lifecycle . InvokeApplicationPhase . execute ( InvokeApplicationPhase . java : 81 )
at com . sun . faces . lifecycle . Phase . doPhase ( Phase . java : 101 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 118 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 593 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 305 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 393 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 243 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 225 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 169 )
at org . apache . catalina . authenticator . AuthenticatorBase . invoke ( AuthenticatorBase . java : 472 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 168 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 98 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 927 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 407 )
at org . apache . coyote . http11 . AbstractHttp11Processor . process ( AbstractHttp11Processor . java : 999 )
at org . apache . coyote . AbstractProtocol$AbstractConnectionHandler . process ( AbstractProtocol . java : 565 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 309 )
at java . util . concurrent . ThreadPoolExecutor . runWorker ( ThreadPoolExecutor . java : 1110 )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( ThreadPoolExecutor . java : 603 )
at java . lang . Thread . run ( Thread . java : 722 )
Caused by : javax . persistence . PersistenceException : [ PersistenceUnit : SGBanco ] Unable to build EntityManagerFactory
at org . hibernate . ejb . Ejb3Configuration . buildEntityManagerFactory ( Ejb3Configuration . java : 677 )
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 bean . UsuarioBean . verificaUser ( UsuarioBean . java : 45 )
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 . apache . el . parser . AstValue . invoke ( AstValue . java : 264 )
at org . apache . el . MethodExpressionImpl . invoke ( MethodExpressionImpl . java : 278 )
at com . sun . faces . facelets . el . TagMethodExpression . invoke ( TagMethodExpression . java : 105 )
at javax . faces . event . MethodExpressionActionListener . processAction ( MethodExpressionActionListener . java : 148 )
... 28 more
Caused by : org . hibernate . HibernateException : Hibernate Dialect must be explicitly set
at org . hibernate . dialect . DialectFactory . determineDialect ( DialectFactory . java : 57 )
at org . hibernate . dialect . DialectFactory . buildDialect ( DialectFactory . java : 39 )
at org . hibernate . cfg . SettingsFactory . determineDialect ( SettingsFactory . java : 426 )
at org . hibernate . cfg . SettingsFactory . buildSettings ( SettingsFactory . java : 128 )
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 )
... 40 more
fdiaz2011 21 de jun. de 2013
Vc precisa ler o erro
Vc precisa dizer qual o dialeto q o hibernate irá usar.
Algo do tipo
Porém, o específico pro postgre.
b10machado 21 de jun. de 2013
ja pus o dialect mas o err continua
b10machado 21 de jun. de 2013
da o erro ao executar essa linha
EntityManagerFactory emf = Persistence.createEntityManagerFactory(“SGBanco”);
Rodrigo_Sasaki 21 de jun. de 2013
a propriedade não deveria ser somente hibernate.dialect ?
fdiaz2011 21 de jun. de 2013
Sim !
Copiei de um local aqui para passar como exemplo pra ele.
@b10machado
Teste como o Rodrigo disse
edit:
Até me confundi.
Na verdade eu passei da forma certa ele q alterou… hehe
b10machado 21 de jun. de 2013
rsrs alterei o problema continua to usando o hibernate 3.2.2
com jpa 2.0
fdiaz2011 21 de jun. de 2013
Tem certeza q é o mesmo problema ?
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
b10machado 21 de jun. de 2013
dão esses erros
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: SGBanco] Unable to build EntityManagerFactory
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
nessa ordem