Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Can't find eclipselink bundle when running java app with docker
Can't find eclipselink bundle when running java app with docker [message #1859845] Fri, 30 June 2023 06:26 Go to next message
Henrik van Onna is currently offline Henrik van OnnaFriend
Messages: 2
Registered: June 2023
Junior Member
You can check out this repo to reproduce the error (I cannot post links that's why I have to describe where to find it): github: username:henrikvanonna, repository-name: demo-service

I have a Spring Boot 3.0.4 app, running it with `spring-boot:run` works fine, but when I build the docker image with `mvn clean spring-boot:build-image -Pnative -DskipTests` (that works) and then running the image with `docker run --rm demo-service:0.0.1-SNAPSHOT` it fails with this error:

2023-06-20T09:32:19.419Z INFO 1 --- [ main] d.d.prodis.service.registry.Application : Starting AOT-processed Application using Java 17.0.7 with PID 1 (/workspace/de.dsa.prodis.service.registry.Application started by cnb in /workspace)
2023-06-20T09:32:19.420Z INFO 1 --- [ main] d.d.prodis.service.registry.Application : The following 1 profile is active: "dev"
2023-06-20T09:32:19.465Z INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-06-20T09:32:19.468Z INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-06-20T09:32:19.468Z INFO 1 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.5]
2023-06-20T09:32:19.476Z INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-06-20T09:32:19.476Z INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 56 ms
2023-06-20T09:32:19.495Z WARN 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Can't find bundle for base name org.eclipse.persistence.exceptions.i18n.EntityManagerSetupExceptionResource, locale en_US
2023-06-20T09:32:19.495Z INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2023-06-20T09:32:19.497Z ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Can't find bundle for base name org.eclipse.persistence.exceptions.i18n.EntityManagerSetupExceptionResource, locale en_US
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1762) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1132) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:907) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[de.dsa.prodis.service.registry.Application:3.0.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[de.dsa.prodis.service.registry.Application:3.0.4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[de.dsa.prodis.service.registry.Application:3.0.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[de.dsa.prodis.service.registry.Application:3.0.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[de.dsa.prodis.service.registry.Application:3.0.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[de.dsa.prodis.service.registry.Application:3.0.4]
at de.dsa.prodis.service.registry.Application.main(Application.java:15) ~[de.dsa.prodis.service.registry.Application:na]
Caused by: java.util.MissingResourceException: Can't find bundle for base name org.eclipse.persistence.exceptions.i18n.EntityManagerSetupExceptionResource, locale en_US
at java.base@17.0.7/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2045) ~[de.dsa.prodis.service.registry.Application:na]
at java.base@17.0.7/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1683) ~[de.dsa.prodis.service.registry.Application:na]
at java.base@17.0.7/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1586) ~[de.dsa.prodis.service.registry.Application:na]
at java.base@17.0.7/java.util.ResourceBundle.getBundle(ResourceBundle.java:1280) ~[de.dsa.prodis.service.registry.Application:na]
at org.eclipse.persistence.exceptions.i18n.ExceptionMessageGenerator.buildMessage(ExceptionMessageGenerator.java:71) ~[na:na]
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:233) ~[na:na]
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:2150) ~[na:na]
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2126) ~[na:na]
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:347) ~[de.dsa.prodis.service.registry.Application:4.0.1]
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313) ~[de.dsa.prodis.service.registry.Application:4.0.1]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[de.dsa.prodis.service.registry.Application:na]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[de.dsa.prodis.service.registry.Application:na]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[de.dsa.prodis.service.registry.Application:na]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[de.dsa.prodis.service.registry.Application:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1808) ~[de.dsa.prodis.service.registry.Application:6.0.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758) ~[de.dsa.prodis.service.registry.Application:6.0.6]
... 16 common frames omitted

```

The file mentioned in the stacktrace ("org.eclipse.persistence.exceptions.i18n.EntityManagerSetupExceptionResource") exists in the eclipselink-4.0.1.jar which is a maven dependency, this is it's content:
```/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.exceptions.i18n;

import java.util.ListResourceBundle;

/**
* INTERNAL:
* English ResourceBundle for EntityManagerSetupException messages.
*
* @author Tom Ware
*/
public final class EntityManagerSetupExceptionResource extends ListResourceBundle {
static final Object[][] contents = {
{ "28001", "A ValidationException was thrown while trying to create session: [{0}]. " +
"The most likely causes of this issue are that your [{1}] file is not available on the classpath " +
"or it does not contain a session called: [{0}]." },
{ "28002", "EclipseLink is attempting to load a ServerSession named [{0}] from [{1}], and not getting a ServerSession." },
{ "28003", "EclipseLink has loaded Session [{0}] from [{1}] and it either does not have a server platform specified or specifies " +
"a server platform that does not use and external transaction controller. Specify an appropriate server platform if you plan to use JTA." },
{ "28004", "Error in setup of EntityManager factory: JavaSECMPInitializer.initializeFromMain returned false." },
{ "28005", "An Exception was thrown in setup of EntityManager factory." },
{ "28006", "ClassNotFound: [{0}] specified in [{1}] property." },
{ "28007", "Failed to instantiate ServerPlatform of type [{0}] specified in [{1}] property." },
{ "28008", "Class: {0} was not found while processing annotations." },
{ "28009", "Attempted to redeploy a session named {0} without closing it." },
{ "28010", "PersistenceUnitInfo {0} has transactionType JTA, but does not have a jtaDataSource defined." },
{ "28011", "The session, [{0}], built for a persistence unit was not available at the time it was deployed. This means that somehow the session was removed from the container in the middle of the deployment process." },
{ "28012", "Value [{0}] is of incorrect type for property [{2}], value type should be [{1}]." },
{ "28013", "Unable to deploy PersistenceUnit [{0}] in invalid state [{1}]." },
{ "28014", "Exception was thrown while processing property [{0}] with value [{1}]." },
{ "28015", "Failed to instantiate SessionLog of type [{0}] specified in [{1}] property." },
{ "28016", "The persistence unit with name [{0}] does not exist." },
{ "28017", "Unable to predeploy PersistenceUnit [{0}] in invalid state [{1}]." },
{ "28018", "Predeployment of PersistenceUnit [{0}] failed." },
{ "28019", "Deployment of PersistenceUnit [{0}] failed. Close all factories for this PersistenceUnit." },
{ "28020", "The session with name [{0}] loaded from [{1}] is [{2}], it however must be ServerSession." },
{ "28021", "PersistenceUnit [{0}] attempts to load a session from [{1}] without providing a session name. A session name should be provided by defining the eclipselink.session-name property." },
{ "28022", "Value [true] for the property [eclipselink.weaving] is incorrect when global instrumentation is null, value should either be null, false, or static." },
{ "28023", "The method invocation of the method [{0}] on the object [{1}], of class [{2}], triggered an exception." },
{ "28024", "Cannot reflectively access the method [{0}] for object [{1}], of class [{2}]." },
{ "28025", "The persistence unit with name [{0}] has returned a [null] temporary classLoader - weaving has been disabled for this session. You may use static weaving is an optional workaround." },
{ "28026", "org.eclipse.persistence.jpa.osgi.PersistenceProvider does not support container deployment (createContainerEntityManagerFactory). Use org.eclipse.persistence.jpa.PersistenceProvider instead." },
{ "28027", "An attempt has been made to use PersistenceUnit [{0}], but no bundle is available that defines that persistence unit." },
{ "28028", "Failed to instantiate class instance [{0}] for persistence unit property [{1}], ensure constructor is defined correctly." },
{ "28029", "PersistenceUnit [{0}] tries both to use sessions.xml (specifies eclipselink.sessions-xml property) and to be a composite (specifies eclipselink.composite-unit property with value true). These modes are incompatible." },
{ "28030", "PersistenceUnit [{0}] specifies eclipselink.composite-unit.member property with value true. That means it cannot be used standalone, but only as a composite member." },
{ "28031", "Missing the required property [{0}]." },
{ "28032", "Failed to create temporary classloader with doPrivileged." }
};

/**
* Default constructor.
*/
public EntityManagerSetupExceptionResource() {
// for reflection
}

/**
* Return the lookup table.
*/
@Override
protected Object[][] getContents() {
return contents;
}
}
```

my pom.xml:
```<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="<ALink>" xmlns:xsi="<ALink>" xsi:schemaLocation="<ALink>">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.4</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<groupId>demo.demo</groupId>
<artifactId>demo-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo-service</name>

<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<eclipselink.version>4.0.1</eclipselink.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-loader</artifactId>
</dependency>
<!-- Spring data JPA, default tomcat pool, exclude it -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>${eclipselink.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.2.14</version>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
<version>1.0.78</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

</plugins>

<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>cfg/**</exclude>
<exclude>logback-spring.xml</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>cfg/**</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>systemd/**</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>

</project>
```


Docker version 20.10.17, build 100c701

So what exactly am I missing here?
I saw other proposed solutions for similar questions e.g. adding a Bundle.properties to the classpath, but it doesn't seem like the correct solution, because 1. this file comes from eclipselink and it doesn't make sense to me to add such a file manually to the classpath and 2. I am not using the translations in my project, eclipselink is.
Re: Can't find eclipselink bundle when running java app with docker [message #1859854 is a reply to message #1859845] Fri, 30 June 2023 19:57 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 54
Registered: December 2021
Member
I saw your stack overflow post and was hoping someone could help there as this is a Spring class loader issue, not an EclipseLink one. The static ResourceBundle.getBundle("org.eclipse.persistence.exceptions.i18n.ExceptionResource", Locale.getDefault(), getLoader()); call, which should be using the class loader returned from ExceptionMessageGenerator.class.getClassLoader(), isn't able to find the ExceptionResource class: Spring is either misconfigured so that the file cannot be loaded with that loader, or the file really isn't there. You might try stepping through that line with a debugger (source is available on GitHub: https://github.com/eclipse-ee4j/eclipselink/blob/master/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/exceptions/i18n/ExceptionMessageGenerator.java )

Best Regards,
Chris
Re: Can't find eclipselink bundle when running java app with docker [message #1859874 is a reply to message #1859854] Mon, 03 July 2023 07:13 Go to previous message
Henrik van Onna is currently offline Henrik van OnnaFriend
Messages: 2
Registered: June 2023
Junior Member
I really appreciate your quick response. Thank you for pointing me in the right direction.

Best Regards,
Henrik
Previous Topic:EclipseLink migration 2.1.3 -> 2.7.12
Next Topic:refreshIdentityMapResult - refresh cache only when new version
Goto Forum:
  


Current Time: Fri Jul 19 04:48:45 GMT 2024

Powered by FUDForum. Page generated in 0.03344 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top