How do I set java:comp/DefaultDataSource in WildFly?

Archimedes Trajano

According to the JEE spec, there should be a default data source provided to applications using java:comp/DefaultDataSource. WildFly out of the box will provide that data source as per the spec.

What I can't seem to find is a way of changing the value to point somewhere else without changing the java:comp/DefaultDataSource mapping on the application itself.

Under "Container" -> "JPA Subsystem" there's a Default DataSource which I have tried setting, but the connection still goes to the java:jboss/datasources/ExampleDS

@Resource(name = "somedatasource", lookup = "java:comp/DefaultDataSource")
private DataSource ds;

One thing to note, I am not using JPA for the application, I just wanted to get the default data source and use raw JDBC calls as I am working with a lot of LOB data and dynamic table names and it is more only possible on raw JDBC.

The way I test it is

System.out.println(ds.getConnection().getMetaData().getURL());

Which yields jdbc:h2:mem:test

Steve C

Open your standalone.xml in your favourite editor and locate the line in the urn:jboss:domain:ee:2.0 subsystem that says:

<default-bindings
   context-service="java:jboss/ee/concurrency/context/default"
   datasource="java:jboss/datasources/ExampleDS"
   jms-connection-factory="java:jboss/DefaultJMSConnectionFactory"
   managed-executor-service="java:jboss/ee/concurrency/executor/default"
   managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default"
   managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>

and set the datasource value to the physical datasource name that you would like to be mapped to java:comp/DefaultDataSource.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I make JNDI names compatible with both GlassFish and WildFly

From Dev

How do I set the Java options for Kafka?

From Dev

How do I set extension to protobuf DynamicMessage in java?

From Dev

Java: How do I set a color in a child class?

From Dev

How do I set up a scanner object in JAVA?

From Dev

How do I get Wildfly to use additional Jackson Datatypes?

From Dev

How do I set up a Java Apache Derby database in Intellij?

From Dev

How do I set Java options in SBT for the test configuration only?

From Dev

How do I enable on-the-fly compilation of JSPs in Wildfly 9?

From Dev

How do I encrypt the bindCredential password in Wildfly?

From Dev

How do I set the isolation level of transaction of Postgres from Java?

From Dev

How do I connect a STOMP client to Wildfly?

From Dev

How do I set $PATH?

From Dev

How do I handle an empty java set of strings in AWS DynamoDB

From Dev

Wildfly 9 - How do I exclude Jackson

From Dev

Java: How do I set the nonce when using DRBG SecureRandom?

From Dev

How Does Java Set It's Path and How Do I Change It?

From Dev

How can I set context path in spring boot jboss/wildfly?

From Dev

How do I set NetBeans as the default for .java files?

From Dev

How do I get Wildfly to use additional Jackson Datatypes?

From Dev

How do I automatically set a directory and create a new file in java?

From Dev

Wildfly 9 - How do I exclude Jackson

From Dev

How do i set in android studio the Set JDK_HOME and JAVA_HOME environment variables?

From Dev

How do i convert a Set into 2D array in java?

From Dev

How do I specify a Wildfly server version when using wildfly-maven-plugin?

From Dev

How do I set the variable to an incoming argument in java?

From Dev

How do i set the requestPayloadType parameter to a HashMap using Java DSL

From Dev

How do I set java version for a particular sonarlint scan?

From Dev

how can i do for an MDB to deploy last on my wildfly

Related Related

  1. 1

    How do I make JNDI names compatible with both GlassFish and WildFly

  2. 2

    How do I set the Java options for Kafka?

  3. 3

    How do I set extension to protobuf DynamicMessage in java?

  4. 4

    Java: How do I set a color in a child class?

  5. 5

    How do I set up a scanner object in JAVA?

  6. 6

    How do I get Wildfly to use additional Jackson Datatypes?

  7. 7

    How do I set up a Java Apache Derby database in Intellij?

  8. 8

    How do I set Java options in SBT for the test configuration only?

  9. 9

    How do I enable on-the-fly compilation of JSPs in Wildfly 9?

  10. 10

    How do I encrypt the bindCredential password in Wildfly?

  11. 11

    How do I set the isolation level of transaction of Postgres from Java?

  12. 12

    How do I connect a STOMP client to Wildfly?

  13. 13

    How do I set $PATH?

  14. 14

    How do I handle an empty java set of strings in AWS DynamoDB

  15. 15

    Wildfly 9 - How do I exclude Jackson

  16. 16

    Java: How do I set the nonce when using DRBG SecureRandom?

  17. 17

    How Does Java Set It's Path and How Do I Change It?

  18. 18

    How can I set context path in spring boot jboss/wildfly?

  19. 19

    How do I set NetBeans as the default for .java files?

  20. 20

    How do I get Wildfly to use additional Jackson Datatypes?

  21. 21

    How do I automatically set a directory and create a new file in java?

  22. 22

    Wildfly 9 - How do I exclude Jackson

  23. 23

    How do i set in android studio the Set JDK_HOME and JAVA_HOME environment variables?

  24. 24

    How do i convert a Set into 2D array in java?

  25. 25

    How do I specify a Wildfly server version when using wildfly-maven-plugin?

  26. 26

    How do I set the variable to an incoming argument in java?

  27. 27

    How do i set the requestPayloadType parameter to a HashMap using Java DSL

  28. 28

    How do I set java version for a particular sonarlint scan?

  29. 29

    how can i do for an MDB to deploy last on my wildfly

HotTag

Archive