Persistence units in persistence.xml are created during building the application. As I want to change the database url at runtime, is there any way to modify the persistence
In Long-lived Session Architecture you should create a Plug-in-Framework.
Therefore you need to create a different Thread-Group and Class-Repository.
This might be your Class-Loader-Tree
persistence.xml inside, specify the Database-Configuration from Application-Class-Loader