ninjaframework / ninja

Ninja is a full stack web framework for Java. Rock solid, fast and super productive.
http://www.ninjaframework.org
Apache License 2.0
1.91k stars 518 forks source link

Ninja properties are missing intermittently #714

Open ghost opened 3 years ago

ghost commented 3 years ago

We are currently using Ninja v6.5.0 (due to https://github.com/ninjaframework/ninja-appengine/tree/ninja-appengine-1.9.76 being the latest version for the Google App Engine dependency).

We have multiple endpoints defined in the Routes.java file that work 100% of the time in the deployed version and only work 80% of the time in the local development environment.

Calling those endpoints via our Anguluar frontend several times, we consistently get this error at some point:

[INFO] GCLOUD: 11:38:18.187 [qtp1105423942-18] ERROR ninja.utils.NinjaPropertiesImpl - Key application.cookie.prefix does not exist. Please include it in your application.conf. Otherwise this app will not work
[INFO] GCLOUD: 2021-04-30 13:38:18.195:WARN:oejs.HttpChannel:qtp1105423942-18: /api/locations
[INFO] GCLOUD: com.google.inject.ProvisionException: Unable to provision, see the following errors:<|<|1) Error injecting constructor, java.lang.RuntimeException: Key application.cookie.prefix does not exist. Please include it in your application.conf. Otherwise this app will not work<|  at ninja.session.FlashScopeImpl.<init>(FlashScopeImpl.java:42)<|  while locating ninja.session.FlashScopeImpl<|  while locating ninja.session.FlashScope<|    for the 2nd parameter of ninja.servlet.NinjaServletContext.<init>(NinjaServletContext.java:104)<|  while locating ninja.servlet.NinjaServletContext<|  while locating ninja.Context<|<|1 error
[INFO] GCLOUD:  at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226)
[INFO] GCLOUD:  at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053)
[INFO] GCLOUD:  at ninja.servlet.NinjaServletDispatcher.service(NinjaServletDispatcher.java:79)
[INFO] GCLOUD:  at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:290)
[INFO] GCLOUD:  at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:280)
[INFO] GCLOUD:  at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:184)
[INFO] GCLOUD:  at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:89)
[INFO] GCLOUD:  at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
[INFO] GCLOUD:  at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
[INFO] GCLOUD:  at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
[INFO] GCLOUD:  at ninja.servlet.NinjaServletFilter.doFilter(NinjaServletFilter.java:106)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
[INFO] GCLOUD:  at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
[INFO] GCLOUD:  at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
[INFO] GCLOUD:  at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
[INFO] GCLOUD:  at com.google.appengine.tools.development.jetty9.DevAppEngineWebAppContext.doScope(DevAppEngineWebAppContext.java:94)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
[INFO] GCLOUD:  at com.google.appengine.tools.development.jetty9.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:599)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
[INFO] GCLOUD:  at org.eclipse.jetty.server.Server.handle(Server.java:512)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:279)
[INFO] GCLOUD:  at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
[INFO] GCLOUD:  at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
[INFO] GCLOUD:  at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036)
[INFO] GCLOUD:  at java.lang.Thread.run(Thread.java:748)
[INFO] GCLOUD: Caused by: 
[INFO] GCLOUD: java.lang.RuntimeException: Key application.cookie.prefix does not exist. Please include it in your application.conf. Otherwise this app will not work
[INFO] GCLOUD:  at ninja.utils.NinjaPropertiesImpl.getOrDie(NinjaPropertiesImpl.java:249)
[INFO] GCLOUD:  at ninja.session.FlashScopeImpl.<init>(FlashScopeImpl.java:44)
[INFO] GCLOUD:  at ninja.session.FlashScopeImpl$$FastClassByGuice$$37ea5ae0.newInstance(<generated>)
[INFO] GCLOUD:  at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
[INFO] GCLOUD:  at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
[INFO] GCLOUD:  at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
[INFO] GCLOUD:  at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
[INFO] GCLOUD:  at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62)
[INFO] GCLOUD:  at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
[INFO] GCLOUD:  at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65)
[INFO] GCLOUD:  at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
[INFO] GCLOUD:  at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
[INFO] GCLOUD:  at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
[INFO] GCLOUD:  at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62)
[INFO] GCLOUD:  at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050)
[INFO] GCLOUD:  at ninja.servlet.NinjaServletDispatcher.service(NinjaServletDispatcher.java:79)
[INFO] GCLOUD:  at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:290)
[INFO] GCLOUD:  at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:280)
[INFO] GCLOUD:  at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:184)
[INFO] GCLOUD:  at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:89)
[INFO] GCLOUD:  at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
[INFO] GCLOUD:  at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
[INFO] GCLOUD:  at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
[INFO] GCLOUD:  at ninja.servlet.NinjaServletFilter.doFilter(NinjaServletFilter.java:106)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
[INFO] GCLOUD:  at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
[INFO] GCLOUD:  at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
[INFO] GCLOUD:  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
[INFO] GCLOUD:  at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
[INFO] GCLOUD:  at com.google.appengine.tools.development.jetty9.DevAppEngineWebAppContext.doScope(DevAppEngineWebAppContext.java:94)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
[INFO] GCLOUD:  at com.google.appengine.tools.development.jetty9.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:599)
[INFO] GCLOUD:  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
[INFO] GCLOUD:  at org.eclipse.jetty.server.Server.handle(Server.java:512)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
[INFO] GCLOUD:  at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:279)
[INFO] GCLOUD:  at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
[INFO] GCLOUD:  at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
[INFO] GCLOUD:  at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882)
[INFO] GCLOUD:  at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036)

application.conf of course has an application.cookie.prefix property defined that works correctly the rest of the time (and in production), so I don't believe the error is actually related to that file.

Has anyone else encountered this issue before?

thibaultmeyer commented 2 years ago

Hello @vpriesner,

version 6.5.0 is quite old, is it possible to migrate to version 6.8.1 of Ninja Framework?

Are you still experiencing the problem? If so, can you attach an empty project reproducing the problem you are experiencing in order to analyze more quickly what is wrong?

ghost commented 2 years ago

Hi @thibaultmeyer,

We'd love to upgrade, actually. We are currently being blocked by https://github.com/ninjaframework/ninja-appengine though. I'm trying to get that dependency upgraded right now (https://github.com/ninjaframework/ninja-appengine/issues/33), but I'm not getting a response there.