You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by zsaade <zs...@path-solutions.com> on 2019/02/13 10:01:56 UTC

EAR Datasource javax.naming.NameNotFoundException

Dear All 

I have an EAR file that i'm deploying under
<apache-tomee-plume-7.1.0-home>\apps folder, I added the the below
Datasource configuration in the tomee.xml file located under
<tomee-home>\conf: 

<?xml version="1.0" encoding="UTF-8"?> 
<tomee>
        <Deployments dir="apps" />
        <Resource id="services" type="javax.sql.DataSource">
                jdbcDriver oracle.jdbc.OracleDriver 
                jdbcUrl jdbc:oracle:thin:@//db-server:1521/ORA11 
                userName test_server 
                password test_server 
                jtaManaged true 
                defaultAutoCommit true 
        </Resource>
</tomee>

In my EJB i'm calling the datasource as per the below code: 

Context initContext = new InitialContext(); 
DataSource ds = (DataSource) initContext.lookup("services"); 
this.ConnectDataSource = ds; 

But When i'm starting TomeEE i'm getting the below exception: 

javax.naming.NameNotFoundException: Name [services] is not bound in this
Context. Unable to find [services.] 

Kindly advice 

Best Regards 




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html

Re: EAR Datasource javax.naming.NameNotFoundException

Posted by zsaade <zs...@path-solutions.com>.
Dear Thomas

thanks for your reply.

If I define the annotation @Resource at the level of the DataSource
variable, what would be the JNDI name in the look up below?

DataSource datasource = (DataSource) initContext.lookup("*iMALSerciecs*");

Thanks and Best Regards



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html

Re: EAR Datasource javax.naming.NameNotFoundException

Posted by zsaade <zs...@path-solutions.com>.
Hi Thomas

Thanks for your reply, 

Note that I'm using EJB 2.1 and i'm deploying the EAR on multiple
application server under JDK 1.7 compliance.

Best Regards



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html

Re: EAR Datasource javax.naming.NameNotFoundException

Posted by Thomas Butz <tb...@optitool.de.INVALID>.
Why don't you use injection for this?

@Resource(name="services")
private DataSource dataSource;


-- 
Best regards


Thomas Butz