File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Define DataSource in META-INF/context.xml ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Define DataSource in META-INF/context.xml ?" Watch "Define DataSource in META-INF/context.xml ?" New topic
Author

Define DataSource in META-INF/context.xml ?

Stephen Byrne
Greenhorn

Joined: Aug 21, 2008
Posts: 2
(JBoss AS 4.2.2.GA)
(Oracle 10.2)

I currently define my DataSource in $JBOSS_HOME/server/default/deploy/oracle-ds.xml, which looks like this:

My web application (war packaged) WEB-INF/web.xml has:

And of course the corresponding WEB-INF/jboss-web.xml:

Which allows me to get a DataSource as follows:

This all works. However, I would prefer to define my DataSource in my web application's META-INF/context.xml as is done in (standalone) Tomcat, something like this:

I have been unable to get this to work. Does JBoss AS use the context.xml? If so, how do I define my DataSource there?

If I have simply missed the relevant section of the manual and somebody can point me to it, I would be grateful.
[ August 21, 2008: Message edited by: Stephen Byrne ]
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

That is not possible. The only way of defining a datasource is with a *-ds.xml file.

Is it that you prefer to deploy just a single file, rather than two files? If so, you could package the *.ds.xml and war files in an ear. You would need a META-INF/jboss-app.xml file to reference the *-ds.xml.


JBoss In Action
Stephen Byrne
Greenhorn

Joined: Aug 21, 2008
Posts: 2
Originally posted by Peter Johnson:
Is it that you prefer to deploy just a single file, rather than two files? If so, you could package the *.ds.xml and war files in an ear. You would need a META-INF/jboss-app.xml file to reference the *-ds.xml.


In addition to wanting to deal with only a single file I would like the DataSource pool stopped and started when I redeploy the application. Will that happen if I deploy with a .ear?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

That should get you what you want:

1) Single file to deploy - 100% confidence level

2) Datasource pool restarted on redeploy - 80% confidence level. If you do not change the *-ds.xml file and thus the timestamp remains the same, I am not sure if the datasource would actually be restarted, but a quick test should verify if it is (you'll see it in the console log, and if you are using PostgreSQL you should see a new set of processes). If the timestamp on the *-ds.xml file changes a restart is guaranteed.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9937
    
159

Srikant Venkata,
Your post was moved to a new topic.


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Define DataSource in META-INF/context.xml ?
 
Similar Threads
Whacky db problem.
Deploying with context config file
Accessing DBCP in RequestProcessor class
Tomcat application won't start with MySQL Connection Pooling
Jboss 4.2.3 how to change the default datasource to oracle ?