aspose file tools*
The moose likes JBoss/WildFly and the fly likes More than one applications in Jboss? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "More than one applications in Jboss?" Watch "More than one applications in Jboss?" New topic
Author

More than one applications in Jboss?

senthilkumar ap
Greenhorn

Joined: Dec 01, 2008
Posts: 19
Hi all,
Im a newbie to JBOSS, forgive me if it is a stupid question.

can i run more applications in JBOSS? if it is possible how can i relate the each application to separate database?
suggest me some documents for jboss which has these details..



Thanks all
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

Yes you can run multiple applications on a single server. Each application will configure and use its own datasource.

[My Blog] [JavaRanch Journal]
senthilkumar ap
Greenhorn

Joined: Dec 01, 2008
Posts: 19
thanks for your reply..
you meant "its own datasourse".. so i cant configure each application with its own "database"?
and could you suggest some documents or examples to how to configure?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

senthilkumar ap wrote:
you meant "its own datasourse".. so i cant configure each application with its own "database"?


Typically in a JavaEE environment, database access is done through datasources. However if you have some custom way of accessing a database, you can continue doing that. It's finally upto the application on how it connects to the right database (the connection url).


and could you suggest some documents or examples to how to configure?


See this

senthilkumar ap
Greenhorn

Joined: Dec 01, 2008
Posts: 19
Actually my application is Struts with Ejb integrated, i configure the database for the first application in postgres-ds.xml file.. so if want to run one more application configured with separate database or datasource then what should i do?
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
So you're accessing the database through a datasource, as described in the postgres-ds.xml file. If you look in that file, it will have an entry which specifies the JNDI Name for the datasource (note that the name of the file itself doesn't matter - it is the JNDI name inside the file that is used).

If you want another datasource that operates on a different database, just create another datasource file with a different JNDI name.

Then, in each application, just reference the correct datasource (by its JNDI name).

Note that multiple applications can certainly use the same datasource if you want them to. You don't have to have a different datasource for each application. However, if each application really uses a different database, then you will need to have separate datasource files.

senthilkumar ap
Greenhorn

Joined: Dec 01, 2008
Posts: 19
Thanks your reply, i understood what you are coming to say.. so i can create another one file which may have the name like postgres1-ds.xml and i can specify the different JNDI name there.. am i right?
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
senthilkumar ap wrote:Thanks your reply, i understood what you are coming to say.. so i can create another one file which may have the name like postgres1-ds.xml and i can specify the different JNDI name there.. am i right?

That's right. You can create as many as you like.

Also, if you have two applications which need to access the same database, they can share a datasource if you like - or use separate datasources if you need that for some reason.
senthilkumar ap
Greenhorn

Joined: Dec 01, 2008
Posts: 19
Again Thanks,
Could you tell how the JBOSS will pick up postgres-ds.xml's if i have more than one? will it read every postgres-ds compulsorily ?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

You can have multiple *-ds.xml files (hence the use of the term "*-ds.xml" to describe them). You can name them anything you like (for example, one-ds.xml, two-ds.xm, etcl) but a typically recommended pattern is to include the database type, and at times the database name or datasource name, in the file name (example: postgresql-accounting-ds.xml). Note that this naming convention is preferred over numbering the files; in other words I recommend against using postgreslq1-ds.xml, postgresql2-ds.xml, etc. Not that it would not work, but by using a more descriptive name you can tell them apart more easily.

The application server will open and deploy every *-ds.xml file in the deploy directory.


JBoss In Action
senthilkumar ap
Greenhorn

Joined: Dec 01, 2008
Posts: 19
Thanks Peter Johnson ,Mark E Hansen and Jaikiran Pai,
Finally i got what i was looking for, bec of you all,

Thanks again

Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
Remember to mark your topic as Resolved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: More than one applications in Jboss?