Jib created Microprofile image cannot resolve CDI classes
See original GitHub issueEnvironment Details
- Helidon Version:
1.0.0
- Helidon SE or Helidon MP:
MP
- JDK version:
openjdk:8-alpine
andgcr.io/distroless/java
- OS: ^
- Docker version (if applicable): Docker Desktop 2.0.0.2 using Jib 1.0.0 created image
Problem Description
No CDI classes are being introspected by Weld so no JAX-RS resources are available resulting in 404 Not Found. The beans.xml
files are being found:
Feb 18, 2019 3:24:09 PM org.jboss.weld.environment.deployment.discovery.DefaultBeanArchiveScanner getBeanArchiveReference
DEBUG: Resolved bean archive reference: /app/resources for URL: file:/app/resources/META-INF/beans.xml
But later down I get:
Feb 18, 2019 3:25:33 PM io.helidon.microprofile.server.Server$Builder resourcesFromContainer
WARNING: Failed to find JAX-RS resource to use
I’ve remotely debugged the image an no classes are being passed to io.helidon.microprofile.server.ServerCdiExtension#gatherApplications(...)
so not being initialised.
This is also confirmed by no message from Weld when processing the classes as it should say something like:
Feb 18, 2019 4:16:14 PM org.jboss.weld.bootstrap.events.ContainerLifecycleEvents fireProcessAnnotatedType
TRACE: Sending PAT using the fast event resolver: [BackedAnnotatedType] public @ApplicationPath @LoginConfig @ApplicationScoped class foo.MyApplication
My assumption is Helidon Microprofile really doesn’t like processing the /app/classes/*
when running via Docker.
This works locally using io.helidon.microprofile.server.Main
, the issue is reproducible every time.
Steps to reproduce
- Create simple Microprofile 1.2 project
- Add
javax.ws.rs.core.Application
implementation with@javax.ws.rs.ApplicationPath
and@javax.enterprise.context.ApplicationScoped
- Build Docker image using Jib 1.0.0 as per instructions,
- Run in docker and try and hit endpoints.
Unfortunately, I can’t provide an example project yet.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Jib created Microprofile image cannot resolve CDI classes #419
Workaround is to put beans.xml into /src/main/jib/app/classes/META-INF as it then placed it into the right place. Arguably this is ...
Read more >Building a Native Executable - Quarkus
Mandrel's main goal is to provide a way to build native executables specifically designed to support Quarkus. Mandrel releases are built from a...
Read more >Chapter 7. Contexts and Dependency Injection (CDI)
Unsatisfied dependencies exist when the container is unable to resolve an injection to any bean at all. The container takes the following steps...
Read more >Building Java container images using Jib - Snyk
In this article, we will look at Jib, a 100% Java-based tool for Java developers to build highly optimized images for their Java...
Read more >Jersey 2.37 User Guide - GitHub Pages
This is user guide for Jersey 2.37. We are trying to keep it up to date as we add new features. When reading...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Found the problem: Weld expects the
bean.xml
to be in the same classpath as the classes. Ordinarily in an IDE or via Maven/target/classes
this would be the case so no problem with Weld. Unfortunately, Jib creates separate directories for resources and classes and attaches them separately to the classpath:Workaround is to put
beans.xml
into/src/main/jib/app/classes/META-INF
as it then placed it into the right place.Arguably this is a problem with Jib: GoogleContainerTools/jib#1488
As mentioned above, this is caused by JIB’s handling of class path. See https://github.com/GoogleContainerTools/jib/issues/1488 for more details. Closing as there is nothing we can do in Helidon. Workaround as described in the JIB case: Place
beans.xml
file insrc/main/jib/app/classes/META-INF
.