question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jib created Microprofile image cannot resolve CDI classes

See original GitHub issue

Environment Details

  • Helidon Version: 1.0.0
  • Helidon SE or Helidon MP: MP
  • JDK version: openjdk:8-alpine and gcr.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

  1. Create simple Microprofile 1.2 project
  2. Add javax.ws.rs.core.Application implementation with @javax.ws.rs.ApplicationPath and @javax.enterprise.context.ApplicationScoped
  3. Build Docker image using Jib 1.0.0 as per instructions,
  4. Run in docker and try and hit endpoints.

Unfortunately, I can’t provide an example project yet.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dansivitercommented, Feb 18, 2019

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:

/app
  - /classes
    - /foo
      - MyWeldManagedBean.class
  - /resources
    - /META-INF
      - beans.xml   #  Weld can't find MyWeldManagedBean as this is separate

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

0reactions
tomas-langercommented, Apr 16, 2019

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 in src/main/jib/app/classes/META-INF.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found