Configuring Java EE default resources
You can use the administrative console or wsadmin commands to configure bindings for Java™ Platform Enterprise Edition (Java EE) default resources.
About this task

The Java EE specification defines six default resources, which the product
provides in its default configuration. You configure a Java EE default resource provider by binding
the Java Naming and Directory Interface (JNDI) name for a default resource to the JNDI name of a
configured resource. For example, you can bind java:comp/DefaultDataSource to a
data source that is configured in the product.newfeat
- Java EE default resources
- Configure a Java EE default resource provider using the administrative console.
- Example: code that shows how an application can find a default resource
- Configure properties of a default resource.
Resource class | Java EE JNDI name | WebSphere resource type |
---|---|---|
javax.sql.DataSource | java:comp/DefaultDataSource | JDBC Data Source |
javax.enterprise.concurrent.ContextService | java:comp/DefaultContextService | Work Manager |
javax.enterprise.concurrent.ManagedExecutorService | java:comp/DefaultManagedExecutorService | Work Manager |
javax.enterprise.concurrent.ManagedScheduledExecutorService | java:comp/DefaultManagedScheduledExecutorService | Work Manager |
javax.enterprise.concurrent.ManagedThreadFactory | java:comp/DefaultManagedThreadFactory | Work Manager |
javax.jms.ConnectionFactory | java:comp/DefaultJMSConnectionFactory | JMS Connection Factory |
Procedure
Example
The following code examples show how an application can find a default resource.
- Lookup that uses @Resource
injection
@Resource(lookup = "java:comp/DefaultDataSource") DataSource defaultDatasource;
- JNDI
lookup
DataSource defaultDs = (DataSource) new InitialContext().lookup("java:comp/DefaultDataSource");
- @Resource annotation without the lookup, which defaults to the corresponding
JNDI name defined by the Java EE
specification
@Resource DataSource defaultDatasource;
What to do next
You can configure the properties of a resource to which a Java EE default resource is bound. For example, suppose java:comp/DefaultDataSource is bound to jdbc/myDatasource and you want to set the maximum pool size of java:comp/DefaultDataSource to 10. To do this, set the maximum pool size of jdbc/myDataSource to 10. For information on how to modify properties of various resources, see the related links.