Home Table not found with H2
Reply: 0

Table not found with H2

user2089 Published in August 14, 2018, 8:27 am

My Java EE application cannot find tables. I am using WildFly (as the application server) and H2 (as the DB, in the embedded mode).

The error is:

org.h2.jdbc.JdbcSQLException: Table "MY_TABLE" not found

Look at my table creation:

create table "MY_TABLE" (
    -- ...

See how my entity is defined:

@Table(name = "MY_TABLE")
public class MyTable {
    // ...

This is how I call JPA (this causes the exception):

private EntityManager entityManager;

// ...

entityManager.find(MyTable.class, 1);

My persistence.xml is:

<persistence-unit name="myapp" transaction-type="JTA">

And the standalone.xml in my WildFly:

<datasource jndi-name="java:jboss/datasources/myappDS" pool-name="myappDS" enabled="true" use-java-context="true">
    <driver name="h2" module="com.h2database.h2">

Everything looks good so why the exception? Do I need to flush something? Or set schema somewhere?

If I configure another datasource (having the same DB structure) in WildFly (for example Postgres), everything works fine. That would mean that the datasource configuration is the place causing the error.

(Yes, I am totally sure the DB is not empty and the connection URL is correct as I have tried it from an SQL client.)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.288596 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO