Pessoal
—Na tela aparece o seguinte erro :
javax.servlet.ServletException: org.hibernate.exception.JDBCConnectionException: Could not open connection
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361)
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289)
org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:261)
br.com.cliente.daos.ProdutoDAO.listatpproduto(ProdutoDAO.java:23)
br.com.cliente.controllers.ProdutoBean.getTpprodutos(ProdutoBean.java:34)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
–estou executando a pagina e esta dando o erro no log do JBOSS :
13:46:32,728 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-2) HHH000299: Could not complete schema update: java.lang.UnsupportedOperationException: The application must supply JDBC connections
at org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:62) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:194) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:457) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_24]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_24]
13:46:32,748 INFO [org.apache.catalina.core.StandardContext] (MSC service thread 1-7) The listener “com.sun.faces.config.ConfigureListener” is already configured for this context. The duplicate definition has been ignored.
13:46:32,748 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-7) Inicializando Mojarra 2.1.7-jbossorg-1 (20120227-1401) para o contexto ‘/Project’
13:46:33,049 INFO [org.primefaces.webapp.PostConstructApplicationEventListener] (MSC service thread 1-7) Running on PrimeFaces 3.3.1
13:46:33,049 INFO [org.jboss.web] (MSC service thread 1-7) JBAS018210: Registering web context: /Project
13:46:33,139 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018565: Replaced deployment “Project.war” with deployment “Project.war”
13:47:23,236 INFO [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011403: Stopping Persistence Unit Service ‘Project.war#Project’
13:47:23,267 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment Project.war in 42ms
13:47:23,267 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of “Project.war”
13:47:23,831 WARN [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015893: Encountered invalid class name ‘com.sun.faces.vendor.Tomcat6InjectionProvider:org.apache.catalina.util.DefaultAnnotationProcessor’ for service type ‘com.sun.faces.spi.injectionprovider’
13:47:23,831 WARN [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015893: Encountered invalid class name ‘com.sun.faces.vendor.Jetty6InjectionProvider:org.mortbay.jetty.plus.annotation.InjectionCollection’ for service type ‘com.sun.faces.spi.injectionprovider’
13:47:23,841 INFO [org.jboss.as.jpa] (MSC service thread 1-8) JBAS011401: Read persistence.xml for Project
13:47:23,981 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
13:47:23,981 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.0)
13:47:23,991 INFO [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011402: Starting Persistence Unit Service ‘Project.war#Project’
13:47:23,991 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-2) HHH000204: Processing PersistenceUnitInfo [
name: Project
…]
13:47:23,991 WARN [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-2) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
13:47:24,001 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-2) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
13:47:24,001 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-2) HHH000422: Disabling contextual LOB creation as connection was null
13:47:24,001 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-2) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
13:47:24,001 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-2) HHH000397: Using ASTQueryTranslatorFactory
13:47:24,011 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-2) HHH000228: Running hbm2ddl schema update
13:47:24,011 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-2) HHH000102: Fetching database metadata
13:47:24,011 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-2) HHH000299: Could not complete schema update: java.lang.UnsupportedOperationException: The application must supply JDBC connections
at org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:62) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:194) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:457) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_24]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_24]
Minha pagina :
<h:selectOneMenu id="tipodoproduto" value="#{produtoBean.selecttpproduto}"
requiredMessage="Valor é obrigatório">
<f:selectItem itemValue="" itemLabel="Selecione uma empresa"/>
<f:selectItems value="#{produtoBean.tpprodutos}" var="o" itemLabel="#{o.descricao}" itemValue="#{o}"/>
</h:selectOneMenu>
*********************************************************
Bean
@ManagedBean
@SessionScoped
public class ProdutoBean implements Serializable {
private Tpproduto selecttpproduto;
private List<Tpproduto> tpprodutos = new ArrayList<Tpproduto>();
private Produto produto = new Produto();
public Tpproduto getSelecttpproduto() {
return selecttpproduto;
}
public void setSelecttpproduto(Tpproduto selecttpproduto) {
this.selecttpproduto = selecttpproduto;
}
public List<Tpproduto> getTpprodutos() {
ProdutoDAO produtodao = new ProdutoDAO();
List<Tpproduto> resultado = produtodao.listatpproduto();
// return tpempresas;
return resultado;
}
public void setTpprodutos(List<Tpproduto> tpprodutos) {
this.tpprodutos = tpprodutos;
}
public Produto getProduto() {
return produto;
}
public void setProduto(Produto produto) {
this.produto = produto;
}
}
***********************************
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="Project">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>br.com.cliente.models.Tpproduto</class>
<class>br.com.cliente.models.Produto</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/postgres" />
<property name="javax.persistence.jdbc.user" value="xxxxx" />
<property name="javax.persistence.jdbc.password" value="xxxxx" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.shutdown" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>