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

JDK8u60 breaks CDI Injection #407

Closed
mamboking opened this issue Aug 24, 2015 · 16 comments
Closed

JDK8u60 breaks CDI Injection #407

mamboking opened this issue Aug 24, 2015 · 16 comments

Comments

@mamboking
Copy link

JDK8u60 is adding a RuntimeVisibleParameterAnnotations section to the compiled bytecode for lambdas. JDK8u51 did not add that section. This is causing failures when trying to deploy my project.

Test Class:

package com.lairdlink.lib.cdilambda.CDITest;

import java.util.Arrays;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Observes;

@RequestScoped
public class CDITest {

    public void foo(@Observes String someString) {
        List<String> strList = Arrays.asList("s1", "s2", "s3");
        final int a = 0;
        final int b = 1;

        strList.forEach((s) -> { System.out.printf("%s - %d - %d - %s\n", someString, a, b, s); });
    }
}

Error:

org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type String with qualifiers @default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedMethod] private static com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(@observes String, String)
at com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(CDITest.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:

  • Producer Method [String] with qualifiers [@JaxRsParamQualifier @Any] declared as [[UnbackedAnnotatedMethod] @produces @JaxRsParamQualifier public org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider$JaxRsParamProducer.getParameterValue(InjectionPoint, BeanManager)],
  • Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @produces @dependent @BatchProperty public com.ibm.jbatch.container.cdi.BatchProducerBean.produceProperty(InjectionPoint)]
@smillidge
Copy link
Contributor

Is that all I need to reproduce a war with the above class in or do I need to know what the Event generator code to go with this is? Even better would be a simple test application on GitHub we could use to investigate.

@mamboking
Copy link
Author

That is the only class you need. It doesn't deploy when compiled with JDK8u60.

I used netbeans and created a Maven -> Web Application project. That is the only class in the project.

@mamboking
Copy link
Author

Here's the full project I used: https://github.com/mamboking/jdk8u60_cdi_test

@smillidge
Copy link
Contributor

Is it compiled with the -parameters flag?

@mamboking
Copy link
Author

No, it is not.

@smillidge
Copy link
Contributor

I'm afraid I can't reproduce this.

I cloned your GitHub project
Deployed the application using the console
It deployed on JDK8u60 successfully.
I am running the latest Payara build.

See screenshot below
screenshot from 2015-08-26 18 56 10

@smillidge
Copy link
Contributor

Sorry I hadn't compiled the war on JDK8u60. I can now reproduce the issue

@arjantijms
Copy link
Contributor

@aq47
Copy link
Contributor

aq47 commented Aug 27, 2015

Getting same issues with GlassFish 4.1, Payara 4.1.153, wildfly-9.0.1.Final, Wildly wildfly-10.0.0.Beta2

Payara 4.1.153

remote failure: Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type String with qualifiers @default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedMethod] private static com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(@observes String, String)
at com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(CDITest.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:

  • Producer Method [String] with qualifiers [@JaxRsParamQualifier @Any] declared as [[UnbackedAnnotatedMethod] @produces @JaxRsParamQualifier public org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider$JaxRsParamProducer.getParameterValue(InjectionPoint, BeanManager)],
  • Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @produces @dependent @BatchProperty public com.ibm.jbatch.container.cdi.BatchProducerBean.produceProperty(InjectionPoint)]
    . Please see server.log for more details.
    Command deploy failed.

GlassFish 4.1

remote failure: Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type String with qualifiers @default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedMethod] private static com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(@observes String, String)
at com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(CDITest.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:

  • Producer Method [String] with qualifiers [@JaxRsParamQualifier @Any] declared as [[UnbackedAnnotatedMethod] @produces @JaxRsParamQualifier public org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$JaxRsParamProducer.getParameterValue(InjectionPoint, BeanManager)],
  • Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @produces @dependent @BatchProperty public com.ibm.jbatch.container.cdi.BatchProducerBean.produceProperty(InjectionPoint)]
    . Please see server.log for more details.
    Command deploy failed.

Wildfly wildfly-9.0.1.Final

Unexpected HTTP response: 500

Request
{
"operation" => "deploy",
"address" => [("deployment" => "CDILambda-1.0.0-SNAPSHOT.war")]
}

Response

Internal Server Error
{
"outcome" => "failed",
"failure-description" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit."CDILambda-1.0.0-SNAPSHOT.war".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit."CDILambda-1.0.0-SNAPSHOT.war".WeldStartService: Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type String with qualifiers @default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedMethod] private static com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(@observes String, String)
at com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(CDITest.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:

  • Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @produces @BatchProperty public org.jberet.creation.BatchBeanProducer.getString(InjectionPoint)]
    "}},
    "rolled-back" => true
    }

Wildly wildfly-10.0.0.Beta2

Unexpected HTTP response: 500

Request
{
"operation" => "deploy",
"address" => [("deployment" => "CDILambda-1.0.0-SNAPSHOT.war")]
}

Response

Internal Server Error
{
"outcome" => "failed",
"failure-description" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit."CDILambda-1.0.0-SNAPSHOT.war".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit."CDILambda-1.0.0-SNAPSHOT.war".WeldStartService: Failed to start service
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type String with qualifiers @default
at injection point [BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedMethod] private static com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(@observes String, String)
at com.lairdlink.lib.cdilambda.CDITest.CDITest.lambda$foo$0(CDITest.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:

  • Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @produces @BatchProperty public org.jberet.creation.BatchBeanProducer.getString(InjectionPoint)]
    "}},
    "rolled-back" => true
    }

@mamboking
Copy link
Author

This is the only thing that is added by u60 when compared to u51 bytecode:

205a206
>             0      36     0 someString   Ljava/lang/String;
206a208,211
>     RuntimeVisibleParameterAnnotations:
>       parameter 0:
>         0: #34()
>       parameter 1:

@arjantijms
Copy link
Contributor

@mamboking yes, that 's indeed the only change. I diffed the output of a number of variants, and only that changed every time.

I also checked on TomEE 7.0-snapshot (apache-tomee-7.0.0-20150518.041133-5-plus.zip) which uses OWB instead of Weld (OWB version 1.6.0-SNAPSHOT) and this one did not seem to have any issues with the U60 compiled war.

@smillidge
Copy link
Contributor

I agree the problem is as you describe in your email to the JDK list @arjantijms. The synthetic method is now a valid event observer method but the second parameter has no matching producer. If you did have a matching producer/bean and it deployed correctly I suppose all sort of weirdness could happen.

@aq47
Copy link
Contributor

aq47 commented Aug 27, 2015

Issue raised in JIRA
https://issues.jboss.org/browse/WELD-2021

@ratcashdev
Copy link
Contributor

https://issues.jboss.org/browse/WELD-2019 just got resolved. Does Payara plan to release a hotfix for 4.1.153 (likely together with #377)?

@smillidge
Copy link
Contributor

Once they are both out to Maven central we will incorporate them into the Payara build and close the two issues. Latest builds are always downloadable from http://www.payara.co.uk/upstream_builds

@smillidge
Copy link
Contributor

payara test please

smillidge added a commit that referenced this issue Sep 17, 2015
JamesHillyard pushed a commit to JamesHillyard/Payara that referenced this issue Sep 17, 2021
FISH-666 FISH-1069 FISH-1416 FISH-1504 FISH-1526 MicroProfile 4.0
JamesHillyard pushed a commit to JamesHillyard/Payara that referenced this issue Sep 17, 2021
This reverts commit 1185010, reversing
changes made to 3fdff0e.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants