We're updating the issue view to help you get more done. 

AuditReader find method throws an error

Description

Dear Hibernate team,

I've encountered a problem with my application when upgrading Hibernate from version 4 to 5.
Its origin seem to be an enum: when debugging, I get an error "BillStatus is not an enum type", which of course is wrong since it exists and has always worked so far.

Because of how massive the application is, I can't find a way to directly build a test case easily, so I'll do my best to provide as much information as possible about the issue.

The enum causing the error is the following:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 @JsonSerialize(using = BillStatus.BillStatusJsonSerializer.class, as = String.class) public enum BillStatus implements EnumResumable { TO_VALIDATE(0), VALIDATED(1), DELETED(2); protected int value; private BillStatus(int value) { this.value = value; } public int getValue() { return this.value; } public String getStringValue() { return "" + this.value; } @Override public String getResume() { return this.toString(); } }

My Bill item is the following:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 @JsonFilter("Bill_Filter") @Audited @Entity @Table(name = "`BILL`", schema = "ecc") @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE) public class Bill extends GenericBusinessObject implements Resumable, Loggable { @SequenceGenerator(name = "BILL_ID_GEN", sequenceName = "BILL_ID_SEQ", allocationSize = 1) @Id @Column(name = "\"ID\"", nullable = false) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BILL_ID_GEN") private int id; @NotNull(message = "status cannot be null") @Enumerated(EnumType.STRING) @Column(name = "\"STATUS\"") private BillStatus billStatus; // ... and getters come later }

And lastly, in another file, the line causing the error:

1 Bill bill = reader.find(Bill.class, id, lastRevision);

id and lastRevision are non null integers. The stack trace is the following:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 [1 claris-webapp] - [2019-06-28 10:27:00,743] ERROR com.ecc.gui.bean.page.BI01XBean.searchBillList(BI01XBean.java:518) - javax.ejb.EJBException at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748) at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698) at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2074) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2044) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88) at com.sun.proxy.$Proxy474.searchBillAtDate(Unknown Source) at com.ecc.bll.bill.__EJB31_Generated__BillEJB__Intf____Bean__.searchBillAtDate(Unknown Source) at com.ecc.gui.bean.page.BI01XBean.searchBillList(BI01XBean.java:491) at com.ecc.gui.bean.page.BI01XBean.gridDispatcher(BI01XBean.java:378) at sun.reflect.GeneratedMethodAccessor258.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:412) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalStateException: This web container has not yet been started at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1674) at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633) at sun.misc.Unsafe.defineClass(Native Method) at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63) at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399) at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:394) at java.security.AccessController.doPrivileged(Native Method) at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:393) at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:53) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at java.lang.Class.getEnumConstantsShared(Class.java:3320) at java.lang.Class.enumConstantDirectory(Class.java:3341) at java.lang.Enum.valueOf(Enum.java:232)

The issue seemed to be somewhat similar to another one:
https://hibernate.atlassian.net/browse/HHH-12396
But I haven't found any clue to solve my problem.

When reverting back from Hibernate 5.4.3.Final to Hibernate 4.3.5.Final, the problem disapears.

Environment

Java 8 update 161, Glassfish 4, Hibernate 5.4.3.Final, PostgreSQL 10

Status

Assignee

Unassigned

Reporter

Yozamu

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.3.12

Components

Affects versions

5.4.3

Priority

Major