Ticket #594 (closed: fixed)
Update hibernate lib
| Reported by: | gregory | Owned by: | olle |
|---|---|---|---|
| Milestone: | Proteios SE 2.9 | Keywords: | |
| Cc: |
Description
Change History
comment:2 Changed 3 years ago by olle
Reference note:
- Hibernate main web page is https://www.hibernate.org/.
- Hibernate download overview web page is https://www.hibernate.org/6.html.
- As of 2009-07-27, latest release for Hibernate Core is version 3.3.2.GA, released 2009-06-24.
comment:3 Changed 3 years ago by olle
Note of required external libraries for Hibernate Core release 3.3.2.GA:
Hibernate Core release 3.3.2.GA requires a number of external jar files, listed below. Current status in Proteios SE 2.8.0 is added in parenthesis:
- antlr-2.7.6.jar (antlr-2.7.6rc1.jar)
- commons-collections-3.1.jar (commons-collections-2.1.1.jar)
- dom4j-1.6.1.jar (dom4j-1.6.1.jar - OK)
- javassist-3.9.0.GA.jar (Not included)
- jta-1.1.jar (jta.jar)
- slf4j-api-1.5.8.jar (Not included)
Except for library dom4j-1.6.1.jar, new versions of all other required jar files need to be added. It may therefore affect Ticket #570 (Remove redundant external libraries).
comment:4 Changed 3 years ago by olle
Traceability note:
- Ticket #570 (Remove redundant external libraries) may be affected by updated of required external libraries for new Hibernate version.
comment:5 Changed 3 years ago by olle
Hibernate version information.
- According to the META-INF/MANIFEST.MF file in the Hibernate JAR file hibernate3.jar in api/external/, current Hibernate version is 3.1.2.
comment:6 Changed 3 years ago by olle
Problem with change of return type of aggregation functions (sum, count, avg) in Hibernate 3.2:
- According to the Hibernate3 Migration Guide ( https://www.hibernate.org/250.html), in Hibernate 3.2 the return type of the aggregation functions (sum, count, avg) was changed, see http://opensource.atlassian.com/projects/hibernate/browse/HHH-1538. Specifically, the count function (as specified in the EJB3 specification) returns Long instead of Integer. This will affect static method <T> T loadData(Class<T> clazz, Query query) in class/file core/HibernateUtil.java in api/core/, since calls for count queries normally use return class Integer, which will lead to a ClassCastException, when a new Hibernate version is used.
The problem can be solved by updating method <T> T loadData(Class<T> clazz, Query query) in class HibernateUtil to convert Long values to Integer, if possible. An alternative is to update all problematic calls to this method by using the new return class. The latter approach was selected in Proteios SE sister project BASE ( http://base.thep.lu.se/), see BASE2 ticket #263, changeset [2474].
comment:7 Changed 3 years ago by olle
First test of updating Hibernate library to Hibernate 3.3.2.GA:
The test setup included updates in api/external/ of required libraries listed in comment 2009-07-27 11:46:21.
- antlr-2.7.6rc1.jar updated to antlr-2.7.6.jar.
- commons-collections-2.1.1.jar updated to commons-collections-3.1.jar.
- hibernate3.jar version 3.1.2 updated to hibernate3.jar version 3.3.2.GA.
- javassist-3.9.0.GA.jar added.
- jta.jar updated to jta-1.1.jar.
- slf4j-api-1.5.8.jar added.
Compilation error:
- Class/file core/AbstractSqlQuery.java in api/core/, package private method String bindLimits(String sql, List<String> parameterOrder), line 268:
sql = dialect.getLimitString(sql, hasOffset && supportsOffset);
Error message: "getLimitString(java.lang.String,boolean) has protected access in org.hibernate.dialect.Dialect". For reference, see e.g. https://www.hibernate.org/hib_docs/v3/api/org/hibernate/dialect/Dialect.html#getLimitString(java.lang.String, boolean).
Solution:
- The solution chosen in BASE2 ticket #440, changeset [2967] was also used here; the problematic call was changed to:
sql = dialect.getLimitString(sql, getFirstResult(), getMaxResults());
This works as method String getLimitString(String query, int offset, int limit) has public access in org.hibernate.dialect.Dialect.
Status: Code could now be compiled without errors.
Deployment error:
- When trying to load Proteios SE from Tomcat, the following error appeared: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder.
Information on the error from http://www.slf4j.org/codes.html#StaticLoggerBinder gave the following information:
"Failed to load class org.slf4j.impl.StaticLoggerBinder
This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.
You can download SLF4J bindings from the project download page."
Solution:
- The slf4j-1.5.8.tar.gz package was downloaded from http://www.slf4j.org/download.html, and JAR file slf4j-log4j12-1.5.8.jar was added to api/external/.
Status: The error in question did no longer appear.
Deployment error:
- When trying to load Proteios SE from Tomcat, the following error appeared:
could not instantiate RegionFactory
[org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge]
...
Caused by: java.lang.NoClassDefFoundError: net/sf/ehcache/Ehcache.
The error is a little surprising, since a JAR file ehcache-1.1.jar exists in api/external/. However, the Hibernate 3.3.2.GA distribution contains an optional library file lib/optional/ehcache/ehcache-1.2.3.jar.
Solution:
- JAR file ehcache-1.1.jar in api/external/ was exchanged for the package ehcache-1.2.3.jar supplied with the Hibernate 3.3.2.GA distribution.
Status: Proteios SE could now be loaded from Tomcat, displaying the login page in the web browser.
Run-time error:
- Directly after login a ClassCastException error appeared for class/file core/HibernateUtil.java in api/core/, static method <T> T loadData(Class<T> clazz, Query query), line 860:
...
List items = query.list();
Object data = null;
if (items.size() != 0)
data = items.get(0);
return clazz.cast(data);
This is the problem with change of return type of aggregation functions (sum, count, avg) in Hibernate 3.2 described in comment added 2009-07-28 09:35:54 (in the current case with the count function returning a Long instead of an Integer value).
Solution:
- For test purposes as few changes as possible are desired, so a simple fix was implemented in method <T> T loadData(Class<T> clazz, Query query) in class HibernateUtil to convert Long values to Integer, when the latter return type should be used. This change may be reverted, if it is decided to update all problematic calls to this method by using a new return class.
Status: It was now possible to log in to Proteios SE, select an active project, list project files, display the Hits table, and display spectra. More testing during normal use is required to decide whether additional changes are necessary to ensure full functionality with the new Hibernate version.
comment:8 Changed 3 years ago by olle
(In [3383]) Refs #594. Refs #570. Hibernate library file updated from version 3.1.2 to 3.3.2.GA, in order for the latter to be tested during normal use. Also included are other changes related to the Hibernate update. Note that the involved updates might be reverted, if serious problems are found.
- External library files in api/external/ updated:
- Library file antlr-2.7.6rc1.jar updated to antlr-2.7.6.jar.
- Library file commons-collections-2.1.1.jar updated to
commons-collections-3.1.jar.
- Library file ehcache-1.1.jar updated to ehcache-1.2.3.jar.
- Library file hibernate3.jar updated from version 3.1.2 to 3.3.2.GA.
- Library file javassist-3.9.0.GA.jar added.
- Library file jta.jar updated to jta-1.1.jar.
- Library file slf4j-api-1.5.8.jar added.
- Library file slf4j-log4j12-1.5.8.jar added.
- Class/file core/AbstractSqlQuery.java in api/core updated in
package private method String bindLimits(String sql, List<String> parameterOrder) by exchanging call to (now) protected method String getLimitString(java.lang.String,boolean) in class org.hibernate.dialect.Dialect for call to public method String getLimitString(String query, int offset, int limit) in the same class.
- Class/file core/HibernateUtil.java in api/core/ updated in
static method <T> T loadData(Class<T> clazz, Query query) by converting Long values to Integer, when the latter return type should be used.
comment:9 Changed 3 years ago by olle
Problem when changing active directory:
- Project A is selected as active project in menu "File -> Select project", after which project B is selected as active project using the same menu item. The following error results:
BaseException: could not execute query
...
Caused by: java.sql.SQLException: Statement parameter 4 not set.
Reversing the order of the projects (selecting project B as active project first), results in a similar error, but with a different SQL error:
BaseException: could not execute query
...
Caused by: java.sql.SQLException: Parameter index out of bounds. 4 is not between valid values of 1 and 3
Variations of the setup by using other projects or performing some other operation for the first active project before selecting the new active project, sometimes resulted in the problem appearing, and sometimes not. When the problem appeared, the most frequent SQL error was the second one, "Parameter index out of bounds. 4 is not between valid values of 1 and 3". In all cases, the error appears in class ViewHome, public method void runMe(), line 148, when performing a query to obtain the number of removed directory items for the trash can pane.
The problem seems connected with caching of a used query. The same error did occur for the BASE project, when trying to update to Hibernate version 3.3.2.GA. Tests performed in the BASE project indicate that the problem did not arise in Hibernate version 3.3.1. A Hibernate ticket has been written regarding the problem (Hibernate ticket HHH-4065).
comment:10 Changed 3 years ago by olle
Traceability note regarding problem described in comment added 2009-07-30 14:29:42:
- A problem that with high probability has the same cause as the caching problem described in comment added 2009-07-30 14:29:42 is discussed in BASE2 ticket #1350 (Update to Hibernate 3.3.2), see comment added 2009-07-30 13:48:28. A hack in the BASE2 version of class HibernateUtil in order to fix the problem is described in BASE2 changeset [5037].
comment:11 Changed 3 years ago by olle
Traceability note:
- Ticket #388 (Ftp server is unstable) introduced Proteios FTP server control script templates proteios_ftp_server.sh.in and proteios_ftp_server.bat.in in client/ftpd/, that contain explicit class paths and therefore might be affected by changes of external libraries.
- Ticket #451 (Proteios FTP Server double-clickable start and stop scripts for MS-Windows) introduced Proteios FTP Server template bat-files proteios_ftp_server_start.bat.in and proteios_ftp_server_stop.bat.in in client/ftpd/, that contain explicit class paths and therefore might be affected by changes of external libraries.
comment:12 Changed 3 years ago by olle
(In [3387]) Refs #594. Refs #388. Refs #451. Proteios SE FTP server scripts template files updated in class path by library changes related to update of Hibernate from version 3.1.2 to 3.3.2.GA:
- Proteios SE FTP server scripts template files
proteios_ftp_server.sh.in, proteios_ftp_server.bat.in, proteios_ftp_server_start.bat.in, proteios_ftp_server_stop.bat.in, in client/ftpd/ updated in class path by the following changes:
- Library file commons-collections-2.1.1.jar updated to
commons-collections-3.1.jar.
- Library file ehcache-1.1.jar updated to ehcache-1.2.3.jar.
- Library file jta.jar updated to jta-1.1.jar.
- Library file antlr-2.7.6rc1.jar updated to antlr-2.7.6.jar.
- Library file slf4j-api-1.5.8.jar added.
- Library file slf4j-log4j12-1.5.8.jar added.
- Library file javassist-3.9.0.GA.jar added.
comment:13 Changed 2 years ago by gregory
comment:14 Changed 2 years ago by olle
- severity changed from 1 to 4
Severity set to 4, since several issues related to changed API for the new Hibernate lib, bugs in the latter, and required updates of other external libraries made the update non-trivial.
comment:15 Changed 2 years ago by olle
- Status changed from assigned to closed
- Resolution set to fixed
Ticket closed as Hibernate has been updated to the latest released version, 3.3.2.GA. However, the update might be reverted, if known bugs in the latest version or other issues related to the update are found to lead to serious problems.

Ticket accepted.