0 Replies Latest reply on Sep 12, 2016 4:24 PM by antonior14

    REST EASY HIBERNATE TABLE NOT FOUND ERROR

    antonior14

      Hi! I'm trying to set rest endpoints within my jee7 project using Wildfly 8, Rest Easy and Arquillian.

       

      So running both a junit test and client request from SOAP UI I get this error:

       

      Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement

          at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]

          at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]

       

          ... 188 more

      Caused by: org.h2.jdbc.JdbcSQLException: Table "EMPLOYEES" not found; SQL statement:

      select employee0_.employeed_id as employee1_3_0_, employee0_.address as address2_3_0_, employee0_.birthday as birthday3_3_0_, employee0_.city as city4_3_0_, employee0_.country_id ...

          at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)

       

      This is my /src/main/resource/META-INF/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="my-persistence-unit">

              <class>model.Department</class>

              <class>model.Employee</class>

              <class>model.Job</class>

                ...

              <properties>

                  <property name="javax.persistence.jdbc.url"

                      value="jdbc:mysql://localhost:3306/datasource1?zeroDateTimeBehavior=convertToNull" />

                  <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />

                  <property name="javax.persistence.jdbc.user" value="root" />

                     ...

                  <property name="hibernate.hbm2ddl.auto" value="create-drop" />

                  <property name="hibernate.show_sql" value="true" />

                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

                  <property name="hibernate.format_sql" value="true" />

              </properties>

          </persistence-unit>

      </persistence>

       

       

      Rest Endpoint for employee:

       

      @Stateless

      @Path("/employees")

      public class EmployeeEndpoint

      {

        @Inject

        private EmployeeService employeeService;

       

        @GET

        @Path("/{id:[0-9][0-9]*}")

        @Produces({ "application/xml", "application/json" })

        public Response findById(@PathParam("id") Integer id)

        {

          Employee entity;

          try

          {

            entity = employeeService.findById(id);

          } catch (NoResultException nre)

          {

            entity = null;

          }

          if (entity == null)

          {

            return Response.status(Status.NOT_FOUND).build();

          }

          return Response.ok(entity).build();

        }

      }

       

      Junit test for Employee Service work fine...

       

      thanks in advance