You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by X <ma...@qq.com.INVALID> on 2023/07/19 02:50:10 UTC

why is @ServerEndpoint not implemented as @inherited?

Hi, guys, nice to meet you here. I am newbie for maillist, hope I can post this question complying community code of conduct.


My team is developing a new web app with tomcat 9.0.65 and Spring boot 2.7.4. We declare a @ServerEndpoint&nbsp; annotated class, which can not be aop-proxied.
 

The root cause is the tomcat implemented like this:


ServerEnpoint annotation = pojo.getAnnotation(ServerEnpoint.class);


When Spring uses CGlib to create proxy class, the subclass does not has @ServerEndpoint annotation, so the bootstrap fails.

Subclass impls are so common in CDI container,&nbsp; there are common scenario to combine AOP and @ServerEnpoint together. There was similar issue raised for glassfish/undertow already(for example: https://github.com/jakartaee/websocket/issues/229). We also agree that ServerEndpoint is declared as not @inherited according to javax spec. But since many developer need to proxy ServerEnpoint instance, can tomcat do some workaround, just do some recursive super class scan to get annotation instead of fast-fail?


Hope kind answer to explain why tomcat is implemented like what it is now(in 9.0.65 ), thanks in advance.















&nbsp;

Re: why is @ServerEndpoint not implemented as @inherited?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
To whom it may concern,

On 7/18/23 22:50, X wrote:
> My team is developing a new web app with tomcat 9.0.65 and Spring
> boot 2.7.4. We declare a @ServerEndpoint&nbsp; annotated class, which
> can not be aop-proxied.
> 
> The root cause is the tomcat implemented like this:
> 
> ServerEnpoint annotation = pojo.getAnnotation(ServerEnpoint.class);
> 
> When Spring uses CGlib to create proxy class, the subclass does not
> has @ServerEndpoint annotation, so the bootstrap fails.
> 
> Subclass impls are so common in CDI container,&nbsp; there are common
> scenario to combine AOP and @ServerEnpoint together. There was
> similar issue raised for glassfish/undertow already(for example:
> https://github.com/jakartaee/websocket/issues/229). We also agree
> that ServerEndpoint is declared as not @inherited according to javax
> spec. But since many developer need to proxy ServerEnpoint instance,
> can tomcat do some workaround, just do some recursive super class
> scan to get annotation instead of fast-fail?
> 
> 
> Hope kind answer to explain why tomcat is implemented like what it is
> now(in 9.0.65 ), thanks in advance.

If you read https://github.com/jakartaee/websocket/issues/229 you'll see 
why the Jakarta EE declined to make the annotation inheritable.

I'm not sure how your AOP framework works, but you'll have to instruct 
that framework to ensure that the proxy class ends up inheriting the 
annotations.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org