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 7646785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:17:49+00:00 2026-05-31T10:17:49+00:00

I’m running JBoss AS 7.1.0.CR1b. I’ve got several datasources defined in my standalone.xml e.g.

  • 0

I’m running JBoss AS 7.1.0.CR1b. I’ve got several datasources defined in my standalone.xml e.g.

        <subsystem xmlns="urn:jboss:domain:datasources:1.0">
            <datasources>
                <datasource jndi-name="java:/MyDS" pool-name="MyDS_Pool" enabled="true" use-java-context="true" use-ccm="true">
                    <connection-url>some-url</connection-url>
                    <driver>the-driver</driver>
                    [etc]

Everything works fine.

I’m trying to access the information contained here within my code – specifically the connection-url and driver properties.

I’ve tried getting the Datasource from JNDI, as normal, but it doesn’t appear to provide access to these properties:

// catches removed
InitialContext context;
DataSource dataSource = null;
context = new InitialContext();
dataSource = (DataSource) context.lookup(jndi);

ClientInfo and DatabaseMetadata from a Connection object from this Datasource also don’t contain these granular, JBoss properties either.

My code will be running inside the container with the datasource specfied, so all should be available. I’ve looked at the IronJacamar interface org.jboss.jca.common.api.metadata.ds.DataSource, and its implementing class, and these seem to have accessible hooks to the information I require, but I can’t find any information on how to create such objects with these already deployed resources within the container (only constructor on impl involves inputting all properties manually).

JBoss AS 7’s Command-Line Interface allows you to navigate and list the datasources as a directory system. http://www.paykin.info/java/add-datasource-programaticaly-cli-jboss-7/ provides an excellent post on how to use what I believe is the Java Management API to interact with the subsystem, but this appears to involve connecting to the target JBoss server. My code is already running within that server, so surely there must be an easier way to do this?

Hope somebody can help. Many thanks.

  • 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-31T10:17:50+00:00Added an answer on May 31, 2026 at 10:17 am

    What you’re really trying to do is a management action. The best way to is to use the management API’s that are available.

    Here is a simple standalone example:

    public class Main {
    
        public static void main(final String[] args) throws Exception {
            final List<ModelNode> dataSources = getDataSources();
            for (ModelNode dataSource : dataSources) {
                System.out.printf("Datasource: %s%n", dataSource.asString());
            }
        }
    
        public static List<ModelNode> getDataSources() throws IOException {
            final ModelNode request = new ModelNode();
            request.get(ClientConstants.OP).set("read-resource");
            request.get("recursive").set(true);
            request.get(ClientConstants.OP_ADDR).add("subsystem", "datasources");
            ModelControllerClient client = null;
            try {
                client = ModelControllerClient.Factory.create(InetAddress.getByName("127.0.0.1"), 9999);
                final ModelNode response = client.execute(new OperationBuilder(request).build());
                reportFailure(response);
                return response.get(ClientConstants.RESULT).get("data-source").asList();
            } finally {
                safeClose(client);
            }
        }
    
        public static void safeClose(final Closeable closeable) {
            if (closeable != null) try {
                closeable.close();
            } catch (Exception e) {
                // no-op
            }
        }
    
    
        private static void reportFailure(final ModelNode node) {
            if (!node.get(ClientConstants.OUTCOME).asString().equals(ClientConstants.SUCCESS)) {
                final String msg;
                if (node.hasDefined(ClientConstants.FAILURE_DESCRIPTION)) {
                    if (node.hasDefined(ClientConstants.OP)) {
                        msg = String.format("Operation '%s' at address '%s' failed: %s", node.get(ClientConstants.OP), node.get(ClientConstants.OP_ADDR), node.get(ClientConstants.FAILURE_DESCRIPTION));
                    } else {
                        msg = String.format("Operation failed: %s", node.get(ClientConstants.FAILURE_DESCRIPTION));
                    }
                } else {
                    msg = String.format("Operation failed: %s", node);
                }
                throw new RuntimeException(msg);
            }
        }
    }
    

    The only other way I can think of is to add module that relies on servers internals. It could be done, but I would probably use the management API first.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
i got an object with contents of html markup in it, for example: string
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.