This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Properties props = new Properties(); | |
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); | |
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); | |
props.put(Context.PROVIDER_URL, "jnp://localhost:1099"); | |
try { | |
Context ctx = new InitialContext(props); | |
DataSource ds = (DataSource) ctx.lookup("java:jboss/datasources/ConcordeDS"); | |
connection = ds.getConnection(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.omega.war:main" from Service Module Loader
Thanks to this link, the solution is quite simple, only put the INITIAL_CONTEXT_FACTORY to org.jboss.as.naming.InitialContextFactory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Properties props = new Properties(); | |
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory"); | |
try { | |
Context ctx = new InitialContext(props); | |
DataSource ds = (DataSource) ctx.lookup("java:jboss/datasources/ConcordeDS"); | |
connection = ds.getConnection(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |