Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception during lifecycle processing org.glassfish.deployment.common.DeploymentException: CDI deployment failure:Unable to cast config source to type class io.smallrye.config.SmallRyeConfig -- Unable to cast config source to type class io.smallrye.config.SmallRyeConfigBug Report: #6548

Closed
urbandroid opened this issue Jan 31, 2024 · 5 comments
Assignees
Labels
Type: Bug Label issue as a bug defect

Comments

@urbandroid
Copy link

Brief Summary

Same setup: https://github.com/urbandroid/graphql-jakarta/tree/debug
works for Wildfly and OpenLiberty but fails for Payara i think it is a bug from payara side.
Using

payara/server-full docker image.

Error at deployment:

Expected Outcome

Deployment should complete without an error and
curl -X POST -H "Content-Type: application/json" -d '{"query": "query { hello }"}' http://localhost:8080/deneme2-web/graphql/test
should return "hello"

Current Outcome

Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:Unable to cast config source to type class io.smallrye.config.SmallRyeConfig -- Unable to cast config source to type class io.smallrye.config.SmallRyeConfig
at org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:38)
at org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:501)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:94)
at org.glassfish.weld.WeldDeployer.processApplicationLoaded(WeldDeployer.java:582)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:437)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:344)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:580)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:570)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:552)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:551)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:582)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:574)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/javax.security.auth.Subject.doAs(Subject.java:453)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:573)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1497)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1879)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1755)
at com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.executeCommand(CommandExecutorImpl.java:183)
at com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.run(CommandExecutorImpl.java:96)
at fish.payara.boot.runtime.BootCommand.execute(BootCommand.java:69)
at fish.payara.boot.runtime.BootCommands.executeCommands(BootCommands.java:166)
at fish.payara.boot.runtime.BootCommands.executeCommands(BootCommands.java:160)
at com.sun.enterprise.v3.bootstrap.BootCommandService.doBootCommands(BootCommandService.java:81)
at com.sun.enterprise.v3.bootstrap.BootCommandService.postConstruct(BootCommandService.java:91)
at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:303)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:351)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:466)
at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:281)
at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:65)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2103)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:67)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1213)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1144)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpOneLevel.run(CurrentTaskFuture.java:762)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
|#]

[#|2024-01-31T10:05:42.433+0000|SEVERE|Payara 6.2024.1-SNAPSHOT|javax.enterprise.system.core|_ThreadID=33;_ThreadName=RunLevelControllerThread-1706695519788;_TimeMillis=1706695542433;_LevelValue=1000;|
Exception while loading the app|#]

[#|2024-01-31T10:05:42.445+0000|SEVERE|Payara 6.2024.1-SNAPSHOT|jakarta.enterprise.web|_ThreadID=33;_ThreadName=RunLevelControllerThread-1706695519788;_TimeMillis=1706695542445;_LevelValue=1000;_MessageID=AS-WEB-GLUE-00192;|
Undeployment failed for context /deneme2-web|#]

[#|2024-01-31T10:05:42.474+0000|SEVERE|Payara 6.2024.1-SNAPSHOT|javax.enterprise.system.core|_ThreadID=33;_ThreadName=RunLevelControllerThread-1706695519788;_TimeMillis=1706695542474;_LevelValue=1000;|
Exception while loading the app : CDI deployment failure:Unable to cast config source to type class io.smallrye.config.SmallRyeConfig -- Unable to cast config source to type class io.smallrye.config.SmallRyeConfig|#]

[#|2024-01-31T10:05:42.496+0000|WARNING|Payara 6.2024.1-SNAPSHOT|fish.payara.boot.runtime.BootCommand|_ThreadID=33;_ThreadName=RunLevelControllerThread-1706695519788;_TimeMillis=1706695542496;_LevelValue=900;|
Boot Command deploy failed PlainTextActionReporterFAILUREDescription: deploy AdminCommandError occurred during deployment: Exception while loading the app : CDI deployment failure:Unable to cast config source to type class io.smallrye.config.SmallRyeConfig -- Unable to cast config source to type class io.smallrye.config.SmallRyeConfig. Please see server.log for more details.
[name=deneme2-ear
|#]

Reproducer

https://github.com/urbandroid/graphql-jakarta/tree/debug

  1. mvn clean install
  2. docker build -f payara/Dockerfile
  3. docker run

Operating System

ubuntu 20.04

JDK Version

openjdk version "21.0.1" 2023-10-17 LTS

Payara Distribution

Payara Server Full Profile

@urbandroid urbandroid added Status: Open Issue has been triaged by the front-line engineers and is being worked on verification Type: Bug Label issue as a bug defect labels Jan 31, 2024
@poikilotherm
Copy link
Contributor

Hey @urbandroid it looks like you are trying to use a specific MicroProfile Config implementation (SmallRye), which is used in Wildfly and OpenLiberty. However, Payara provides its own implementation of the standard. You should probably try to stick to the MicroProfile Config API and not to an implementation.

If you followed https://smallrye.io/smallrye-config/Main to add MPC to your app, please instead follow https://github.com/eclipse/microprofile-config/releases/tag/3.1 and try again.

Disclaimer: I'm not associated with Payara, just a fellow MicroProfile Config API user.

@urbandroid
Copy link
Author

@poikilotherm Thanks Oliver but i'm trying to not depend on server dependency so that it will be portable across servers.

@fturizo fturizo assigned fturizo and unassigned shub8968 Mar 5, 2024
@fturizo
Copy link
Contributor

fturizo commented Mar 6, 2024

Greetings @urbandroid,

After reviewing this issue and the reproducer you shared in detail, I'm afraid that @poikilotherm is correct. The problem is caused by the JAR for Small Rye config is included by default in the WAR artefact and thus scanned by Weld internally during the boot sequence of the MicroProfile Config engine. Payara Server already has its implementation of the MicroProfile Config API and including a competing implementation in the server classpath is causing Weld to be confused about how it should load them.

The solution here is to exclude the Small Rye Config dependency from the WAR's build (a simple <scope>provided</scope> should do this). This is a requirement for true portability since you are including vendor-specific dependencies in your application's deployable. I suggest applying this principle to other possible clashing JARs in it too.

We'll proceed to close this issue as there are no issues with the server's behaviour.

@fturizo fturizo closed this as completed Mar 6, 2024
@fturizo fturizo removed the Status: Open Issue has been triaged by the front-line engineers and is being worked on verification label Mar 6, 2024
@urbandroid
Copy link
Author

Project dependencies should get priority before runtime dependencies how is that not a bug?

@lprimak
Copy link
Contributor

lprimak commented Mar 7, 2024

There are certain dependencies that just can’t be supported. You can’t mix and match conflicting dependencies which is what you are trying to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Label issue as a bug defect
Projects
None yet
Development

No branches or pull requests

5 participants