Hibernate Schema not found

Recebo o erro de que schema não está sendo encontrado no ao rodar o projeto, segui a configuração do meu persistence.xml, já tentei alterar as configurações do meu persistence, mas continou recebendo a mesma mensagem :confused:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
	<persistence-unit name="SistemaRUMavenFinal" transaction-type="RESOURCE_LOCAL">
	<!-- <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> -->
	<provider>org.hibernate.ejb.HibernatePersistence</provider>
	<properties>
	<!-- DADOS CONEXAO -->
			<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
			<property name="hibernate.connection.username" value="root" />
			<property name="hibernate.connection.password" value="123456" />
			<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/sistema_ru" />
			<property name="hibernate.default_schema" value="sistema_ru"/>
			<!-- CONFIGURACAO -->
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
			<property name="hibernate.hbm2ddl.auto" value="create-drop" />
			<property name="hibernate.show_sql" value="true" />
			<property name="hibernate.format_sql" value="true" />
			<property name="hibernate.archive.autodetection" value="class" />	
	</properties>
	</persistence-unit>
</persistence>

Vou aproveitar e deixar as configurações do meu pom.xml para vocês verem as configurações do hibernate que estou usando.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>br.com</groupId>
	<artifactId>SistemaRUMavenFinal</artifactId>
	<version>0.0.1-SNAPSHOT</version>



	<dependencies>
		<!-- FJS -->
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.faces</artifactId>
			<version>2.1.17</version>
			<scope>compile</scope>
		</dependency>

		<!-- PrimeFaces -->
		<dependency>
			<groupId>org.primefaces</groupId>
			<artifactId>primefaces</artifactId>
			<version>6.0</version>
		</dependency>

		<!-- Núcleo Hibernate -->
		<!-- <dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>5.2.9.Final</version>
		</dependency> -->

		<!-- for JPA, use hibernate-entitymanager instead of hibernate-core -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-entitymanager</artifactId>
			<version>5.2.9.Final</version>
		</dependency>

		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.6</version>
		</dependency>


	</dependencies>

	<repositories>
		<repository>
			<id>prime-repo</id>
			<name>PrimeFaces Maven Repository</name>
			<url>http://repository.primefaces.org</url>
			<layout>default</layout>
		</repository>
	</repositories>
</project>

E aqui é minha classe de Teste

public class Teste {

	public static void main(String[] args) {
				
		
		Usuario user = new Usuario();
		
		user.setNome("super");

		EntityManagerFactory  facoty = Persistence.createEntityManagerFactory("sistema_ru");
		EntityManager manager = facoty.createEntityManager();
		EntityTransaction transaction = manager.getTransaction();
		
		try{
			
			transaction.begin();
			manager.persist(user);
			transaction.commit();	
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Fim");
	}

}

Algo está estranho, porque nem minha menagem de fim não aparece…

Atualizado: Agora estou chamando o meu persistence-unit em createEntityManagerFactory, mas continou recebendo a mesma mensagem, segui a mesnagem de erro completa.

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
21:30:27,719 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
21:30:27,960 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
21:30:28,059 INFO  [org.jboss.as] (MSC service thread 1-8) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
21:30:29,511 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found SistemaRUMavenFinal.war in deployment directory. To trigger deployment create a file called SistemaRUMavenFinal.war.dodeploy
21:30:29,543 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
21:30:29,575 INFO  [org.xnio] (MSC service thread 1-5) XNIO version 3.3.0.Final
21:30:29,600 INFO  [org.xnio.nio] (MSC service thread 1-5) XNIO NIO Implementation Version 3.3.0.Final
21:30:29,700 INFO  [org.jboss.remoting] (MSC service thread 1-5) JBoss Remoting version 4.0.6.Final
21:30:29,720 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
21:30:29,731 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
21:30:29,751 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
21:30:29,809 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
21:30:29,819 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-6) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
21:30:29,830 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) JBAS010417: Started Driver service with driver-name = h2
21:30:29,839 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
21:30:29,885 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
21:30:29,899 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
21:30:29,909 INFO  [org.jboss.as.security] (MSC service thread 1-7) JBAS013170: Current PicketBox version=4.0.21.Final
21:30:29,915 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
21:30:29,948 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
21:30:29,949 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
21:30:30,042 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017502: Undertow 1.1.0.Final starting
21:30:30,044 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting
21:30:30,290 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /home/afonso/Computacao/wildfly-8.2.0.Final/welcome-content
21:30:30,312 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017525: Started server default-server.
21:30:30,364 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017531: Host default-host starting
21:30:30,643 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080
21:30:30,915 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /home/afonso/Computacao/wildfly-8.2.0.Final/standalone/deployments
21:30:30,926 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "SistemaRUMavenFinal.war" (runtime-name: "SistemaRUMavenFinal.war")
21:30:31,066 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
21:30:31,463 INFO  [org.jboss.as.jpa] (MSC service thread 1-5) JBAS011401: Read persistence.xml for SistemaRUMavenFinal
21:30:31,675 INFO  [org.jboss.ws.common.management] (MSC service thread 1-4) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
21:30:31,943 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 1 of 2) Service 'SistemaRUMavenFinal.war#SistemaRUMavenFinal'
21:30:32,018 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 50) HHH000204: Processing PersistenceUnitInfo [
	name: SistemaRUMavenFinal
	...]
