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

Deploying WAR with ee10-cdi-spi fails with Weld 5/CDI 4 #10356

Closed
justin-tay opened this issue Aug 22, 2023 · 5 comments
Closed

Deploying WAR with ee10-cdi-spi fails with Weld 5/CDI 4 #10356

justin-tay opened this issue Aug 22, 2023 · 5 comments
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@justin-tay
Copy link

justin-tay commented Aug 22, 2023

Jetty version(s)
12.0.0

Jetty Environment
ee10

Java version/vendor (use: java -version)
openjdk 17.0.7 2023-04-18 LTS
OpenJDK Runtime Environment Corretto-17.0.7.7.1 (build 17.0.7+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.7.7.1 (build 17.0.7+7-LTS, mixed mode, sharing)

OS type/version
Windows 11 22H2

Description
The ee10-cdi-spi does not work with Weld 5/CDI 4.

java.lang.NoSuchMethodException: no such method: jakarta.enterprise.inject.spi.BeanManager.createInjectionTarget(AnnotatedType)InjectionTarget/invokeInterface

The CdiSpiDecorator attempts to find the createInjectionTarget which does not appear in CDI 4. https://jakarta.ee/specifications/coreprofile/10/apidocs/jakarta/enterprise/inject/spi/beanmanager

https://github.com/eclipse/jetty.project/blob/28100e8da711e44c0722ed10bd413ae862497539/jetty-ee10/jetty-ee10-cdi/src/main/java/org/eclipse/jetty/ee10/cdi/CdiSpiDecorator.java#L86

I think the equivalent should be something like

    public <T> InjectionTarget<T> createInjectionTarget(AnnotatedType<T> type) {
        return getInjectionTargetFactory(type).createInjectionTarget(null);
    }

How to reproduce?

  • java -jar %JETTY_HOME%/start.jar --add-modules=http,ee10-deploy,ee10-annotations,ee10-websocket-jakarta,ee10-cdi-spi
  • Deploy a WAR with Weld 5

Using ee10-cdi-decorate doesn't work either because Weld 5's org.jboss.weld.environment.jetty.JettyContainer isn't using the org.eclipse.jetty.ee10.cdi, org.eclipse.jetty.ee10.cdi.decorator,org.eclipse.jetty.ee9.cdi, org.eclipse.jetty.ee9.cdi.decorator attributes but I think that requires changes on their end.

@justin-tay justin-tay added the Bug For general bugs on Jetty side label Aug 22, 2023
@justin-tay justin-tay changed the title Deploying WAR with `ee10-cdi-spi Deploying WAR with ee10-cdi-spi fails with Weld 5/CDI 4 Aug 22, 2023
@janbartel janbartel self-assigned this Aug 23, 2023
janbartel added a commit that referenced this issue Aug 23, 2023
@janbartel
Copy link
Contributor

@justin-tay thanks for the heads-up. I've created #10359 to fix the issue. We can mostly fix it on our side, as there are a few combinations of our CdiServletContainerListener and the Weld EnhancedListener or Listener that will work just fine. I've got a couple more tests to finish off for that PR, so keep an eye on it.

@janbartel
Copy link
Contributor

FYI, raised issue https://issues.redhat.com/browse/WELD-2751 regarding the classloading difficulties now that cdi-api needs to also be on the server's classpath.

janbartel added a commit that referenced this issue Aug 29, 2023
* Issue #10356 Update Weld integration

Signed-off-by: Olivier Lamy <[email protected]>
Co-authored-by: Olivier Lamy <[email protected]>
@janbartel
Copy link
Contributor

@justin-tay fix to jetty has been committed. You might like to test it.

lorban pushed a commit that referenced this issue Aug 30, 2023
* Issue #10356 Update Weld integration

Signed-off-by: Olivier Lamy <[email protected]>
Co-authored-by: Olivier Lamy <[email protected]>
@justin-tay
Copy link
Author

I've just tested it and ee10-cdi-spi now works.

However I also tried enabling ee10-cdi-decorate and that doesn't cause it to use the CdiDecoratingListener. It looks like the module is still setting CdiDecoratingListener on the org.eclipse.jetty.ee10.cdi attribute, but the CdiServletContainerInitializer is reading from org.eclipse.jetty.cdi so it always finds null and always uses the CdiSpiDecorator.

@justin-tay
Copy link
Author

Closing as ee10-cdi-spi now works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

2 participants