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

Dependency Injection: Quickfix for bean constructor with parameter anotated with @Disposes, @Observes or @ObservesAsync #212

Closed
Tracked by #16
KidoVin01 opened this issue Nov 12, 2021 · 1 comment · Fixed by #226
Assignees
Labels
diagnostic Diagnostic item

Comments

@KidoVin01
Copy link
Contributor

Declaring a Bean Constructor

If a bean constructor has a parameter annotated @Disposes, @Observes, or @ObservesAsync, the container automatically detects the problem and treats it as a definition error.

Diagnostics for delivering error already exists and is shown at the constructor.

Quickfixes

  • Remove the annotation

Example

@ApplicationScoped
public class Greeting{
	@Inject
	public Greeting (@ObservesAsync String string) {};
	
	public String greet(String name) {
        return "Greeting, " + name;
    }
}
[INFO] [ERROR   ] CWWKZ0004E: An exception occurred while starting the application demo-servlet. The exception message was: com.ibm.ws.container.service.state.StateChangeException: org.jboss.weld.exceptions.WeldException: WELD-000076: Bean constructor must not have a parameter annotated with @ObservesAsync: [EnhancedAnnotatedConstructorImpl] @Inject public io.openliberty.sample.jakarta.di.error.con.Greeting(@ObservesAsync String)

Related to #153

@KidoVin01 KidoVin01 changed the title Dependency Injection: Quickfix for bean constructor with parameter anotated with @Disposes, @Observes or ObservesAsync Dependency Injection: Quickfix for bean constructor with parameter anotated with @Disposes, @Observes or @ObservesAsync Nov 12, 2021
@kathrynkodama kathrynkodama added the diagnostic Diagnostic item label Nov 15, 2021
@KidoVin01
Copy link
Contributor Author

Similar to #105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic Diagnostic item
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants