1 Reply Latest reply on Sep 6, 2011 9:53 AM by smarlow

    Multiple Persistence Units & DataSources for one App

    subhraroy

      This is a continuation from http://community.jboss.org/message/623828#623828

       

      As suggested by Scott I am starting a new discussion.

       

      Our requirement is to be able to dynamically create persistence managers and attach datasources on the fly to the managers further depending on context we can have more than one providers for our app. So we want full control on the persistence manager configuration and initialization etc. Currently AS7 is trying to instanciate the persistence provider on the startup of the app. We would like to avoid that.

       

      Problem 1

      AS7 tries to initialize the persistence.xml on app startup and I could not find a way from stopping it from doing that. Even after renaming the file to x-persistence.xml  AS7 is still trying to configure the persistence manager.

       

      Observations

      1) If the file name is kept as persistence.xml it tries to use the inbuilt provider and then tries to process the one specified in the xml and throws error saying one app can have only one provider.

       

      2) When the xml is renamed it does load the specified provider from the xml. But it still does not allow more than one provider per app and still manages to find the config and tries to load the persistence provider.

       

      Problem 2

      AS7 mandates that the persitence.xml have the datasource fixed during deploy time and throws error if the <jta (non-jta) - data source> tags are missing in the xml. What we have is a platform which alows multiple different apps to startup and collaborate and thus we can only know this in runtime.

       

      What we require

      1) AS7 to allow more than one persistance provider per app.

      2) Way to configure AS7 so that it does not try to automatically instanciate the providers.

      3) AS7 should not mandate that the datasouce be bound statically to the provider.

       

      Insight on our requirement:

      What we have is a platform where web applications can be built, deployed, managed, executed. Building an application is more like configuring and based on the configuration the platform gives a feel of virtual applications. (Technically speaking only one app is running on the server). The customer base can be managed through this platform. Data sources configured. Thus one "virtual app" can have more than one data source (per customer) in some cases. As well as virtual apps will have different providers / entity managers / data sources. All this is dynamic based on the platform (our app) configuration. We have multiple ways of deploying. We have achieved this functionality in Embedded Tomcat/Jetty, Osgi-Equinox-embedded tomcat, Tomcat,Jetty, so far. We were trying out AS7 as our next possible deployment when we got stuck on these problems.

       

      I hope I could make sense and thanks to all for taking time to help us resolve these problems.

       

      Regards,