Skip to content

vaadin-spring-boot-starter contains jakarta.websocket package twice #3898

Closed
vaadin/flow
#16221

Description

@Frettman

Describe the bug

The vaadin-spring-boot-starter contains the jakarta.websocket Java package twice. This - so far - isn't a problem during compilation or execution, but Javadoc complains about it and it might be a problem later, if the versions of these packages ever diverge from each other.
jakarta.websocket-api and jakarta.websocket-client-api are included via vaadin-core -> vaadin-dev -> vaadin-dev-server.
tomcat-embed-websocket is included via spring-boot-starter-web -> spring-boot-starter-tomcat.

My first guess would be that vaadin-spring-boot-starter should exclude jakarta.websocket-api and jakarta.websocket-client-api from its vaadin-core dependency. vaadin-core is Spring-independent, so it would make sense that vaadin-spring-boot-starter would override these dependencies with its own versions. But maybe there a better way. (Like asking

Please note, that apps generated via https://start.vaadin.com/ also include com.vaadin:vaadin, which in turn would bring back jakarta.websocket-api and jakarta.websocket-client-api again. Since there's usually no Javadoc artifact for applications, there wouldn't be any build error, but having the same package twice on the classpath could still cause problems later.

Expected-behavior

It would be nice if Vaadin add-ons using vaadin-spring-boot-starter could just have their Javadoc artifact built without having to tweak the dependencies.

Reproduction

Opening any project created via https://start.vaadin.com/ should show the affected dependency tree.

System Info

Vaadin 24
Java 17
Maven 3.8.7 (maven-javadoc-plugin:3.4.1)

Activity

  1. knoobie commented on Mar 10, 2023

    @knoobie
    Contributor

    I would recommend to exclude vaadin-dev-* from your production build and artefacts nevertheless

  2. Frettman commented on Mar 10, 2023

    @Frettman
    Author

    I would recommend to exclude vaadin-dev-* from your production build and artefacts nevertheless

    After having checked my projects, that exclusion is already part of the production profile :) Good advice nonetheless. Especially since the https://start.vaadin.com/ projects don't do that yet (hint hint).

  3. knoobie commented on Mar 10, 2023

    @knoobie
    Contributor

    The ticket for the exclusion is here vaadin/flow#15749

  4. mstahv commented on Mar 10, 2023

    @mstahv
    Member

    Plain servlet starters seem to have some issues as well. Pretty much all jakarta namespaced stuff should only be in provides scope in vaadin dependencies:

    Screenshot 2023-03-10 at 10 59 43

    Websocket stuff seems to be coming from development mode stuff (not that critical), but in production profile there is still annotation,inject and validation.

  5. Artur- commented on Mar 10, 2023

    @Artur-
    Member

    Especially since the https://start.vaadin.com/ projects don't do that yet (hint hint).

    Doesn't this do it?

            <profile>
                <!-- Production mode is activated using -Pproduction -->
                <id>production</id>
                <dependencies>
                    <!-- Exclude development dependencies from production -->
                    <dependency>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-core</artifactId>
                        <exclusions>
                            <exclusion>
                                <groupId>com.vaadin</groupId>
                                <artifactId>vaadin-dev</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
    
  6. Artur- commented on Mar 10, 2023

    @Artur-
    Member

    Opening any project created via https://start.vaadin.com/ should show the affected dependency tree.

    I only see the websocket api included once (it should be included 0 times) but not twice:

    [INFO] |  \- com.vaadin:vaadin-core:jar:24.0.0:compile
    [INFO] |     \- com.vaadin:vaadin-dev:jar:24.0.0:compile
    [INFO] |        +- com.vaadin:vaadin-dev-server:jar:24.0.0:compile
    [INFO] |        |  +- jakarta.websocket:jakarta.websocket-api:jar:2.1.0:compile
    [INFO] |        |  \- jakarta.websocket:jakarta.websocket-client-api:jar:2.1.0:compile
    [INFO] |        \- com.vaadin:vaadin-dev-bundle:jar:24.0.0:compile
    
  7. added a commit that references this issue on Mar 10, 2023
  8. Frettman commented on Mar 10, 2023

    @Frettman
    Author

    Doesn't this do it?

    Ah, yes, this will do it of course. I had some fairly recent projects from shortly before the Vaadin 24 release (Vaadin 24 beta2) that didn't include this yet. So you were a bit faster than me :)

  9. Frettman commented on Mar 10, 2023

    @Frettman
    Author

    I only see the websocket api included once (it should be included 0 times) but not twice:

    The Websocket API is also contained in tomcat-embed-websocket. Two different artifacts containing the same packages. That's always bound to get messy. But it makes me wonder, why tomcat-embed-websocket doesn't depend on jakarta.websocket:jakarta.websocket-api instead of including the same classes...

  10. Artur- commented on Mar 10, 2023

    @Artur-
    Member

    LIkely any server that implements the API will include both the API and the implementation. Anyway, vaadin/flow#16221 should fix it

  11. Frettman commented on Mar 10, 2023

    @Frettman
    Author

    The provided scope does not seem to make a difference for Javadoc (which made me aware of this in the first place). But I'll just exclude vaadin-dev in all Vaadin add-ons that are also Spring Boot add-ons.

  12. mstahv commented on Mar 10, 2023

    @mstahv
    Member

    The PR by @Artur- only tackles to websocket APIs coming from dev server. Changed to scope of validation and annotation api's in https://github.com/vaadin/flow/pull/16223/files

    Didn't build it locally, let's see what the tests say about that...

  13. mstahv commented on Mar 10, 2023

    @mstahv
    Member

    And then there is still inject API left:

    [INFO] |  |  |  +- com.vaadin:flow-push:jar:24.0.0:compile
    [INFO] |  |  |  |  \- com.vaadin.external.atmosphere:atmosphere-runtime:jar:3.0.0.slf4jvaadin2:compile
    [INFO] |  |  |  |     \- jakarta.inject:jakarta.inject-api:jar:2.0.1:compile
    
  14. mstahv commented on Mar 10, 2023

    @mstahv
    Member

    @Frettman Good point about the add-ons. Probably all add-ons should now have the vaadin-dev excluded, not nice :-(

  15. mstahv commented on Mar 10, 2023

    @mstahv
    Member

    Or have vaadin/vaadin-core in provided scope 🤷‍♂️

  16. Artur- commented on Mar 10, 2023

    @Artur-
    Member

    If you do not set the vaadin or vaadin-core dependency to provided in an addon, you might cause version conflict problems for the users at some point

  17. mstahv commented on Mar 10, 2023

    @mstahv
    Member

    If one only depends on an add-on there shouldn't be conflicts.

  18. mstahv commented on Mar 10, 2023

    @mstahv
    Member

    atmosphere fix in Atmosphere/atmosphere#2489 (coming in via vaadin-push, which includes a special build of atmostphere).

  19. added a commit that references this issue on Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions