blaze-persistence icon indicating copy to clipboard operation
blaze-persistence copied to clipboard

Warning due to missing `javax.enterprise.inject.Stereotype`

Open EugenMayer opened this issue 5 years ago • 10 comments

1.5.0Alpha2

I'am working through my bootstrap warnings and found Stereotype annotation can not be found, skipping annotation inheritance via stereotype.

It seems like this javax.enterprise.inject.Stereotype would be typical for a J2EE application, but for me i'am neither sure what i should need it for ( spring boot ) nor why i should see a warning due to that on each start.

Could you elaborate a bit why we need this general warning and why it is important / hamrful to not follow the advice and include javax.enterprise.inject.Stereotype ?

Thanks

public final class AnnotationUtils {

    private static Class<? extends Annotation> stereotypeAnnotationClass;

    static {
        try {
            stereotypeAnnotationClass = (Class<? extends Annotation>) Class.forName("javax.enterprise.inject.Stereotype");
        } catch (ClassNotFoundException ex) {
            Logger log = Logger.getLogger(AnnotationUtils.class.getName());
            log.log(Level.WARNING, "Stereotype annotation can not be found, skipping annotation inheritance via stereotype.");
        }
    }

EugenMayer avatar May 20 '20 06:05 EugenMayer

The stereotype annotation could be used to define custom annotations that are aggregates of multiple other annotations see here for more details: https://docs.oracle.com/javaee/6/api/javax/enterprise/inject/Stereotype.html

I don't think anyone really uses this concept though and I am thinking about dropping the support for that as we haven't documented it anywhere anyway.

beikov avatar May 20 '20 13:05 beikov

I get a feeling that its getting more popular in EE. I believe they are used in conjunction with MicroProfile and that there is general hope that stereotypes will eventually provide all behaviour for CDI that currently still requires EJB (timers etc). It could be a bad time to remove support for it 🤷 Perhaps just change the log level to DEBUG or possibly INFO.

That said, I've never used it. Whats the idea behind it? That you can create stereotypes for entity view annotations? I can't really think of a use case for it within the Blaze-Persistence domain.

jwgmeligmeyling avatar May 20 '20 17:05 jwgmeligmeyling

Right, so you could for example define a stereotype annotation like this

@Stereotype
@Mapping(fetch = SUBSELECT)
@UpdatableMapping
@Retention(RUNTIME)
@Target(METHOD)
public @interface UpdatableCollection {}

I'm not sure though if the annotation reader can properly read this, annotation processing for sure does not support that. I also never really tried this out. The support for the stereotype just came with the usage of AnnotationUtils from blaze-common-utils, but there is no specific reason for using that.

I don't know if it is popular in EE, I rarely use stereotypes myself. If nobody cares about this, I will remove it. If you really want it, let me know about the use case, then I can switch to debug logging, but I personally don't see the benefits.

beikov avatar May 20 '20 17:05 beikov

I don't have any use for that, neither yet nor in the future AFAICS.

EugenMayer avatar May 21 '20 05:05 EugenMayer

Same here,

except WARNs during deploy (:smiling_imp:) no additional profits

image

Kaerol avatar Dec 17 '21 07:12 Kaerol

Any update on this @EugenMayer @beikov?

It is especially annoying in a jakarta ee project because it searches for the old javax namespace

EvaristeGalois11 avatar Mar 25 '23 09:03 EvaristeGalois11

I'll try to see what I can do, but you could simply disable the logging for that logger if the message is bothering you so much. Usually, this means just setting logger.com.blazebit.annotation.AnnotationUtils=ERROR in your logging config.

beikov avatar Mar 25 '23 14:03 beikov

I'll try to see what I can do, but you could simply disable the logging for that logger if the message is bothering you so much. Usually, this means just setting logger.com.blazebit.annotation.AnnotationUtils=ERROR in your logging config.

That's true thank you for the workaround, still a bit strange that this warn message is the first thing one will see trying blaze persistence for the first time lol

I understand that removing something like this could be potentially very hard or time consuming with a small return, but maybe just lowering the log level of the messege could be much simpler? You said a couple message above that it's pretty much a forgotten feature, a warn level seems a bit excessive.

Just my thoughts anyway, i'm liking the blaze experience so far so thank you for your hard work!

EvaristeGalois11 avatar Mar 25 '23 14:03 EvaristeGalois11

Thanks for the kind words. I'll try my best to get rid of this as soon as possible.

beikov avatar Mar 25 '23 15:03 beikov

FWIW, I'm also seeing this warning after migration of a Quarkus 2.16 app to 3.1.2, BP 1.6.9 respectively (using those *-jakarta deps) .

famod avatar Jun 16 '23 17:06 famod