21:30:32,241 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 50) HHH000412: Hibernate Core {4.3.7.Final}
21:30:32,243 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000206: hibernate.properties not found
21:30:32,246 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000021: Bytecode provider name : javassist
21:30:32,846 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'SistemaRUMavenFinal.war#SistemaRUMavenFinal'
21:30:33,082 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 50) HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
21:30:33,524 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 50) HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
21:30:33,699 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 50) HHH000397: Using ASTQueryTranslatorFactory
21:30:33,784 INFO  [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 50) HV000001: Hibernate Validator 5.1.3.Final
21:30:34,507 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000227: Running hbm2ddl schema export
21:30:34,513 INFO  [stdout] (ServerService Thread Pool -- 50) Hibernate: 
21:30:34,513 INFO  [stdout] (ServerService Thread Pool -- 50)     drop table if exists sistema_ru.aluno
21:30:34,514 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: drop table if exists sistema_ru.aluno
21:30:34,514 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Schema "SISTEMA_RU" not found; SQL statement:

    drop table if exists sistema_ru.aluno [90079-173]
21:30:34,514 INFO  [stdout] (ServerService Thread Pool -- 50) Hibernate: 
21:30:34,515 INFO  [stdout] (ServerService Thread Pool -- 50)     drop table if exists sistema_ru.hibernate_sequence
21:30:34,515 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: drop table if exists sistema_ru.hibernate_sequence
21:30:34,515 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Schema "SISTEMA_RU" not found; SQL statement:

    drop table if exists sistema_ru.hibernate_sequence [90079-173]
21:30:34,516 INFO  [stdout] (ServerService Thread Pool -- 50) Hibernate: 
21:30:34,516 INFO  [stdout] (ServerService Thread Pool -- 50)     create table sistema_ru.aluno (
21:30:34,516 INFO  [stdout] (ServerService Thread Pool -- 50)         id bigint not null,
21:30:34,516 INFO  [stdout] (ServerService Thread Pool -- 50)         nome varchar(255),
21:30:34,516 INFO  [stdout] (ServerService Thread Pool -- 50)         primary key (id)
21:30:34,516 INFO  [stdout] (ServerService Thread Pool -- 50)     ) ENGINE=InnoDB
21:30:34,517 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: create table sistema_ru.aluno (id bigint not null, nome varchar(255), primary key (id)) ENGINE=InnoDB
21:30:34,517 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Schema "SISTEMA_RU" not found; SQL statement:

    create table sistema_ru.aluno (
        id bigint not null,
        nome varchar(255),
        primary key (id)
    ) ENGINE=InnoDB [90079-173]
21:30:34,518 INFO  [stdout] (ServerService Thread Pool -- 50) Hibernate: 
21:30:34,518 INFO  [stdout] (ServerService Thread Pool -- 50)     create table sistema_ru.hibernate_sequence (
21:30:34,518 INFO  [stdout] (ServerService Thread Pool -- 50)          next_val bigint 
21:30:34,518 INFO  [stdout] (ServerService Thread Pool -- 50)     )
21:30:34,519 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: create table sistema_ru.hibernate_sequence ( next_val bigint )
21:30:34,519 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Schema "SISTEMA_RU" not found; SQL statement:

    create table sistema_ru.hibernate_sequence (
         next_val bigint 
    ) [90079-173]
21:30:34,519 INFO  [stdout] (ServerService Thread Pool -- 50) Hibernate: 
21:30:34,519 INFO  [stdout] (ServerService Thread Pool -- 50)     insert into sistema_ru.hibernate_sequence values ( 1 )
21:30:34,520 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000389: Unsuccessful: insert into sistema_ru.hibernate_sequence values ( 1 )
21:30:34,520 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) Schema "SISTEMA_RU" not found; SQL statement:

    insert into sistema_ru.hibernate_sequence values ( 1 ) [90079-173]
21:30:34,521 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 50) HHH000230: Schema export complete
21:30:34,522 WARN  [org.hibernate.internal.SessionFactoryImpl] (ServerService Thread Pool -- 50) HHH000008: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()
21:30:34,897 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Initializing Mojarra 2.2.8-jbossorg-1 20140822-1131 for context '/SistemaRUMavenFinal'
21:30:35,731 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /SistemaRUMavenFinal
21:30:35,800 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "SistemaRUMavenFinal.war" (runtime-name : "SistemaRUMavenFinal.war")
21:30:35,896 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
21:30:35,896 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
21:30:35,897 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 8496ms - Started 255 of 310 services (92 services are lazy, passive or on-demand)

Coloca a mensagem completa de erro.

<persistence-unit name="SistemaRUMavenFinal" transaction-type="RESOURCE_LOCAL">

EntityManagerFactory facoty = Persistence.createEntityManagerFactory("sistema_ru");

Repare nessas duas linhas de código, o que você vê de diferente nelas?

Humm não tinha notado é que eu pensei que em persistence-unit seria o nome do meu projeto e em createEntityManagerFactory, seria o nome da minha base de dados, quando chegar em casa vou testar isso :slight_smile: .

DarkElf eu troquei aqui estava errado, mas agora continou recebendo a mesma mensagem… O que mais poderia está errado?

Como está o seu banco de dados, e qual mensagem está dando?

Tenho só banco criado, toda vez que ele tenta criar qualquer tabela recebo a mensagem de schema-not-found

21:30:34,515 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool – 50) HHH000389: Unsuccessful: drop table if exists sistema_ru.hibernate_sequence
21:30:34,515 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool – 50) Schema “SISTEMA_RU” not found; SQL statement:

Tem mesmo certeza que o nome do banco é esse?
Posta os códigos de configuração do hibernate e da criação do banco de dados.

Vc criou esse schema no banco?

E se for para usar somente um schema não precisa especificar nada para schema default. O hibernate sabe que tem que utilizar o schema padrão do banco.

Era isso mesmo DarkElf, vc ajudou muito cara só tirei o esquema padrão e a mensagem de erro mudou :smiley:

Vlw mesmo cara.