Hi I’m building application with Vaadin 24. When I try to using my theme by adding a Theme annotation to my ApplicationServlet which extends VaadinServlet, production building fails in prepare-frontend.
Could not execute prepare-frontend goal.: Error occured during goal execution: Cannot invoke "java.lang.Class.isInterface()" because the return value of "org.reflections.Reflections.forClass(String, java.lang.ClassLoader[])" is null
My debug console output
java.lang.NoClassDefFoundError: jakarta/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (ClassLoader.java:1017)
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:712)
at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
at org.codehaus.plexus.classworlds.realm.ClassRealm.findClassInternal (ClassRealm.java:256)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf (ClassRealm.java:351)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:36)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:225)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:210)
at java.lang.ClassLoader.loadClass (ClassLoader.java:579)
at java.lang.ClassLoader.loadClass (ClassLoader.java:525)
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (ClassLoader.java:1017)
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:712)
at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
at java.lang.ClassLoader.loadClass (ClassLoader.java:592)
at java.lang.ClassLoader.loadClass (ClassLoader.java:525)
at com.vaadin.flow.server.scanner.ReflectionsClassFinder$LoggingReflections.forClass (ReflectionsClassFinder.java:172)
at org.reflections.Reflections.lambda$getTypesAnnotatedWith$12 (Reflections.java:405)
at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:178)
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 org.reflections.util.QueryFunction.lambda$filter$3 (QueryFunction.java:32)
at org.reflections.util.QueryFunction.lambda$add$9 (QueryFunction.java:66)
at org.reflections.util.QueryFunction.lambda$add$9 (QueryFunction.java:66)
at org.reflections.util.QueryFunction.lambda$asClass$13 (QueryFunction.java:89)
at org.reflections.Reflections.get (Reflections.java:365)
at org.reflections.Reflections.getTypesAnnotatedWith (Reflections.java:403)
at com.vaadin.flow.server.scanner.ReflectionsClassFinder.getAnnotatedClasses (ReflectionsClassFinder.java:87)
at com.vaadin.flow.server.frontend.scanner.ClassFinder$CachedClassFinder.lambda$getAnnotatedClasses$0 (ClassFinder.java:154)
at java.util.HashMap.computeIfAbsent (HashMap.java:1220)
at com.vaadin.flow.server.frontend.scanner.ClassFinder$CachedClassFinder.getAnnotatedClasses (ClassFinder.java:153)
at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.verifyTheme (FullDependenciesScanner.java:390)
at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.discoverTheme (FullDependenciesScanner.java:349)
at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:141)
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:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
Caused by: java.lang.ClassNotFoundException: jakarta.servlet.http.HttpServlet
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:225)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:210)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:205)
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (ClassLoader.java:1017)
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:712)
at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
at org.codehaus.plexus.classworlds.realm.ClassRealm.findClassInternal (ClassRealm.java:256)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf (ClassRealm.java:351)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:36)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:225)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:210)
at java.lang.ClassLoader.loadClass (ClassLoader.java:579)
at java.lang.ClassLoader.loadClass (ClassLoader.java:525)
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (ClassLoader.java:1017)
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:712)
at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
at java.lang.ClassLoader.loadClass (ClassLoader.java:592)
at java.lang.ClassLoader.loadClass (ClassLoader.java:525)
at com.vaadin.flow.server.scanner.ReflectionsClassFinder$LoggingReflections.forClass (ReflectionsClassFinder.java:172)
at org.reflections.Reflections.lambda$getTypesAnnotatedWith$12 (Reflections.java:405)
at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:178)
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 org.reflections.util.QueryFunction.lambda$filter$3 (QueryFunction.java:32)
at org.reflections.util.QueryFunction.lambda$add$9 (QueryFunction.java:66)
at org.reflections.util.QueryFunction.lambda$add$9 (QueryFunction.java:66)
at org.reflections.util.QueryFunction.lambda$asClass$13 (QueryFunction.java:89)
at org.reflections.Reflections.get (Reflections.java:365)
at org.reflections.Reflections.getTypesAnnotatedWith (Reflections.java:403)
at com.vaadin.flow.server.scanner.ReflectionsClassFinder.getAnnotatedClasses (ReflectionsClassFinder.java:87)
at com.vaadin.flow.server.frontend.scanner.ClassFinder$CachedClassFinder.lambda$getAnnotatedClasses$0 (ClassFinder.java:154)
at java.util.HashMap.computeIfAbsent (HashMap.java:1220)
at com.vaadin.flow.server.frontend.scanner.ClassFinder$CachedClassFinder.getAnnotatedClasses (ClassFinder.java:153)
at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.verifyTheme (FullDependenciesScanner.java:390)
at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.discoverTheme (FullDependenciesScanner.java:349)
at com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner.<init> (FullDependenciesScanner.java:141)
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:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
I’m sure I have a jakarta.servlet-api 6.1.0 dependency in my pom
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>
Everything goes well if I remove the @Theme annotation. I also using @Push in the ApplicationServlet and works well.