Jndi lookup for bean and datasource.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Jndi lookup for bean and datasource.

Kalyan
Hello,
I have two issues with the jndi lookup.
I am using kind of a netty server which is our home grown server.
I used openejb to deploy the ejbs.  I don't have any EAR or WAR file. Its
jar file with contains the ejb-jar.xml etc..
The deployment was successful.  The container came up fine.


*1 ) Bean lookup issue*
If you look at the jndi below

Jndi(name=*global/classpath.ear*/SERVICE_EJBs/SyncServiceBean!SyncServiceBeanLocalHome)
--> Ejb(deployment-id=SyncServiceBean)

what's the classpath.ear here?? from where its is coming ? i don't have any
classpath.ear file in my deployment.

I figured out the classpath.ear..  if i set to
openejb.deployments.classpath.ear=false. It doesn't show up.

I want to lookup the bean using something like sd/SyncServiceBeanSB .

How can i do the mapping ?


2) Datasource lookup issue

    I created a datasource as

     p.put("DS_DB", "new://Resource?type=javax.sql.DataSource");
        p.put("DS_DB.JdbcDriver", "oracle.jdbc.OracleDriver");
        p.put("DS_DB.JdbcUrl", "jdbc:oracle:thin:@xxxxxxx:1521/readdb");
        p.put("DS_DB.UserName", "q1_user");
        p.put("DS_DB.Password", "XXXXX");
        p.put("DS_DB.LogSql", "true");
        p.put("DS_DB.JtaManaged", "true");

     InitialContext initialContext = new InitialContext(p);

  In the code if i try to lookup with DS_DB it doesn't work

    context.lookup("java:/DS_DB")   throws exception


But same if i lookup as
   context("java:openejb:Resource/DS_DB")  it works.

I also tried with the link

    context.bind("java:/DS_DB",new
                    javax.naming.LinkRef("java:openejb:Resource/DS_DB"));

Even then it doesn't work.

Please help me solve the above two issues..

thanks
Kalyan



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: Jndi lookup for bean and datasource.

Cesar Hernandez
Hi  Kalyan,

About your Datasource lookup issue , Last week I was reviewing this pr [1]
and I saw this in code DS building.
I think your lookup should be: java:global/DS_DB

[1] https://github.com/apache/tomee/pull/488

El jue., 20 jun. 2019 a las 14:41, Kalyan (<[hidden email]>)
escribió:

> Hello,
> I have two issues with the jndi lookup.
> I am using kind of a netty server which is our home grown server.
> I used openejb to deploy the ejbs.  I don't have any EAR or WAR file. Its
> jar file with contains the ejb-jar.xml etc..
> The deployment was successful.  The container came up fine.
>
>
> *1 ) Bean lookup issue*
> If you look at the jndi below
>
> Jndi(name=*global/classpath.ear*/SERVICE_EJBs/SyncServiceBean!SyncServiceBeanLocalHome)
>
> --> Ejb(deployment-id=SyncServiceBean)
>
> what's the classpath.ear here?? from where its is coming ? i don't have
> any
> classpath.ear file in my deployment.
>
> I figured out the classpath.ear..  if i set to
> openejb.deployments.classpath.ear=false. It doesn't show up.
>
> I want to lookup the bean using something like sd/SyncServiceBeanSB .
>
> How can i do the mapping ?
>
>
> 2) Datasource lookup issue
>
>     I created a datasource as
>
>      p.put("DS_DB", "new://Resource?type=javax.sql.DataSource");
>         p.put("DS_DB.JdbcDriver", "oracle.jdbc.OracleDriver");
>         p.put("DS_DB.JdbcUrl", "jdbc:oracle:thin:@xxxxxxx:1521/readdb");
>         p.put("DS_DB.UserName", "q1_user");
>         p.put("DS_DB.Password", "XXXXX");
>         p.put("DS_DB.LogSql", "true");
>         p.put("DS_DB.JtaManaged", "true");
>
>      InitialContext initialContext = new InitialContext(p);
>
>   In the code if i try to lookup with DS_DB it doesn't work
>
>     context.lookup("java:/DS_DB")   throws exception
>
>
> But same if i lookup as
>    context("java:openejb:Resource/DS_DB")  it works.
>
> I also tried with the link
>
>     context.bind("java:/DS_DB",new
>                     javax.naming.LinkRef("java:openejb:Resource/DS_DB"));
>
> Even then it doesn't work.
>
> Please help me solve the above two issues..
>
> thanks
> Kalyan
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>


--
Atentamente:
César Hernández.
Reply | Threaded
Open this post in threaded view
|

Re: Jndi lookup for bean and datasource.

Kalyan
Thanks César Hernández Mendoza for looking into it.
Yes looks like its binding to java:global as well as java:openejb:Resource/

The way i want to link didn't work. But anyways i have mapped my old jndi
name to new jndi as per openejb. And that works.

Thanks a lot

Regards
Kalyan



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