I doubt the OP would mind building a J2EE project from scratch to solve a novel problem. But nobody does that -- usually if there is a J2EE job, it's maintenance, which can be less interesting. And if there is a novel problem, it will likely be solved with the current status quo ("modern") technology.
For me it's couple of things:
My experience has been that newer languages and frameworks tend to be more user friendly. In particular, I tend to enjoy the abstraction and design aspects of programming more than the nuts and bolts technology aspects. So, for example, I find the low level aspects (e.g. memory management) of C annoying and I appreciate that React lets me use all of the abstractions that a programming language provides to define UI.
I tend to like functional programming techniques and dislike object oriented ones. FP techniques seem to be popular with the current generation of tech while the previous generation seems to have been dominated by OO. Of course that's not true in every domain and could change in the future.
This is a stereotype, but I tend to associate older tech stacks with companies that are more conservative, less innovative/more established, and/or less technology focused.
Finally, like you guys have mentioned, newer tech is associated with less maintenance work and greater future job prospects; even if that's just signaling as opposed to being inherent to the technologies themselves.
I wrote my comment because I felt some disingenuity in the OP saying that jobs with modern tech stacks are interesting for him. It means that he's either genuinely intersted in following the tech frameworks threadmill, and jobs with modern tech stack allow him to do that - or, he's lying to himself that he's intersting in it, to make getting up for work every day a little bit easier.
I always wonder why using a modern tech is interesting? Let's say there's a job where you're using J2EE 1.4 or some other outdated technology from the early 2000s. The thing is, I remember when that technology was hot shit and people considered working on it very interesting. So, it looks like, over the course of time, doing the very same task, with the same day-to-day activities, went from interesting to uninteresting?