[
https://issues.jboss.org/browse/WFLY-2898?page=com.atlassian.jira.plugin....
]
Eduardo Martins commented on WFLY-2898:
---------------------------------------
I tried to replicate your use case through:
{code:xml}
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<!-- ... -->
<datasource jndi-name="java:/MyDataSource"
pool-name="MyDataSource" enabled="true"
use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<!-- ... -->
</datasources>
</subsystem>
{code}
and
{code}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException {
try {
System.out.println(String.valueOf(InitialContext.doLookup("java:/MyDataSource")));
} catch (NamingException e) {
throw new ServletException(e);
}
}
{code}
and found no issue:
{code}
15:50:36,995 INFO [stdout] (default task-3)
org.jboss.jca.adapters.jdbc.WrapperDataSource@66ff90bd
{code}
Do you have anything else suspicious in the server log?
Note that what is in JNDI is an object factory, my guess is that the datasource setup is
not ok and then the object factory bound is not create the datasource instances as
expected.
Please provide a standalone.xml and a web app maven project that can be used to replicate
your issue.
JNDI Name lookup of the DataSource returns NULL
-----------------------------------------------
Key: WFLY-2898
URL:
https://issues.jboss.org/browse/WFLY-2898
Project: WildFly
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Naming, Web (Undertow)
Affects Versions: 8.0.0.CR1, 8.0.0.Final
Reporter: Igor Shulika
Assignee: Eduardo Martins
Hi,
I'm having a problem to obtain DataSource using JNDI Name lookup.
Please see my code below:
Connection connection = null;
DataSource dataSource = null;
try {
final Context initContext = new InitialContext();
dataSource = (DataSource) initContext.lookup("java:/MyDataSource");
connection = dataSource.getConnection();
} catch (Exception e) {
LOGGER.error(e);
}
I'm doing initContext.lookup from a servlet, everything is working on JBoss EAP
6.2.0.GA (AS 7.3.0.Final-redhat-14).
Also I can find and test connection of my “java:/MyDataSource” under the “Datasources”
section of the WildFly Administration Console just fine(anoter word the datasource is
there).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira