Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Define DataSource in META-INF/context.xml ?

 
Stephen Byrne
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stephen Byrne
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srikant Venkata,
Your post was moved to a new topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic