ClassCastException when running on Glassfish 4.0
Description
Attachments
Activity

Chris Cranford May 31, 2018 at 11:47 PMEdited
I believe the problem here is the mysql driver needs to be installed as a server library rather than just providing it as an application dependency.
I ran into a similar problem with postgresql under GlassFish 5 and installing the jar inside domains/domain1/lib/ext
fixed the issue.
Can you check if doing the above solves your issue?
Steve Ebersole September 27, 2015 at 1:07 PM
That's a lot of installing of stuff to verify this. I'll get to it when I have some time

Juan Arjona September 24, 2015 at 6:59 PMEdited
Thanks for looking into this Steve.
Assuming you have JDK 8 installed, to run the test, install Glassfish 4.1 (from https://glassfish.java.net/), MySQL (from www.mysql.org) and install maven. Add to your path the bin folder of glassfish and the bin folder of Maven.
Set the variable GFHOME as the installation folder for glassfish.
Setup the database:
mysql -u root -p
(type the root password for your database installation)
sql> create database test;
sql> grant all privileges on test.* to 'test'@'%' identified by 'test';
sql> exit;
Unzip the Hibernate-GF-Test.zip file in a folder, cd to that folder and:
Here you will see the exceptions showing up when the Timer event is fired up (it is every minute).
I have little experience on creating automated tests. This test requires a Timer in the application server to fire up, a MySQL installation and a Glassfish installation I cannot think of a way to easily automate it, but again, I am not an expert on that.
Steve Ebersole September 24, 2015 at 5:38 PM
I really need some guidance on this one. I have no idea how the attached test is supposed to run. And a complicated test is not really what we'd like to see (ideally).

Juan Arjona September 16, 2015 at 6:40 PM
Steve, I have no experience with in-memory databases. Nevertheless I tried setting up the application using Derby in-memory (thanks google) and the bug doesn't show up: it happens with MySQL. I haven't tried other databases.
The datasource is defined in the glassfish-resources.xml file, you can remove the one on the EJB module.
I really have no idea on how to download, install, run, deploy and test the application in glassfish on an automated process, maybe someone can help on that.
I am not an expert on glassfish internals: my uninformed guess is that when a timer executes a different class loader is being used and for some reason the thread cannot access the driver class...? Perhaps there is a glassfish expert following this that could help?
Details
Assignee
UnassignedUnassignedReporter
Juan ArjonaJuan ArjonaLabels
Components
Affects versions
Priority
Major
Details
Details
Assignee
Reporter

See bug https://hibernate.atlassian.net/browse/HHH-9446. The problem was fixed with a workaround by setting hibernate.classloading.use_current_tccl_as_parent to false.
On 4.3.11.Final the workaround work but sporadically the logs shows the same exception/problem when a singleton bean executes a @Scheduled timer.
The stack trace: