<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Multiple Persistence Units & DataSources for one App
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/subhraroy">Subhra Roy</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/message/624720#624720">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>This is a continuation from <a class="jive-link-message-small" href="http://community.jboss.org/message/623828#623828">http://community.jboss.org/message/623828#623828</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>As suggested by Scott I am starting a new discussion.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="text-decoration: underline;">Problem 1</span></p><p>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&#160; AS7 is still trying to configure the persistence manager. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="text-decoration: underline;">Observations</span></p><p>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. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="text-decoration: underline;">Problem 2</span></p><p>AS7 mandates that the persitence.xml have the datasource fixed during deploy time and throws error if the &lt;jta (non-jta) - data source&gt; 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. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="text-decoration: underline;">What we require</span></p><p>1) AS7 to allow more than one persistance provider per app.</p><p>2) Way to configure AS7 so that it does not try to automatically instanciate the providers.</p><p>3) AS7 should not mandate that the datasouce be bound statically to the provider.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="text-decoration: underline;">Insight on our requirement</span>:</p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I hope I could make sense and thanks to all for taking time to help us resolve these problems.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Regards,</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/624720#624720">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>