Thank you both for your replies.
Yes, the sample code published at
https://github.com/oliviercailloux/sample-jetty reproduces the problem deterministically. I tried to simplify it as much as I could, but it seems very difficult to make it much simpler than it is: the problem seems to happen because of some combination of Jetty, CDI and Hibernate being present. In particular, if I manage my transaction manually (using userTransaction.begin() and userTransaction.commit()), while still using Hibernate’s EntityManager in the same way, the warning disappears. It seems like the transactional interceptors have something to do with the warning.
Yes, perhaps the problem happens when Hibernate tries to create the tables: the log (linked to in my original post) shows that the warning is produced before the statements “drop table if exists” etc. But it’s hard to be sure. In particular, creating the EMF manually before querying the Jetty server does not trigger the warning.
Here below is the stack trace when the breakpoint placed at TransactionImple.java#L856 is hit. If this may be useful, the debugger indicates that the value of the parameter xaRes is com.arjuna.ats.internal.jdbc.IsSameRMOverrideXAResource@17f520e4, and it contains a wrappedXAResource of type JdbcXAConnection, printing as xads0: conn0: url=jdbc:h2:mem: user=SA.
Olivier
Thread [qtp2028017635-21] (Suspended (breakpoint at line 856 in TransactionImple))
owns: StandardServiceRegistryImpl (id=116)
owns: ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy<T> (id=117)
TransactionImple.delistResource(XAResource, int) line: 856
ConnectionImple.close() line: 300
TransactionalConnectionProvider.closeConnection(Connection) line: 57
JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.releaseConnection(Connection) line: 185
JdbcEnvironmentInitiator.initiateService(Map, ServiceRegistryImplementor) line: 125
JdbcEnvironmentInitiator.initiateService(Map, ServiceRegistryImplementor) line: 35
StandardServiceRegistryImpl.initiateService(ServiceInitiator<R>) line: 101
StandardServiceRegistryImpl(AbstractServiceRegistryImpl).createService(ServiceBinding<R>) line: 263
StandardServiceRegistryImpl(AbstractServiceRegistryImpl).initializeService(ServiceBinding<R>) line: 237
StandardServiceRegistryImpl(AbstractServiceRegistryImpl).getService(Class<R>) line: 214
DefaultIdentifierGeneratorFactory.injectServices(ServiceRegistryImplementor) line: 152
StandardServiceRegistryImpl(AbstractServiceRegistryImpl).injectDependencies(ServiceBinding<R>) line: 286
StandardServiceRegistryImpl(AbstractServiceRegistryImpl).initializeService(ServiceBinding<R>) line: 243
StandardServiceRegistryImpl(AbstractServiceRegistryImpl).getService(Class<R>) line: 214
InFlightMetadataCollectorImpl.<init>(BootstrapContext, MetadataBuildingOptions) line: 176
MetadataBuildingProcess.complete(ManagedResources, BootstrapContext, MetadataBuildingOptions) line: 118
EntityManagerFactoryBuilderImpl.metadata() line: 1224
EntityManagerFactoryBuilderImpl.build() line: 1255
HibernatePersistenceProvider.createEntityManagerFactory(String, Map) line: 56
Persistence.createEntityManagerFactory(String, Map) line: 79
EntityManagerFactoryProducer.produceEntityManagerFactory() line: 29
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 566
VirtualMethodInjectionPoint<T,X>(StaticMethodInjectionPoint<T,X>).invoke(Object, Object[], Class<RuntimeException>) line: 95
VirtualMethodInjectionPoint<T,X>(StaticMethodInjectionPoint<T,X>).invoke(Object, Object, BeanManagerImpl, CreationalContext<?>, Class<RuntimeException>) line: 85
ProducerMethod$1(ProducerMethodProducer<X,T>).produce(Object, CreationalContext<T>) line: 103
ProducerMethod$1(AbstractMemberProducer<X,T>).produce(CreationalContext<T>) line: 161
ProducerMethod<X,T>(AbstractProducerBean<X,T,S>).create(CreationalContext<T>) line: 180
ApplicationContextImpl(AbstractContext).get(Contextual<T>, CreationalContext<T>) line: 96
ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy<T>(ContextualInstanceStrategy$DefaultContextualInstanceStrategy<T>).get(Bean<T>, BeanManagerImpl, CreationalContext<?>) line: 100
ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy<T>.get(Bean<T>, BeanManagerImpl, CreationalContext<?>) line: 140
ContextualInstance.get(Bean<T>, BeanManagerImpl, CreationalContext<?>) line: 50
ContextBeanInstance<T>.getInstance() line: 102
ProxyMethodHandler.invoke(Object, Method, Method, Object[]) line: 105
EntityManagerFactory$50543834$Proxy$_$$_WeldClientProxy.getCriteriaBuilder() line: not available
QueryHelper.selectAll(Class<T>) line: 16
QueryHelper$Proxy$_$$_WeldClientProxy.selectAll(Class) line: not available
ItemService$Proxy$_$$_WeldSubclass(ItemService).getAll() line: 26
ItemService$Proxy$_$$_WeldSubclass.getAll$$super() line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 566
TerminalAroundInvokeInvocationContext.proceedInternal() line: 51
TerminalAroundInvokeInvocationContext(AroundInvokeInvocationContext).proceed() line: 78
TransactionalInterceptorRequired(TransactionalInterceptorBase).invokeInOurTx(InvocationContext, TransactionManager, RunnableWithException) line: 180
TransactionalInterceptorRequired(TransactionalInterceptorBase).invokeInOurTx(InvocationContext, TransactionManager) line: 168
TransactionalInterceptorRequired.doIntercept(TransactionManager, Transaction, InvocationContext) line: 53
TransactionalInterceptorRequired(TransactionalInterceptorBase).intercept(InvocationContext) line: 86
TransactionalInterceptorRequired.intercept(InvocationContext) line: 47
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 566
SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(InvocationContext) line: 73
InterceptorMethodHandler.executeAroundInvoke(Object, Method, Method, Object[], InterceptorMethodHandler$CachedInterceptionChain, InterceptionDecorationContext$Stack) line: 84
InterceptorMethodHandler.executeInterception(Object, Method, Method, Object[], InterceptionType, InterceptionDecorationContext$Stack) line: 72
InterceptorMethodHandler.invoke(InterceptionDecorationContext$Stack, Object, Method, Method, Object[]) line: 56
CombinedInterceptorAndDecoratorStackMethodHandler.invoke(InterceptionDecorationContext$Stack, Object, Method, Method, Object[], boolean, boolean) line: 79
CombinedInterceptorAndDecoratorStackMethodHandler.invoke(InterceptionDecorationContext$Stack, Object, Method, Method, Object[]) line: 68
ItemService$Proxy$_$$_WeldSubclass.getAll() line: not available
ItemService$Proxy$_$$_WeldClientProxy.getAll() line: not available
ItemResource.getItems() line: 37
ItemResource$Proxy$_$$_WeldClientProxy.getItems() line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 566
ResourceMethodInvocationHandlerFactory.lambda$static$0(Object, Method, Object[]) line: 52
622450145.invoke(Object, Method, Object[]) line: not available
AbstractJavaResourceMethodDispatcher$1.run() line: 124
JavaResourceMethodDispatcherProvider$TypeOutInvoker(AbstractJavaResourceMethodDispatcher).invoke(ContainerRequest, Object, Object...) line: 167
JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(Object, ContainerRequest) line: 219
JavaResourceMethodDispatcherProvider$TypeOutInvoker(AbstractJavaResourceMethodDispatcher).dispatch(Object, ContainerRequest) line: 79
ResourceMethodInvoker.invoke(RequestProcessingContext, Object) line: 469
ResourceMethodInvoker.apply(RequestProcessingContext) line: 391
ResourceMethodInvoker.apply(Object) line: 80
ServerRuntime$1.run() line: 255
Errors$1.call() line: 248
Errors$1.call() line: 244
Errors.process(Callable<T>, boolean) line: 292
Errors.process(Producer<T>, boolean) line: 274
Errors.process(Runnable) line: 244
Hk2RequestScope(RequestScope).runInScope(RequestContext, Runnable) line: 265
ServerRuntime.process(ContainerRequest) line: 234
ApplicationHandler.handle(ContainerRequest) line: 680
WebComponent.serviceImpl(URI, URI, HttpServletRequest, HttpServletResponse) line: 394
WebComponent.service(URI, URI, HttpServletRequest, HttpServletResponse) line: 346
ServletContainer.service(URI, URI, HttpServletRequest, HttpServletResponse) line: 366
ServletContainer.service(HttpServletRequest, HttpServletResponse) line: 319
ServletContainer.service(ServletRequest, ServletResponse) line: 205
ServletHolder.handle(Request, ServletRequest, ServletResponse) line: 763
ServletHandler.doHandle(String, Request, HttpServletRequest, HttpServletResponse) line: 563
ServletContextHandler(ScopedHandler).nextHandle(String, Request, HttpServletRequest, HttpServletResponse) line: 233
ServletContextHandler(ContextHandler).doHandle(String, Request, HttpServletRequest, HttpServletResponse) line: 1434
ServletHandler(ScopedHandler).nextScope(String, Request, HttpServletRequest, HttpServletResponse) line: 188
ServletHandler.doScope(String, Request, HttpServletRequest, HttpServletResponse) line: 501
ServletContextHandler(ScopedHandler).nextScope(String, Request, HttpServletRequest, HttpServletResponse) line: 186
ServletContextHandler(ContextHandler).doScope(String, Request, HttpServletRequest, HttpServletResponse) line: 1349
ServletContextHandler(ScopedHandler).handle(String, Request, HttpServletRequest, HttpServletResponse) line: 141
HandlerList.handle(String, Request, HttpServletRequest, HttpServletResponse) line: 59
Server(HandlerWrapper).handle(String, Request, HttpServletRequest, HttpServletResponse) line: 127
Server.handle(HttpChannel) line: 516
HttpChannelOverHttp(HttpChannel).lambda$handle$1() line: 383
2113332774.dispatch() line: not available
HttpChannelOverHttp(HttpChannel).dispatch(DispatcherType, HttpChannel$Dispatchable) line: 556
HttpChannelOverHttp(HttpChannel).handle() line: 375
HttpConnection.onFillable() line: 273
AbstractConnection$ReadCallback.succeeded() line: 311
AbstractEndPoint$1(FillInterest).fillable() line: 105
ChannelEndPoint$1.run() line: 104
EatWhatYouKill.runTask(Runnable) line: 336
EatWhatYouKill.doProduce(boolean) line: 313
EatWhatYouKill.tryProduce(boolean) line: 171
EatWhatYouKill.run() line: 129
ReservedThreadExecutor$ReservedThread.run() line: 375
QueuedThreadPool.runJob(Runnable) line: 773
QueuedThreadPool$Runner.run() line: 905
Thread.run() line: 834