Hello Try follow pattern:
java:openejb/Resource/MySqlDS where MySqlDS is the name of your DS. Att, Elton Kuzniewski Analista de Sup. Desenvolvimento e Arquitetura CSM, SCJA, SCJP 5, SCWCD 5, SCBCD 5 Pesquisa & Desenvolvimento Softplan/Poligraph + 55 48 3027-8000 www.softplan.com.br -----Mensagem original----- De: laredotornado [mailto:[email protected]] Enviada em: terça-feira, 4 de setembro de 2012 18:16 Para: [email protected] Assunto: What JNDI name does a datasource get bound to? Hi, I'm using OpenEJB 4.0.0. When I use openEjb to create a datasource, what JNDI name does it get bound to? When I create my datasource as recommended by the documentation … final Properties p = new Properties(); p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); p.setProperty("openejb.deployments.classpath.include", ".*"); p.put("openejb.descriptors.output", "true"); // Inject data source final Properties props = loadMyProjectProps(); final String dsJndiName = props.getProperty("DATASOURCE_JNDI_PREFIX") + "MySqlDS"; System.out.println("ds jndi name:" + dsJndiName); p.put(dsJndiName, "new://Resource?type=DataSource"); p.put(dsJndiName + ".JdbcDriver", "com.mysql.jdbc.Driver"); final String url = "jdbc:mysql://" + props.getProperty("DB_SERVER") + ":" + props.getProperty("DB_PORT") + "/" + props.getProperty("DB_NAME"); p.put(dsJndiName + ".JdbcUrl", url); p.put(dsJndiName + ".Username", props.getProperty("DB_USER")); p.put(dsJndiName + ".Password", props.getProperty("DB_PASSWORD")); p.put(dsJndiName + ".JtaManaged", "true"); final InitialContext initialContext = new InitialContext(p); it doesn't seem to get bound to any JNDI name. I verify this by listing everything in my context (and through OpenEJB debugging) … System.out.println("initial context jndi names:"); NamingEnumeration<NameClassPair> list = initialContext.list(""); while (list.hasMore()) { final NameClassPair ncp = list.next(); System.out.println("\tname:" + ncp.getName() + " class:" + ncp.getClassName()); } System.out.println("========================"); Nothing is listed for my datasource, whose JNDI name in the above example happens to be "java:MySqlDS". Thanks for any advice, - Dave -- View this message in context: http://openejb.979440.n4.nabble.com/What-JNDI-name-does-a-datasource-get-bound-to-tp4657277.html Sent from the OpenEJB User mailing list archive at Nabble.com.
