How did you bind dsName in comp/env - this is not the default? A quick solution for you is to configure the full jndi path instead of just the ds name and lookup openejb:Resource/dsName or java:openejb/Resource/dsName. Le 18 nov. 2015 07:44, "mean_bcp" <[email protected]> a écrit :
> I'm having a problem very similar to > > http://tomee-openejb.979440.n4.nabble.com/JNDI-Global-resources-and-EJB-JAR-td4663113.html > , > however I am not explicitly creating Threads. > > I'm using a MDB in the ejb.jar, and within the MDB attempting to do a DB > resource lookup which is failing. This same resource lookup works from > within my web app which is deployed in the same ear. I have tried to > declare > the resource in a resources.xml file, and when that failed, declared it in > tomee.xml. > > The lookup code below is common code used for both the web app and the EJB. > It works in one place, but not the other. Logs show that the webapp finds > the resource in comp/env, while the EJB does not find it in either. > > Context initCtx = new InitialContext(); > String dsName = props.getProperty("db.datasource"); > DataSource d = null; > try { > String s = "java:comp/env/" + dsName; > log.info("Looking up datasource named " + s); > d = (javax.sql.DataSource) initCtx.lookup(s); > log.info("Successfully found datasource named " + > s); > } catch (NamingException e) { > String s = "java:global/" + dsName; > log.info("Looking up datasource named " + s); > d = (javax.sql.DataSource) initCtx.lookup(s); > log.info("Successfully found datasource named " + > s); > } > > Do you have any suggestions to make this work? > > > > -- > View this message in context: > http://tomee-openejb.979440.n4.nabble.com/Resource-lookup-from-EJB-tp4676840.html > Sent from the TomEE Users mailing list archive at Nabble.com. >
