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

Missing dependency error not displaying #689

Closed
re-thc opened this issue Sep 22, 2024 · 10 comments · Fixed by avaje/avaje-prisms#90
Closed

Missing dependency error not displaying #689

re-thc opened this issue Sep 22, 2024 · 10 comments · Fixed by avaje/avaje-prisms#90

Comments

@re-thc
Copy link

re-thc commented Sep 22, 2024

If I declare an @Inject without a matching @Singleton or similar, I get the following error:

Caused by: java.lang.NullPointerException: Cannot invoke "String.lastIndexOf(int)" because "fullType" is null

It was pretty hard to realize from that what was missing. Would be good if this error was caught to provide a better message so we can see what to do.

Thanks!

@SentryMan
Copy link
Collaborator

SentryMan commented Sep 22, 2024

Got an example class so I can replicate? The missing dependency message is usually quite descriptive, so this feels like something else is the problem.

@SentryMan
Copy link
Collaborator

SentryMan commented Sep 22, 2024

Yeah, the error message still works for me.

[ERROR] /M:/Dev/avaje-helidon-nima-api-example/src/main/java/com/jojo/helidon/api/Example.java:[6,8] No dependency provided for com.jojo.helidon.api.DependencyClass on com.jojo.helidon.api.Example
[ERROR] Dependencies [com.jojo.helidon.api.DependencyClass] are not provided - there are no @Singleton, @Component, @Factory/@Bean that currently provide this type. If this is an external dependency consider specifying via @External

Tried field/constructor/method injection, but I am unable to replicate your issue.

@SentryMan SentryMan changed the title Better error on missing dependencies? Missing dependency error not displaying Sep 24, 2024
@SentryMan
Copy link
Collaborator

@re-thc got anything to add? I can't publish a fix if I can't replicate the issue.

@re-thc
Copy link
Author

re-thc commented Sep 30, 2024

Happy to close. It triggers if the class is coming from another project/module/jar and no longer exists. Maybe too convoluted to cater for.

@SentryMan
Copy link
Collaborator

can you run with mvn compile -X and send the stacktrace.

@SentryMan
Copy link
Collaborator

@re-thc can you explain exactly how you got this? Edge case it may be, but if it happened once it'll happen again to somebody else.

It triggers if the class is coming from another project/module/jar and no longer exists.

what do you mean no longer exists?

@re-thc
Copy link
Author

re-thc commented Oct 4, 2024

can you explain exactly how you got this?

It happens if you reference a class that no longer exists. You do get class not found exceptions also. When there's a long chain of errors it's possible to miss it so was originally confused by this particular error.

what do you mean no longer exists?

Say it gets deleted or renamed.

@rbygrave
Copy link
Contributor

rbygrave commented Oct 9, 2024

Really need the stack trace for this one. Can you provide it?

@SentryMan
Copy link
Collaborator

@re-thc we should be able to fix it if you provide a stack trace

@SentryMan
Copy link
Collaborator

SentryMan commented Nov 2, 2024

@rbygrave, I figured out how to replicate it using JPMS. All you have to do is remove requires directives for the types you're using. (like blackbox.other in the tests)

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

Successfully merging a pull request may close this issue.

3 participants