Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6987941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:00:18+00:00 2026-05-27T19:00:18+00:00

I have an ear that use a datasource (for a JPA persistence unit). Now

  • 0

I have an ear that use a datasource (for a JPA persistence unit).
Now I need to deploy multiple versions of this ear in the same jboss, each pointing to a different database.

How can I handle this.

I’ve seen that it’s not enough to deploy the datasource xml file inside the ear, with different parameters in each ear (jdbc url/user/password) since the datasource is globally scoped and will be shared by all the ears.

Do I need to use a different datasource name for each ear and to change the persistence.xml file for each deployment? Isn’t there any other option?

I’m using JBoss 6.

Edit: Some more details
As I said the datasource is used for a JPA persistence unit, but I didn’t mention that the same datasource is used directly inside several classes that need to do direct jdbc access. So changing the name of the datasource isn’t a good option.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:00:19+00:00Added an answer on May 27, 2026 at 7:00 pm

    I think there isn’t any option to do this. JBoss AS always scopes data sources globally. There would theoretically be the @DataSourceDefinition or data-source element in application.xml that can be app scoped.

    Unfortunately, this one doesn’t seem to work in JBoss AS 6 at all and even if it would work, it was stated by Jaikiran Pai that such a data source is not allowed to be used for a persistence unit anyway.

    See http://community.jboss.org/thread/161032 and https://issues.jboss.org/browse/JBAS-8816

    But if you’re already putting different *-ds.xml files inside each EAR, then it wouldn’t be that bad to also put a different persistence.xml inside each one, would it? At least you have the indirection that the persistence unit offers you. It would be worse if the data source name would be used directly at many places inside the EAR.

    It’s probably not an option, but just in case, GlassFish does allow embedded data sources to be app scoped.

    If you’re interested in this feature for JBoss AS, you might want to express this here: http://community.jboss.org/message/642506

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple (8) WAR files and 1 EAR file that I want to
I have a code that sounds like this: thread 1 now = rdtsc(); for_each_member_in_a_list
I have 2 ejbs. Ejb-A that calls Ejb-B. They are not in the same
I have deployed a web service with Jax-ws that use a database for storing
I have a Java EE web application that does not make use of EJBs.
I have a few separate application projects (EARs) with multiple EJBs that I want
I have a EAR package that contains a web module and EJB. The EJB
I have an .ear file (an archive file like tar / zip) that has
So I have an EAR that contains all of my modules. The shared JARs
I have a web application that is deployed on WebSphere and that use one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.