Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can configure application scoped resources for the <strong>jdbc-connection-pool</strong> and <strong>jdbc-resource</strong> inside the <em>glassfish-resources.xml</em> and when you deploy your WAR file they will be created. When you undeploy your WAR they will go away. That solves the problem of manually adding them with asadmin. What I usually do it set it up manually using the GUI, then copy and paste the <code>&lt;jdbc-connection-pool&gt;</code> and <code>&lt;jdbc-resource&gt;</code> elements from the <em>domain.xml</em> into <em>glassfish-resources.xml</em> then I change the jndi-name to be application scoped, for example:</p> <pre><code>&lt;jdbc-resource pool-name="MyAppPool" jndi-name="java:app/jdbc/my-app-pool"&gt;&lt;/jdbc-resource&gt; </code></pre> <p>Then I make sure <em>glassfish-resources.xml</em> is packaged into the appropriate place in the WAR file, namely in the <strong>WEB-INF</strong> folder.</p> <p>From what I have read in the Oracle documentation for Glassfish 4 it does not appear that you can package the auth-realm configuration with the application like you can for the JDBC stuff. I have filed an enhancement request for this <a href="https://java.net/jira/browse/GLASSFISH-20874" rel="nofollow">glassfish auth-realm packaging enhancement</a> It only appears that you can package the association to the realm in various deployment descriptors, see the "How to set a realm for an Application or Module" section of this <a href="https://glassfish.java.net/docs/4.0/application-development-guide.pdf" rel="nofollow">guide</a> for details.</p> <p><strong>HACK Alert</strong></p> <p>Actually I just thought of something which is a bit of a hack but might work around this issue. You could create a simple web APP which includes your real applications WAR file in it (in a resource directory). This wrapper app would include a REST client (like Jersey client) which would make REST calls to the Glassfish administration REST API to see if the auth-realm is there and configured. If it is it would use the REST API to deploy the embedded WAR file. If it isn't it would use the REST API to create the auth-realm and then it would deploy the WAR.</p> <p>I'm not quite clear on the issues you are having with schema generation but that's all supported via the persistence.xml and works fine. If you want even more functionality in the way of automatic migration scripting then I would look at integrating a package like <a href="http://flywaydb.org" rel="nofollow">FlyAway</a></p> <p>Here's an example of a glassfish-resources.xml file with app scoped resources which works for me under Glassfish 3.1.2. Some of the attributes you have I don't and I also don't use a JDBC JNDI naming style for the pool-name on the jdbc-resource. </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd"&gt; &lt;resources&gt; &lt;jdbc-connection-pool validation-table-name="TABLEVALIDATION" allow-non-component-callers="true" statement-cache-size="200" associate-with-thread="true" statement-timeout-in-seconds="300" non-transactional-connections="true" connection-leak-reclaim="true" lazy-connection-association="true" connection-creation-retry-attempts="12" lazy-connection-enlistment="true" validate-atmost-once-period-in-seconds="120" statement-leak-timeout-in-seconds="360" datasource-classname="oracle.jdbc.pool.OracleDataSource" res-type="javax.sql.DataSource" connection-leak-timeout-in-seconds="420" statement-leak-reclaim="true" name="UnitTestPool" is-connection-validation-required="true"&gt; &lt;property name="DataSourceName" value="OracleDataSource"&gt;&lt;/property&gt; &lt;property name="ImplicitCachingEnabled" value="false"&gt;&lt;/property&gt; &lt;property name="NetworkProtocol" value="tcp"&gt;&lt;/property&gt; &lt;property name="DatabaseName" value="unittestdb"&gt;&lt;/property&gt; &lt;property name="LoginTimeout" value="0"&gt;&lt;/property&gt; &lt;property name="Password" value="tester"&gt;&lt;/property&gt; &lt;property name="URL" value="jdbc:oracle:thin:@testbed:1521:xe"&gt;&lt;/property&gt; &lt;property name="User" value="testertester"&gt;&lt;/property&gt; &lt;property name="PortNumber" value="1521"&gt;&lt;/property&gt; &lt;property name="ExplicitCachingEnabled" value="false"&gt;&lt;/property&gt; &lt;property name="dynamic-reconfiguration-wait-timeout-in-seconds" value="960"&gt;&lt;/property&gt; &lt;property name="MaxStatements" value="0"&gt;&lt;/property&gt; &lt;/jdbc-connection-pool&gt; &lt;jdbc-resource pool-name="UnitTestPool" jndi-name="java:app/jdbc/unittestdb-pool"&gt;&lt;/jdbc-resource&gt; &lt;/resources&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload