EAR Files: with or without Data Sources?

OC4J 10.1.3 allows you to include Data Source definitions with your EAR file. JDeveloper 10.1.3 automatically creates such EAR Files if you deploy to Oracle Application Server 10.1.3. But what if you don't want to include the database connect information in your EAR file?

In my opinion, data sources are useful for externalizing the database connections (development, test, production, ...) from the web application. I think it's best to use the same EAR file for all environments, and have different data source definitions in each environment. The data sources should have the same name of course, but connect to different databases.

In JDeveloper 10.1.3 I had defined an Application Server connection to our Development OC4J 10.1.3 instance, and discovered that the EAR files I created with JDeveloper deployment profiles always included data source definitions. That meant that I had to change the data sources in the Test and Production application servers after deploying this EAR file.

Fortunately, I also found a way to omit the data sources from the EAR file: remove all Application Server Connections from your JDeveloper 10.1.3 installation before creating the EAR file using a deployment profile. JDeveloper then cannot determine the type of application server you deploy to, and will not include the data source definitions.

Then it became much easier to use the same EAR file for all environments!

Comments:

Have you tried this for an application that uses toplink?

Posted by Charles Poulsen on November 29, 2006 at 12:04 PM PST #

Charles,

This applies to all EAR files that are deployed to an Oracle Application Server 10.1.3, no matter what technology is used. I used for a JHeadstart application using ADF Business Components, JSF and ADF Faces, but the deployment profile did not know that!

I'd like to add that the first time you deploy your application, when you have not created the application's data sources yet, it's very helpful to use an Application Server connection to deploy the EAR file, because then the data sources and connection pools are automatically created with the right names and values. Only afterwards, when you already have the right data sources and simply want to install a new version of the application, I find it easier to use an EAR file without data sources.

kind regards,

Posted by Sandra Muller on November 29, 2006 at 05:41 PM PST #

I also use the same data source name in both development and production but I turned off the option "Bundle Default data-sources.xml During Deployment" in Preferences | Deployment. That prevents the data sources from being bundled and overwritting existing ones.

Posted by Richard Wharton on December 15, 2006 at 06:16 AM PST #

Richard,

Thank you for this addition, I did not know this preference!

kind regards,

Posted by Sandra Muller on December 18, 2006 at 09:37 PM PST #

I did find out that when you have changed this preference, the data sources seem to be removed from embedded OC4J as well, and creation of a new data source for embedded OC4J seems to be disabled. That makes it difficult to test web applications that rely on data sources, so I think I prefer to go back to the method I described in the blog post.

Posted by Sandra Muller on May 10, 2007 at 12:18 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Java EE Consultants - JHeadstart, ADF, JSF

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today