long startup time

hi,

i have used vaadin for a while. suddenly the startup time of vaadin server became very long. i found there’s a operation cause 50s. can anyone explain why?

2020-10-27 15:29:24.462 INFO 3498 — [ restartedMain]
c.v.f.s.VaadinServletContextInitializer : Search for subclasses and classes with annotations took 50 seconds

Hello,

Vaadin scans through all classpath entries (with the exception of some default exclusions) for annotations, such as @Route. Slowdown can be observed if you have recently added some large dependencies to the project. In that case, it is advisable to configure exclusion or inclusion of packages wrt. annotation scanning. See https://vaadin.com/docs/flow/spring/tutorial-spring-configuration.html for details.

Johannes

Johannes Eriksson:
Hello,

Vaadin scans through all classpath entries (with the exception of some default exclusions) for annotations, such as @Route. Slowdown can be observed if you have recently added some large dependencies to the project. In that case, it is advisable to configure exclusion or inclusion of packages wrt. annotation scanning. See https://vaadin.com/docs/flow/spring/tutorial-spring-configuration.html for details.

Johannes

OK, thanks for your information. it seems like a import the jaxws package.

hi,

i found after i import javax lib, this issue happened. and i add “vaadin.blacklisted-packages=javax/xml/ws/Service” in application.properties, but it did not work. the load still very long.


<dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-ri</artifactId>
            <version>2.3.2</version>
            <type>pom</type>
        </dependency>

It also looks like the jaxws-ri depedendency brings some large packages transitively, such as org.eclipse.persistence. Note that vaadin.blacklisted-packages can be a comma-separated list of packages names. Have you tried vaadin.blacklisted-packages=javax/xml/ws,org/eclipse/persistence? An alternative to having to track down exclusions when adding a dependency is using white-listing, where you explicitly specify the packages to be scanned (typically this would be the package path of your app and any add-on you may include).

Johannes

Johannes Eriksson:
It also looks like the jaxws-ri depedendency brings some large packages transitively, such as org.eclipse.persistence. Note that vaadin.blacklisted-packages can be a comma-separated list of packages names. Have you tried vaadin.blacklisted-packages=javax/xml/ws,org/eclipse/persistence? An alternative to having to track down exclusions when adding a dependency is using white-listing, where you explicitly specify the packages to be scanned (typically this would be the package path of your app and any add-on you may include).

Johannes

it works. thanks. but how to find out “org.eclipse.persistence” package ? i mean there are lots of depends packages, how could you know which one is big?

When adding a new dependency, I suggest keeping an eye on the sizes reported by Maven as it downloads transitive dependencies. E.g., when adding the aforementioned jaxws-ri I could see in the log:

...
Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/persistence/org.eclipse.persistence.moxy/2.7.4/org.eclipse.persistence.moxy-2.7.4.jar (653 kB at 2.8 MB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/persistence/org.eclipse.persistence.sdo/2.7.4/org.eclipse.persistence.sdo-2.7.4.jar (400 kB at 1.7 MB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/persistence/org.eclipse.persistence.asm/2.7.4/org.eclipse.persistence.asm-2.7.4.jar (508 kB at 2.0 MB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/persistence/org.eclipse.persistence.core/2.7.4/org.eclipse.persistence.core-2.7.4.jar (5.4 MB at 9.8 MB/s)

To determine the size of a single dependency with its transitives the following SO tips may help:
https://stackoverflow.com/questions/22175847/maven-gradle-way-to-calculate-the-total-size-of-a-dependency-with-all-its-transi
(Caveat: the time-consuming part is scanning classes and as the physical size of a library is not necessarily a reflection on the number of classes, looking at the sizes does not always tell the full story).
Anyway, org.eclipse.persistence is such a common dependency that we may add it to the default exclusion list.

Johannes