Add JDBC driver to image build

In this topic JDBC Connection to DataHub I established a JDBC connection to dremio. For this I downloaded a jdbc driver. Now my microservice is ready to get deplyed.

When I do this I get error messages that say it could not load the JDBC driver
Could not load JDBC driver class [com.dremio.jdbc.Driver].
I guess at the build process the driver is not packed into the image.

To prove this I make a build without the dependency in pom.xml and its almost the same size of the result package. How to say the building process that the dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar should be baked into the image? There is no dockerfile or anything I can find where I can control how the image will be build.

You should add a proper dependency to your project:

You can try the steps above by adding the dremio repo and adding a proper dependency in your pom.xml.

Ok thanks.

I put now

<repository>
    <id>dremio-free</id>
    <url>https://maven.dremio.com/free/</url>
</repository>

...

<dependency>
    <groupId>com.dremio.distribution</groupId>
    <artifactId>dremio-jdbc-driver</artifactId>
    <version>25.0.0-202404051521110861-ed9515a8</version>
</dependency>

into my pom.xml and it seams now to package the jdbc driver to my package.

Now I’m back to the original error message from thread before. After uploading the microservice I got the error CONNECTION : SSL negotiation failed. To fix this locally I put --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED as run parameters. Can I put this parameters also for running inside the container?

In your pom.xml using the microservice-package-maven-plugin you can add a configuration:

<jvmArgs> --add-opens ....

or you can use your own dockerfile to build the microservice adding the properties you need. Here is an example:

1 Like

I edit my pom.xml:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${spring-boot-dependencies.version}</version>
    <configuration>
        <mainClass>com.....microservices.workpiece.WorkpieceApplicationKt</mainClass>
        <jvmArguments>
            --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED
        </jvmArguments>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I’m not sure if this is the right place for add the jvmArguments. When I upload the microservice I still get the CONNECTION : SSL negotiation failed-Message. So I guess I have to change it somewhere else in my pom file?

Looks fine but the configuration Property is wrong. Try <jvmArgs> instead of <jvmArguments>

Ok, now I changed it to . My IDE complains about jvmArgs
grafik

but build went through. But I still go the same errors. Here complete stacktrace:

java.sql.SQLException: Failure in connecting to Dremio: cdjd.com.dremio.exec.rpc.ConnectionFailedException: CONNECTION : SSL negotiation failed
	at com.dremio.jdbc.impl.DremioExceptionMapper.map(DremioExceptionMapper.java:73) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at com.dremio.jdbc.impl.DremioConnectionImpl.<init>(DremioConnectionImpl.java:102) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at com.dremio.jdbc.impl.DremioJdbc41Factory.newConnection(DremioJdbc41Factory.java:66) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at com.dremio.jdbc.impl.DremioFactory.newConnection(DremioFactory.java:61) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:138) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at com.dremio.jdbc.Driver.connect(Driver.java:76) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681) ~[java.sql:na]
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:190) ~[java.sql:na]
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:155) ~[spring-jdbc-5.3.30.jar!/:5.3.30]
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:146) ~[spring-jdbc-5.3.30.jar!/:5.3.30]
	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205) ~[spring-jdbc-5.3.30.jar!/:5.3.30]
	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:169) ~[spring-jdbc-5.3.30.jar!/:5.3.30]
	at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:272) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:223) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:295) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:252) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:223) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[hibernate-core-5.6.15.Final.jar!/:5.6.15.Final]
	at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.30.jar!/:5.3.30]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.30.jar!/:5.3.30]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.30.jar!/:5.3.30]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.30.jar!/:5.3.30]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.30.jar!/:5.3.30]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160) ~[spring-context-5.3.30.jar!/:5.3.30]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:911) ~[spring-context-5.3.30.jar!/:5.3.30]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.30.jar!/:5.3.30]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.17.jar!/:2.7.17]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.7.17.jar!/:2.7.17]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) ~[spring-boot-2.7.17.jar!/:2.7.17]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.17.jar!/:2.7.17]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) ~[spring-boot-2.7.17.jar!/:2.7.17]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) ~[spring-boot-2.7.17.jar!/:2.7.17]
	at com.fronius.microservices.workpiece.WorkpieceApplicationKt.main(WorkpieceApplication.kt:15) ~[classes!/:na]
	at com.fronius.microservices.workpiece.WorkpieceApplicationKt.main(WorkpieceApplication.kt) ~[classes!/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:569) ~[na:na]
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[workpiece.jar:na]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[workpiece.jar:na]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[workpiece.jar:na]
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[workpiece.jar:na]
Caused by: cdjd.com.dremio.exec.rpc.ConnectionFailedException: CONNECTION : SSL negotiation failed
	at cdjd.com.dremio.exec.rpc.ConnectionFailedException.mapException(ConnectionFailedException.java:29) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.com.dremio.exec.client.DremioClient$FutureHandler.connectionFailed(DremioClient.java:914) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.com.dremio.sabot.rpc.user.QueryResultHandler$ChannelClosedHandler.connectionFailed(QueryResultHandler.java:402) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.com.dremio.exec.rpc.BasicClient$ConnectionMultiListener$ConnectionEstablishmentListener.lambda$addNegotiator$0(BasicClient.java:383) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:557) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:492) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:636) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:629) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:118) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1985) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1955) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.handshake(SslHandler.java:2194) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.startHandshakeProcessing(SslHandler.java:2108) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.handlerAdded(SslHandler.java:2090) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:1130) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:609) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.DefaultChannelPipeline.addBefore(DefaultChannelPipeline.java:269) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.DefaultChannelPipeline.addBefore(DefaultChannelPipeline.java:237) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.com.dremio.exec.rpc.BasicClient$ConnectionMultiListener$ConnectionEstablishmentListener.addNegotiator(BasicClient.java:395) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.com.dremio.exec.rpc.BasicClient$ConnectionMultiListener$ConnectionEstablishmentListener.operationComplete(BasicClient.java:327) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.com.dremio.exec.rpc.BasicClient$ConnectionMultiListener$ConnectionEstablishmentListener.operationComplete(BasicClient.java:303) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:583) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:559) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:492) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:636) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:625) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:105) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:84) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:301) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:336) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at java.base/java.lang.Thread.run(Thread.java:840) ~[na:na]
Caused by: cdjd.com.dremio.exec.rpc.RpcException: CONNECTION : SSL negotiation failed
	at cdjd.com.dremio.exec.client.DremioClient$FutureHandler.connectionFailed(DremioClient.java:909) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	... 37 common frames omitted
Caused by: cdjd.com.dremio.exec.rpc.RpcException: SSL negotiation failed
	at cdjd.com.dremio.exec.rpc.BasicClient$ConnectionMultiListener$ConnectionEstablishmentListener.lambda$addNegotiator$0(BasicClient.java:385) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	... 35 common frames omitted
Caused by: java.lang.UnsupportedOperationException: Allocator doesn't support heap-based memory.
	at cdjd.org.apache.arrow.memory.ArrowByteBufAllocator.fail(ArrowByteBufAllocator.java:159) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.org.apache.arrow.memory.ArrowByteBufAllocator.heapBuffer(ArrowByteBufAllocator.java:130) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler$SslEngineType$3.allocateWrapBuffer(SslHandler.java:336) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.allocateOutNetBuf(SslHandler.java:2368) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.wrapNonAppData(SslHandler.java:973) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	at cdjd.io.netty.handler.ssl.SslHandler.handshake(SslHandler.java:2192) ~[dremio-jdbc-driver-25.0.0-202404051521110861-ed9515a8.jar!/:25.0.0-202404051521110861-ed9515a8]
	... 26 common frames omitted

Hm, I used it a long time ago. Maybe it’s not working anymore like that. Can you try the custom docker file?

For better understanding what exectly I have to do for this.

  1. I skip the package process
<configuration>
	<name>templates-basic</name>
	<image>templates-basic</image>
	<encoding>UTF-8</encoding>
	<skip>${c8y.docker.skip}</skip>
</configuration>
  1. I build with the same command lile before mvn clean install -U
  2. I build the image via docker file
  3. I export the image as tar
  4. I zip image with the cumulocity.json into a zip file

Or is there a way to configure the normal building process so that its use a custom docker file?

It’s much easier:

  1. Add a dockerfile in src/main/docker folder
  2. Just build the microservice using the maven plugin e.g. mvn clean package
  3. Deploy the zip in the target folder

The docker skip option is only there to avoid building the docker image all the time.

1 Like

Ok, I add this dockerfile into src/main/docker

FROM alpine:3 as base
RUN apk add  --no-cache openjdk@package.java-version@
RUN jlink \
--module-path /opt/java/jmods \
--compress=2 \
--add-modules java.se,jdk.unsupported,jdk.crypto.ec \
--no-header-files \
--no-man-pages \
--output /opt/jdk-mini
FROM alpine:3
COPY --from=base /opt/jdk-mini /opt/jdk-mini
RUN apk add  --no-cache coreutils
ENV JAVA_HOME=/opt/jdk-mini
ENV PATH="$PATH:$JAVA_HOME/bin"
COPY etc/ /etc/service-request-mgmt/
ADD resources/* /data/
ENTRYPOINT ["java", "--add-opens", "java.base/java.nio=ALL-UNNAMED", "--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED", "-jar", "/data/@package.name@.jar"]

I got still the same SSL-problem. Because I’m not sure if the process really use this dockerfile I add the entrypoint.sh file:

#!/bin/sh
echo "Starting the Java application with the following JAVA_OPTS: $JAVA_OPTS"
java $JAVA_OPTS -jar /data/@package.name@.jar

I changed the Dockerfile to this:

FROM alpine:3 as base
RUN apk add  --no-cache openjdk@package.java-version@
RUN jlink \
--module-path /opt/java/jmods \
--compress=2 \
--add-modules java.se,jdk.unsupported,jdk.crypto.ec \
--no-header-files \
--no-man-pages \
--output /opt/jdk-mini
FROM alpine:3
COPY --from=base /opt/jdk-mini /opt/jdk-mini
RUN apk add  --no-cache coreutils
ENV JAVA_HOME=/opt/jdk-mini
ENV PATH="$PATH:$JAVA_HOME/bin"
COPY etc/ /etc/service-request-mgmt/
ADD resources/* /data/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENV JAVA_OPTS="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED"
ENTRYPOINT ["/entrypoint.sh"]

The microservice starts with

Starting the Java application with the following JAVA_OPTS: --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.7.17)
...

Which means the dockerfile is used. But at the end of all this I still get the same SSL error like before. Is something wrong with the Dockerfile?

Hm did you check if the correct Java Version is fetched? Is it 17+? It might that these options you are setting are not working for the java version you are using. Also I’m not sure about the SSL access to datahub. Within a microservice normally internal communication is using non-ssl cumulocity:8111 but since you are using a different port I guess it should be fine using SSL.

Is this relevant? Issue with SSL connection from Docker - #5 by cantoress - Dremio

1 Like

So I change my Dockerfile to this

FROM openjdk:17-jdk-slim
COPY etc/ /etc/service-request-mgmt/
ADD resources/* /data/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENV JAVA_OPTS="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED"
ENTRYPOINT ["/entrypoint.sh"]

And it seams to run without any SSL errors. I have to make more tests with the service but from the first look I guess this resolve the problem. Thank you.

1 Like

Is there any documentation where I can find the information that I can place a Dockerfile into src/main/docker ?

Not to my knowledge but I will make sure it is addressed in our Best Practices article series in the Architecture & General Best Practices article.