DB Access problem

I don’t think this is really a Vaadin problem, but perhaps someone can help me anyway…

I have a set of Vaadin applications that all refer to a MySQL database, using EclipseLink. The applications all work fine.
Recently I added a new table to the database - it consists of an integer ID field and a couple of string fields - no different that several other tables I use. No foreign keys, nothing special.

The application that reads this table runs in a tomcat container. When the application starts, it opens the database and reads the contents of the table into a List object. I have tried making this the first table it reads, and I’ve switched the order so it reads one or two other tables first.

The code that reads the data looks like this - and is identical to the code that reads almost every table in the database…

public List<Foo> getAllFoo(){
em = getEntityManager();
Query q = em.createQuery("select f from Foo as f");
List<Foo> lf = q.getResultList();
em.close();
return(lf);
}

Couldn't be much simpler - and most of the time it works. But sometimes I get this error in the log file:

[code]
HTTP Status 500 - com.vaadin.server.ServiceException: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
type Exception report
message com.vaadin.server.ServiceException: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: com.vaadin.server.ServiceException: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [select f from Foo as f]
.
[16, 28]
 The abstract schema type 'Foo' is unknown.
        com.vaadin.server.VaadinServlet.service(VaadinServlet.java:239)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
com.vaadin.server.ServiceException: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [select f from Foo as f]
.
[16, 28]
 The abstract schema type 'Foo' is unknown.
        com.vaadin.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1459)
        com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1413)
        com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [select f from Foo as f]
.
[16, 28]
 The abstract schema type 'Foo' is unknown.
        org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1605)
        com.verisign.montools.netcool.rules.db.Ctl_Foo.getAllFoo(Ctl_Foo.java:27)
        com.verisign.montools.netcool.ncadmin.db.dbManager_NCAdmin.getFoo(dbManager_NCAdmin.java:23)
        com.verisign.montools.netcool.ncadmin.NCAdminUI.getFoo(NCAdminUI.java:7)
[/code]

It is failing to locate the table foo in the database. Restarting Tomcat - no code changes - causes it to work. No problems and it reads the table correctly. And it seems to happen occasionally, but not every time we restart the system. Once it works, it works continuously until the system is stopped and restarted.

So my question is - anyone see anything like this? Any idea what can cause it? The table exists, the data is there, the code works... usually. And I'd tear my hair out but there isn't enough left to make that a good idea :)

Any suggestions appreciated - thanks in advance,

nbc

select f from Foo as f

You are saying here there is a field named ‘f’.

You are also referring to the table ‘Foo’ as ‘f’.

Two things are referenced by ‘f’?? Not sure I would do that.

I think that is the standard JPA syntax for selecting an entire object from the table. When I use Eclipse to generate a class from a table, it creates a NamedQuery that looks like

@NamedQuery(name="Foo.findAll", query="SELECT f FROM Foo f")

When I create my own queries, I usually put in ‘select f from Foo AS f’ but I think that is the same thing…
I use that format in every one of my tables - this is the only one that fails (occasionally…)

nbc