DB Access problem [message #1438725] |
Mon, 06 October 2014 08:06  |
Eclipse User |
|
|
|
I have a set of Vaadin applications that all refer to a MySQL database, using EclipseLink 2.5.2. 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<foo> 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:
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)
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....
Any suggestions appreciated - thanks in advance,
nbc
|
|
|
|
|
|
|
|
Re: DB Access problem [message #1440559 is a reply to message #1440545] |
Wed, 08 October 2014 10:14   |
Eclipse User |
|
|
|
Once the table is read, adding a record, or modifying one doesn't seem to be a problem... I will try turning on the logging.
One other thing we noticed. I have an update script that is currently running every morning.
It creates a sql file with over 100k insert statements that populate this particular table. I run the following in a shell script:
mysql -u u1 <sqlfile.txt
reloadTomcat.sh
The sqlfile basically deletes the contents of the table, and then loads the current data set. (this is done daily for testing purposes, but that will not be necessary down the road...) After the dataset is loaded, Tomcat is restarted (and the programs are copied into the webapps directory etc.) Is it possible that the database is somehow locking this table and my application can't access it right away? If that were the case, it would be intermittent, depending on how long the table was unavailable. And it might be that if we simply sleep for a few seconds after the sql reload the problem might go away (?????). We are going to try that for a couple of days and see what happens. I'm not sure this is an issue, but I have not come up with anything else either... If this happens to work, I'll let you know...
Thanks for the suggestions so far...
nbc
|
|
|
|
Re: DB Access problem [message #1441453 is a reply to message #1441359] |
Thu, 09 October 2014 15:11  |
Eclipse User |
|
|
|
You are probably correct - if the first call to the class was to save a new record, I suspect that would fail (intermittently...)
The persistence.xml file contains this:
<persistence-unit name="XXXX" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.vrsn.rules.Alerts</class>
<class>com.vrsn.rules.Hostnames</class>
etc. etc.
The Hostnames class is the one that is affected. I understand what you are suggesting - but I still don't see how it can work intermittently - either the class is there or it isn't... How can it do both?
The persistence.xml file does have several different sections with different persistence units - for different databases that I access. But this is the only table that has ever given me a problem...
nbc
|
|
|
Powered by
FUDForum. Page generated in 0.04581 seconds