Hi Richard, I assume the exception happens within BaseContext.attachToRuntimeIfNeeded(). This whole business of attaching to runtime is a hack for auto-deserialization of the context in certain environments. Tomcat does HttpSession serialization for the purpose of session clustering (and addressing restarts). Jetty does not. IMO clustering of Java sessions is a losing battle, and doesn't scale well anyways. I'd recommend to just turn it off [1].
There may be more steps to integrating Cayenne and Tapestry (such as implementing ValueEncoder<Persistent>), but not having to deal with serialized sessions is definitely step #1 :) Andrus [1] https://tomcat.apache.org/tomcat-8.5-doc/config/manager.html#Disable_Session_Persistence > On Jun 23, 2022, at 11:41 PM, Richard Frovarp <rfrov...@apache.org> wrote: > > I'm using Cayenne 4.1 in the integration I took over to make it just work > with Apache Tapestry. I'm getting: > > Can't attach to Cayenne runtime. Null injector returned from > CayenneRuntime.getThreadInjector() > > The really confusing part is that it works just fine in Jetty, and it > sometimes works in Tomcat. With one project it usually doesn't work in > Tomcat, and in another it appears to work just fine. > > So I'm really confused as to what is going on. Watching through an attached > debugger, I don't see why it is or isn't using a runtime that already has the > injector provided. The integration was created by more talented people than > me for Cayenne 3.0, and I see this injector stuff is starting from 3.1. So > I'm probably missing something. > > I saw a previous post to the list talking about adding a filter, but that > doesn't seem to match what I need here. I probably do need to change the > service that is creating the contexts to always setup an injector?? > > Any pointers are appreciated. > > Richard