This is again, getting to the right answer for the wrong reason. You could keep these code bases separate whether they run in the same JVM in one container or in separate JVMs in different containers. As long as you enforce communication over something like REST, you will never have a problem.
In fact, the application was already written this way and it was never enforced. This makes no sense to enforce if it wasn't already broken.