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

Production build fails if Spring Boot Application implements AppShellConfigurator and is annotated with a Spring Data JPA Repository #19616

Open
leluna opened this issue Jun 20, 2024 · 20 comments

Comments

@leluna
Copy link

leluna commented Jun 20, 2024

Description of the bug

If the application class is used as AppShellConfigurator as in the starter project, the production build fails with NoClassDefFoundError: org/springframework/context/ApplicationEventPublisherAware if the application class is also annotated with @EnableJpaRepositories.

This happens only with profile production, but fails in the prepare-frontend goal that is executed before build-frontend.

The exception itself comes probably from the fact that the AppShellConfigurator class (or any class that is annotated with @theme) is annotated with @EnableJpaRepository, which imports JpaRepositoryFactoryBean that ultimately implements ApplicationEventPublisherAware. However, why the class cannot be found is not not clear to me. Its dependency spring-context is included in the compile scope.

ApplicationEventPublisherAware has many implementations in Spring Security too.

More detailed stacktrace:

Caused by: java.lang.TypeNotPresentException: Type [unknown] not present at java.lang.reflect.Method.getDefaultValue (Method.java:724) at sun.reflect.annotation.AnnotationType.<init> (AnnotationType.java:133) at sun.reflect.annotation.AnnotationType.getInstance (AnnotationType.java:85) at sun.reflect.annotation.AnnotationParser.parseAnnotation2 (AnnotationParser.java:262) at sun.reflect.annotation.AnnotationParser.parseAnnotations2 (AnnotationParser.java:121) at sun.reflect.annotation.AnnotationParser.parseAnnotations (AnnotationParser.java:73) at java.lang.Class.createAnnotationData (Class.java:4068) at java.lang.Class.annotationData (Class.java:4057) at java.lang.Class.getAnnotationsByType (Class.java:3965) at com.vaadin.flow.internal.AnnotationReader.getAnnotationsFor (AnnotationReader.java:221) at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.lambda$verifyTheme$5 (FullDependenciesScanner.java:383) at java.util.stream.ReferencePipeline$7$1.accept (ReferencePipeline.java:273) at java.util.Iterator.forEachRemaining (Iterator.java:133) at java.util.Spliterators$IteratorSpliterator.forEachRemaining (Spliterators.java:1845) at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509) at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921) at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682) at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.verifyTheme (FullDependenciesScanner.java:389) at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.discoverTheme (FullDependenciesScanner.java:339) at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:131) at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:94) at com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner$FrontendDependenciesScannerFactory.createScanner (FrontendDependenciesScanner.java:93) at com.vaadin.flow.server.frontend.NodeTasks.<init> (NodeTasks.java:125) at com.vaadin.flow.plugin.base.BuildFrontendUtil.prepareFrontend (BuildFrontendUtil.java:172) at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:64) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationEventPublisherAware at java.lang.ClassLoader.defineClass1 (Native Method) at java.lang.ClassLoader.defineClass (ClassLoader.java:1012) at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150) at java.net.URLClassLoader.defineClass (URLClassLoader.java:524

Expected behavior

No exception during production build.

Minimal reproducible example

Using the starter:

  • Include spring-data-jpa as dependency
  • Implements a class implementing Repository, e.g. public class TestRepository implements Repository<String, Integer>{}. Can be a static inner class of the Application class
  • Annotation Application with @EnableJpaRepositories(basePackageClasses = Application.TestRepository.class)

Execute mvn clean package -Pproduction and see the build fail.

Versions

  • Vaadin / Flow version: 24.4.3
  • Java version: 17
  • OS version: Windows
  • Browser version (if applicable):
  • Application Server (if applicable):
  • IDE (if applicable):
@mcollovati
Copy link
Collaborator

My guess is that this happens because, even though the dependencies' scanner is using the project classpath, the maven plugin goal is executed within the plugin classpath.

@mcollovati
Copy link
Collaborator

Related draft PR #19010

@mcollovati
Copy link
Collaborator

Workaround should be moving the @EnableJpaRepositories on a separated @Configuration class

@leluna
Copy link
Author

leluna commented Jun 21, 2024

Another workaround would be to implement a separate class for AppShellConfigurator

@enver-haase
Copy link
Contributor

enver-haase commented Jun 24, 2024

I had the exact same problem in December 2021 with vaadin-maven-plugin:9.0.0 .
The workaround from that time still applies when you comment it back in:

<plugin>
                                <groupId>com.vaadin</groupId>
                                <artifactId>vaadin-maven-plugin</artifactId>
                                <version>${vaadin.version}</version>
                                <!-- This is a problem with Vaadin 22.0.0; more exactly
                                vaadin-maven-plugin:9.0.0
                    and flow-maven-plugin:9.0.0 . The build-frontend step breaks without the
                    stanza below. -->
                                <!--dependencies>
                                        <dependency>
                                                <groupId>org.springframework</groupId>
                                                <artifactId>spring-context</artifactId>
                                                <version>5.3.13</version>
                                        </dependency>
                                </dependencies-->
                                <executions>
                                        <execution>
                                                <goals>
                                                        <goal>prepare-frontend</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>


@VISTALL
Copy link

VISTALL commented Jul 24, 2024

After update to last vaadin version got same problem, and I can't find fix for now (suggestion not works as expected)

[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:24.4.7:prepare-frontend (default) on project webadmin: Could not execute prepare-frontend goal.: Error occured during goal execution: Type [unknown] not present
[ERROR] 
[ERROR] Please run Maven with the -e switch (or Gradle with the --stacktrace switch), to learn the full stack trace. org/springframework/context/ApplicationEventPublisherAware: org.springframework.context.ApplicationEventPublisherAware
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.vaadin:vaadin-maven-plugin:24.4.7:prepare-frontend (default) on project webadmin: Could not execute prepare-frontend goal.
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:347)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoFailureException: Could not execute prepare-frontend goal.
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:66)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: com.vaadin.flow.server.ExecutionFailedException: Error occured during goal execution: Type [unknown] not present

Please run Maven with the -e switch (or Gradle with the --stacktrace switch), to learn the full stack trace.
    at com.vaadin.flow.plugin.base.BuildFrontendUtil.prepareFrontend (BuildFrontendUtil.java:178)
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:64)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: java.lang.TypeNotPresentException: Type [unknown] not present
    at java.lang.reflect.Method.getDefaultValue (Method.java:779)
    at sun.reflect.annotation.AnnotationType.<init> (AnnotationType.java:133)
    at sun.reflect.annotation.AnnotationType.getInstance (AnnotationType.java:85)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2 (AnnotationParser.java:262)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2 (AnnotationParser.java:121)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations (AnnotationParser.java:73)
    at java.lang.Class.createAnnotationData (Class.java:4246)
    at java.lang.Class.annotationData (Class.java:4235)
    at java.lang.Class.getAnnotationsByType (Class.java:4143)
    at com.vaadin.flow.internal.AnnotationReader.getAnnotationsFor (AnnotationReader.java:221)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.discoverPackages (FullDependenciesScanner.java:235)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:125)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:94)
    at com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner$FrontendDependenciesScannerFactory.createScanner (FrontendDependenciesScanner.java:93)
    at com.vaadin.flow.server.frontend.NodeTasks.<init> (NodeTasks.java:125)
    at com.vaadin.flow.plugin.base.BuildFrontendUtil.prepareFrontend (BuildFrontendUtil.java:172)
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:64)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationEventPublisherAware
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf (ClassRealm.java:425)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf (ClassRealm.java:425)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:580)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:593)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:534)
    at java.lang.Class.forName (Class.java:513)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType (CoreReflectionFactory.java:114)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature (Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept (ClassTypeSignature.java:49)
    at sun.reflect.annotation.AnnotationParser.parseSig (AnnotationParser.java:442)
    at sun.reflect.annotation.AnnotationParser.parseClassValue (AnnotationParser.java:428)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue (AnnotationParser.java:347)
    at java.lang.reflect.Method.getDefaultValue (Method.java:772)
    at sun.reflect.annotation.AnnotationType.<init> (AnnotationType.java:133)
    at sun.reflect.annotation.AnnotationType.getInstance (AnnotationType.java:85)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2 (AnnotationParser.java:262)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2 (AnnotationParser.java:121)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations (AnnotationParser.java:73)
    at java.lang.Class.createAnnotationData (Class.java:4246)
    at java.lang.Class.annotationData (Class.java:4235)
    at java.lang.Class.getAnnotationsByType (Class.java:4143)
    at com.vaadin.flow.internal.AnnotationReader.getAnnotationsFor (AnnotationReader.java:221)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.discoverPackages (FullDependenciesScanner.java:235)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:125)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:94)
    at com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner$FrontendDependenciesScannerFactory.createScanner (FrontendDependenciesScanner.java:93)
    at com.vaadin.flow.server.frontend.NodeTasks.<init> (NodeTasks.java:125)
    at com.vaadin.flow.plugin.base.BuildFrontendUtil.prepareFrontend (BuildFrontendUtil.java:172)
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:64)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationEventPublisherAware
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf (ClassRealm.java:425)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf (ClassRealm.java:425)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:580)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:593)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:534)
    at java.lang.Class.forName (Class.java:513)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType (CoreReflectionFactory.java:114)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature (Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept (ClassTypeSignature.java:49)
    at sun.reflect.annotation.AnnotationParser.parseSig (AnnotationParser.java:442)
    at sun.reflect.annotation.AnnotationParser.parseClassValue (AnnotationParser.java:428)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue (AnnotationParser.java:347)
    at java.lang.reflect.Method.getDefaultValue (Method.java:772)
    at sun.reflect.annotation.AnnotationType.<init> (AnnotationType.java:133)
    at sun.reflect.annotation.AnnotationType.getInstance (AnnotationType.java:85)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2 (AnnotationParser.java:262)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2 (AnnotationParser.java:121)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations (AnnotationParser.java:73)
    at java.lang.Class.createAnnotationData (Class.java:4246)
    at java.lang.Class.annotationData (Class.java:4235)
    at java.lang.Class.getAnnotationsByType (Class.java:4143)
    at com.vaadin.flow.internal.AnnotationReader.getAnnotationsFor (AnnotationReader.java:221)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.discoverPackages (FullDependenciesScanner.java:235)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:125)
    at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:94)
    at com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner$FrontendDependenciesScannerFactory.createScanner (FrontendDependenciesScanner.java:93)
    at com.vaadin.flow.server.frontend.NodeTasks.<init> (NodeTasks.java:125)
    at com.vaadin.flow.plugin.base.BuildFrontendUtil.prepareFrontend (BuildFrontendUtil.java:172)
    at com.vaadin.flow.plugin.maven.PrepareFrontendMojo.execute (PrepareFrontendMojo.java:64)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

@VISTALL
Copy link

VISTALL commented Jul 24, 2024

And yes, its repositoryFactoryBean. Moving @EnableJpaRepositories not helps, due it anyway analyzed, and throw exception

image

@enver-haase
Copy link
Contributor

Did you try my workaround, too?

@VISTALL
Copy link

VISTALL commented Jul 24, 2024

What I tested, and that not works:

  • move @EnableJpaRepositories to another configuration
  • extract AppShellConfigurator impl
  • adding context dependency to plugin

Now impossible build project, and I reverted upgrade. Also checked - due analyzer run on every annotated class, he will anyway throw exception on other class (all views, etc). Because #getAnnotationsByType() load all annotations

JDK code from Class

    @Override
    public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) {
        Objects.requireNonNull(annotationClass);

        AnnotationData annotationData = annotationData(); // HERE we load all annotations
        return AnnotationSupport.getAssociatedAnnotations(annotationData.declaredAnnotations,
                                                          this,
                                                          annotationClass);
    }

@mcollovati
Copy link
Collaborator

@VISTALL a couple of questions:

  • do you have optimizeBundle set to false in the plugin configuration?
  • looking at the stack trace it seems that the failure happens when visiting classes annotated with @NpmPackage. Since you already have a breakpoint where the exception is raised, can you inspect the stack at FullDependenciesScanner.discoverPackages:235 and confirm which is the offending class, and possibly, show its source code?

@VISTALL
Copy link

VISTALL commented Jul 24, 2024

@mcollovati Yes - optimizeBundle disabled, due project contains around 5 modules, and sometimes optimization make problems.

And yes.
image

@mcollovati
Copy link
Collaborator

I can reproduce if I put a @NpmPackage and @EnableJpaRepositories on the same class implementing AppShellConfigurator.
But once I move all Vaadin annotations to a separated class, the error does not happen anymore.
The workaround works fine with both values of optimizedBundle.

Can you share the code of the Application class? Annotations and definitions should be enough, no need for the whole class.

@VISTALL
Copy link

VISTALL commented Jul 24, 2024

It's company code - not possible. But as you said. App implement AppShellConfigurator and @EnableJpaRepositories exists.

If I move implementation of AppShellConfigurator to another class (just for it) - problem persist.

@SpringBootApplication(scanBasePackages = ?")
@EnableCaching
@EnableScheduling
@Push(value = PushMode.MANUAL, transport = Transport.WEBSOCKET)
@EntityScan(basePackages = "?")
@EnableJpaRepositories(basePackages = "?")
@Theme("?")
@NpmPackage(value = "@fortawesome/fontawesome-free", version = "6.4.0")
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "?"))
@Uses(RadioButtonGroup.class)
@Uses(TextArea.class)
@Uses(ApexCharts.class)
@Uses(Accordion.class)
@Uses(DateTimePicker.class)
@Uses(ComboBox.class)
@Uses(NumberField.class)
@Uses(Checkbox.class)
@Uses(ProgressBar.class)
@Uses(Button.class)
@Uses(IntegerField.class)
@Uses(ColorPicker.class)
@Uses(AceEditor.class)
@Uses(ToggleButton.class)
@Uses(VirtualList.class)
@Uses(Upload.class)
@Uses(TinyMce.class)
@JsModule("./clipboard/clipboard.js")
@NpmPackage(value = "@esotericsoftware/spine-player", version = "4.1.51")
@StyleSheet("@esotericsoftware/spine-player/dist/spine-player.min.css")
public class Application implements AppShellConfigurator {

@Uses from logic when optimization enabled, and there some implicit dependencies exists (like plugins). Legacy - just need remove it :D

@mcollovati
Copy link
Collaborator

Moving all Vaadin annotations to another class seems to work. Give the above snippet it would be like

@SpringBootApplication(scanBasePackages = ?")
@EnableCaching
@EnableScheduling
@EntityScan(basePackages = "?")
@EnableJpaRepositories(basePackages = "?")
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "?"))
public class Application {

and

@Push(value = PushMode.MANUAL, transport = Transport.WEBSOCKET)
@Theme("?")
@NpmPackage(value = "@fortawesome/fontawesome-free", version = "6.4.0")
@Uses(RadioButtonGroup.class)
@Uses(TextArea.class)
@Uses(ApexCharts.class)
@Uses(Accordion.class)
@Uses(DateTimePicker.class)
@Uses(ComboBox.class)
@Uses(NumberField.class)
@Uses(Checkbox.class)
@Uses(ProgressBar.class)
@Uses(Button.class)
@Uses(IntegerField.class)
@Uses(ColorPicker.class)
@Uses(AceEditor.class)
@Uses(ToggleButton.class)
@Uses(VirtualList.class)
@Uses(Upload.class)
@Uses(TinyMce.class)
@JsModule("./clipboard/clipboard.js")
@NpmPackage(value = "@esotericsoftware/spine-player", version = "4.1.51")
@StyleSheet("@esotericsoftware/spine-player/dist/spine-player.min.css")
public class AppShell implements AppShellConfigurator {

@VISTALL
Copy link

VISTALL commented Jul 24, 2024

And. Looks like it helps. Thanks. Ambiguous problem, code was legal before update (and there no info about limitation)

@mcollovati
Copy link
Collaborator

It looks like that in 24.3 the class scan is not performed during prepare-frontend, whereas it is done in 24.4. I have to check if this has been changed on purpose or if it is a regression caused by #19011

@VISTALL
Copy link

VISTALL commented Jul 24, 2024

Will be nice to see fix in near future :)

mcollovati added a commit that referenced this issue Jul 25, 2024
Wraps the annotation finder function to log potential errors during
class scanning and the class that originates the failure.

References #19616
mcollovati added a commit that referenced this issue Jul 25, 2024
Wraps the annotation finder function to log potential errors during
class scanning and the class that originates the failure.

References #19616
mcollovati added a commit that referenced this issue Jul 26, 2024
Wraps the annotation finder function to log potential errors during
class scanning and the class that originates the failure.

References #19616
vaadin-bot pushed a commit that referenced this issue Jul 26, 2024
Wraps the annotation finder function to log potential errors during
class scanning and the class that originates the failure.

References #19616
vaadin-bot pushed a commit that referenced this issue Jul 26, 2024
Wraps the annotation finder function to log potential errors during
class scanning and the class that originates the failure.

References #19616
vaadin-bot added a commit that referenced this issue Jul 26, 2024
…#19724)

Wraps the annotation finder function to log potential errors during
class scanning and the class that originates the failure.

References #19616

Co-authored-by: Marco Collovati <[email protected]>
vaadin-bot added a commit that referenced this issue Jul 26, 2024
…#19725)

Wraps the annotation finder function to log potential errors during
class scanning and the class that originates the failure.

References #19616

Co-authored-by: Marco Collovati <[email protected]>
@mo-jo
Copy link

mo-jo commented Aug 8, 2024

Just as a short info:
I have updated to Vaadin Version 24.4.8 yesterday and have still the exact same error as decribed above.
Using only the Annotations @EnableJpaRepositories and @EntityScan

So hopefully a fix will come in near future :)

@sfbell09
Copy link

I fixed this issue with two main steps. First, I created an AppShell class, extending AppShellConfigurator. I put all the Vaadin related annotations from the app class into it. Next, I went into /.m2/repository and deleted everything. After doing that, I ran mvn clean install, which succeeded and then I ran the app with mvn spring-boot:run and it started up as expected.

@dolukhanov
Copy link

Moving @EnableJpaRepositories to another class with @configuration worked for me as a workaround using 24.4.10 - but would be nice for there to be a proper fix for this given the impact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Development

No branches or pull requests

7 participants