Error Initializing application with REST API

Hello,

I just installed the REST API module and now
I have an error when the application initializes. I can’t find the source of the problem. Thank you for your help !

08:47:06.232 INFO c.h.c.c.s.CubaThreadPoolTaskScheduler - Initializing ExecutorService ‘scheduler’
08:47:06.559 INFO c.h.cuba.core.sys.jmx.MBeanExporter - Registering beans for JMX exposure: [app.cuba:type=ConfigStorage, app.cuba:type=CachingFacade, app.cuba:type=FileUploading, app.cuba:type=JmxNodeIdentifier, app.cuba:type=JmxLogControl, app.cuba:type=ClassLoaderManager, app.cuba:type=StatisticsCounter]
08:47:06.642 INFO c.h.cuba.core.sys.MetadataImpl - Initializing metadata
08:47:06.803 WARN c.h.cuba.core.sys.MetaModelLoader - Class de.diedavids.cuba.entitysoftreference.EntitySoftReferenceConverter is not loaded into metadata
08:47:06.803 WARN c.h.cuba.core.sys.MetaModelLoader - Class de.diedavids.cuba.entitysoftreference.EntitySoftReferenceConverter is not loaded into metadata
08:47:07.014 INFO c.h.cuba.core.sys.MetadataImpl - Metadata initialized in 372 ms
08:47:07.133 INFO c.h.a.r.a.r.RestAPIDispatcherServlet - Initializing Servlet ‘rest_api’
08:47:08.522 INFO c.h.a.r.a.r.RestAPIDispatcherServlet - Completed initialization in 1389 ms
08:47:08.531 ERROR c.h.c.c.s.AbstractWebAppContextLoader - Error initializing application
java.lang.NullPointerException: null
at com.haulmont.addon.restapi.init.RestAPIServletInitializer.init(RestAPIServletInitializer.java:60) ~[restapi-rest-api-7.2.0.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:305) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:190) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:153) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at com.haulmont.cuba.core.sys.EventsImpl.publish(EventsImpl.java:33) ~[cuba-global-7.2.4.jar:7.2.4]
at com.haulmont.cuba.web.sys.WebEvents.publish(WebEvents.java:36) ~[cuba-web-7.2.4.jar:7.2.4]
at com.haulmont.cuba.core.sys.AbstractWebAppContextLoader.contextInitialized(AbstractWebAppContextLoader.java:92) ~[cuba-global-7.2.4.jar:7.2.4]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4685) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) ~[catalina.jar:9.0.27]
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1133) ~[catalina.jar:9.0.27]
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1867) ~[catalina.jar:9.0.27]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-util.jar:9.0.27]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118) ~[na:na]
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1045) ~[catalina.jar:9.0.27]
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:429) ~[catalina.jar:9.0.27]
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576) ~[catalina.jar:9.0.27]
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[catalina.jar:9.0.27]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-util.jar:9.0.27]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.27]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) ~[catalina.jar:9.0.27]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.27]
at org.apache.catalina.startup.Catalina.start(Catalina.java:633) ~[catalina.jar:9.0.27]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) ~[bootstrap.jar:9.0.27]
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) ~[bootstrap.jar:9.0.27]
08:47:08.534 INFO c.h.c.c.s.CubaThreadPoolTaskScheduler - Shutting down ExecutorService ‘scheduler’
mai 11, 2020 8:47:08 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Un ou plusieurs écouteurs n’ont pas pu démarrer, les détails sont dans le fichier de log du conteneur
mai 11, 2020 8:47:08 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Erreur de démarrage du contexte [/app] suite aux erreurs précédentes
mai 11, 2020 8:47:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: L’application web [app] semble avoir démarré un thread nommé [ClientCacheManager-pool-5-thread-1] mais ne l’a pas arrêté, ce qui va probablement créer une fuite de mémoire; la trace du thread est:
java.base@11.0.7/jdk.internal.misc.Unsafe.park(Native Method)
java.base@11.0.7/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
java.base@11.0.7/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
java.base@11.0.7/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
java.base@11.0.7/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base@11.0.7/java.lang.Thread.run(Thread.java:834)
mai 11, 2020 8:47:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Le déploiement du répertoire [/home/strai1/Documents/Cuba_Sources/PerformanceCenter/deploy/tomcat/webapps/app] de l’application web s’est terminé en [4 898] ms
mai 11, 2020 8:47:08 AM org.apache.coyote.AbstractProtocol start
INFO: Démarrage du gestionnaire de protocole [“http-nio-8080”]
mai 11, 2020 8:47:08 AM org.apache.coyote.AbstractProtocol start
INFO: Démarrage du gestionnaire de protocole [“ajp-nio-8009”]
mai 11, 2020 8:47:08 AM org.apache.catalina.startup.Catalina start
INFO: Le démarrage du serveur a pris [14 948] millisecondes

an idea ?
Thanks

Hi,
I would suspect that this is an induced error, because NPE is thrown in the code line where variables should not be null under normal server startup conditions.
Are you sure there are no other error messages in Tomcat logs? You need to check all Tomcat log files: localhost.log, catalina.log, catalina.out (console std out).

Hello Alex,
Thank you for your reply. You put me on the right track.
I had a problem in my web.xml.
There were filters that I removed and the problem seems to be resolved.
I don’t know why they were there.
I no longer have an error when starting tomcat.

Thanks again for your help :+1:

 <filter>
        <filter-name>restSpringSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <param-name>contextAttribute</param-name>
            <param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.rest_api</param-value>
        </init-param>
        <init-param>
            <param-name>targetBeanName</param-name>
            <param-value>springSecurityFilterChain</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>restSpringSecurityFilterChain</filter-name>
        <url-pattern>/rest/*</url-pattern>
    </filter-mapping>