Re: OpenEJB - Datasource lookup problem
David, thanks. Those docs will surely help me. David Blevins wrote: > > > On May 16, 2008, at 12:02 PM, David Blevins wrote: > > I took a quick stab at some docs that compare annotations vs xml: > > http://cwiki.apache.org/OPENEJBx30/ejb-local-ref.html > http://cwiki.apache.org/OPENEJBx30/ejb-ref.html > http://cwiki.apache.org/OPENEJBx30/resource-ref-for-datasource.html > > Will get something for ConnectionFactory, EntityManager, etc. up there > as well. > > -David > > -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p17294068.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
On May 16, 2008, at 12:02 PM, David Blevins wrote: Hi All, Just a note that the lookup style should definitely work. Internally, Tomcat just looks things up from JNDI when doing injection. To get the reference into java:comp/env/ you need to either use the @Resource annotation or add an resource-ref in your web.xml like: MySqlDS javax.sql.DataSource Container I took a quick stab at some docs that compare annotations vs xml: http://cwiki.apache.org/OPENEJBx30/ejb-local-ref.html http://cwiki.apache.org/OPENEJBx30/ejb-ref.html http://cwiki.apache.org/OPENEJBx30/resource-ref-for-datasource.html Will get something for ConnectionFactory, EntityManager, etc. up there as well. -David On May 16, 2008, at 10:17 AM, ManojS wrote: BraamB, I could see your message today only, since I was out of this topic with some other tasks. I could not solve that datasource lookup problem the way I wished to solve. I mean, in my source code there were many places where we used to lookup datasouces simply by the following two lines of code, Context ctx = new InitialContext(); Datasource ds = (DataSource) ctx.lookup ("java:comp/env/MySqlDS" ); All these places where throwing the "NameNotFoundException" when we migrate into OpenEJB (embedded openEJB with Tomcat 6.0.16). I wanted to solve the issue without touching those source codes. But finally we solved the problem by the way David suggested. Using resource injection with annotation. For that, those many places we had to change the source code. Manoj. BraamB wrote: Hallo, Were you able to fix this problem? I am using the embedded openEJB with Tomcat 6 and have the exact same problem. I keep getting NameNotFoundException. Could you please help? -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p17279958.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
Hi All, Just a note that the lookup style should definitely work. Internally, Tomcat just looks things up from JNDI when doing injection. To get the reference into java:comp/env/ you need to either use the @Resource annotation or add an resource-ref in your web.xml like: MySqlDS javax.sql.DataSource Container -David On May 16, 2008, at 10:17 AM, ManojS wrote: BraamB, I could see your message today only, since I was out of this topic with some other tasks. I could not solve that datasource lookup problem the way I wished to solve. I mean, in my source code there were many places where we used to lookup datasouces simply by the following two lines of code, Context ctx = new InitialContext(); Datasource ds = (DataSource) ctx.lookup ("java:comp/env/MySqlDS" ); All these places where throwing the "NameNotFoundException" when we migrate into OpenEJB (embedded openEJB with Tomcat 6.0.16). I wanted to solve the issue without touching those source codes. But finally we solved the problem by the way David suggested. Using resource injection with annotation. For that, those many places we had to change the source code. Manoj. BraamB wrote: Hallo, Were you able to fix this problem? I am using the embedded openEJB with Tomcat 6 and have the exact same problem. I keep getting NameNotFoundException. Could you please help? -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p17279958.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
BraamB, I could see your message today only, since I was out of this topic with some other tasks. I could not solve that datasource lookup problem the way I wished to solve. I mean, in my source code there were many places where we used to lookup datasouces simply by the following two lines of code, Context ctx = new InitialContext(); Datasource ds = (DataSource) ctx.lookup ("java:comp/env/MySqlDS" ); All these places where throwing the "NameNotFoundException" when we migrate into OpenEJB (embedded openEJB with Tomcat 6.0.16). I wanted to solve the issue without touching those source codes. But finally we solved the problem by the way David suggested. Using resource injection with annotation. For that, those many places we had to change the source code. Manoj. BraamB wrote: > > Hallo, > > Were you able to fix this problem? I am using the embedded openEJB with > Tomcat 6 and have the exact same problem. I keep getting > NameNotFoundException. Could you please help? > > -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p17279958.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
With a Resource declared as follows: JdbcDriver org.gjt.mysql.Driver JdbcUrl jdbc:mysql://localhost:3306/test_db UserName root Password 12345 jtamanaged true You could have it injected via: @Resource(name="MyDatasource") private DataSource ds; Or the non-annotated way of using the ejb-jar.xml and jndi as follows: [ejb-jar.xml] MyDatasource javax.sql.DataSource [bean code] Context ctx = new InitialContext(); Datasource ds = (Datasource) ctx.lookup( "java:comp/env/ MyDatasource" ); Here's a working example of the annotated approach if it helps: http://openejb.apache.org/3.0/injection-of-datasource-example.html -David On May 12, 2008, at 11:16 PM, BraamB wrote: Hallo, Were you able to fix this problem? I am using the embedded openEJB with Tomcat 6 and have the exact same problem. I keep getting NameNotFoundException. Could you please help? ManojS wrote: Hello, I was playing with openejb and a test ejb application in my machine. My intention was to identify how much openejb is useful for me as an ejb container, so that I can recommend to use at my workplace. While I was trying to integrate openejb along with the application I cannot able to lookup the datasource connection defined in the openejb.conf file. If I explain in detail, my openejb.conf has the following connection configuration. JdbcDriver org.gjt.mysql.Driver JdbcUrl jdbc:mysql://localhost:3306/test_db UserName root Password 12345 jtamanaged true I am using the "Default Stateless Container" with ctype="STATELESS". And my ejb code (my ejbs are stateless session beans) for datasource lookup is as follows, public Connection getConnection () throws Exception { Context ctx = new InitialContext(); Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); return (ds!=null?ds.getConnection():null); } This code is throwing a javax.naming.NameNotFoundException. I tried with various other JNDI names like "java:comp/MyDatasource", "java:openejb/MyDatasource" etc. But the same result. The openejb version I am using is 1.0, because the EJB version I was using is 2.0. Can anyone help me to figure out what is the JNDI name to use for connector lookup ? Thanks in advance. Manoj. -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p17201828.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
Hallo, Were you able to fix this problem? I am using the embedded openEJB with Tomcat 6 and have the exact same problem. I keep getting NameNotFoundException. Could you please help? ManojS wrote: > > Hello, > > I was playing with openejb and a test ejb application in my machine. My > intention was to identify how much openejb is useful for me as an ejb > container, so that I can recommend to use at my workplace. While I was > trying to integrate openejb along with the application I cannot able to > lookup the datasource connection defined in the openejb.conf file. If I > explain in detail, my openejb.conf has the following connection > configuration. > > > JdbcDriver org.gjt.mysql.Driver > JdbcUrl jdbc:mysql://localhost:3306/test_db > UserName root > Password 12345 > jtamanaged true > > > I am using the "Default Stateless Container" with ctype="STATELESS". And > my ejb code (my ejbs are stateless session beans) for datasource lookup is > as follows, > > public Connection getConnection () throws Exception { > Context ctx = new InitialContext(); > Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); > return (ds!=null?ds.getConnection():null); > } > > This code is throwing a javax.naming.NameNotFoundException. I tried with > various other JNDI names like "java:comp/MyDatasource", > "java:openejb/MyDatasource" etc. But the same result. > > The openejb version I am using is 1.0, because the EJB version I was using > is 2.0. > > Can anyone help me to figure out what is the JNDI name to use for > connector lookup ? > > Thanks in advance. > > Manoj. > > -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p17201828.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
On Jan 7, 2008, at 9:15 PM, ManojS wrote: hmmm... I could able to configure openejb 3.0 locally. But for my enterprise application I must not use it for the timebeing since I am using java 1.4 and tomcat 4.1.24 versions there. So I would prefer to solve the datasource issue mentioned earlier in openejb 1.0. Can anyone help me ? For 1.0 you'd have to change your config like this: JdbcDriver org.gjt.mysql.Driver JdbcUrl jdbc:mysql://localhost:3306/test_db UserName root Password 12345 To be clear though OpenEJB 1.0 supports EJB 1.1 and some EJB 2.0 features, such as local interfaces. It does not support MDBs or CMP2, though the Castor CMP container does support it's own concept of relationships and object query language. If you could change your java level up to 1.5 we might be able to get OpenEJB 3.0 to run in Tomcat 4.1.x. OpenEJB 3.0 is better in many ways including it's Tomcat integration. -David David Blevins wrote: On Jan 6, 2008, at 9:29 AM, ManojS wrote: Thank you very much Mohammad and Jacek for your quick replies. Yes, I missed to set the JNDI context factory setting at first. Now the API has changed as follows. public Connection getConnection () throws Exception { Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); Context ctx = new InitialContext(properties); Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); return (ds!=null?ds.getConnection():null); } I have implemented this method in a session bean only. Also, for your information, I have added the datasource as resource referense in my "ejb-jar.xml" and "openejb-jar.xml" files for the session bean as follows. MyDatasource javax.sql.DataSource Still the problem exist. Now, as you all suggested, I will use the latest openejb 3.0. Let me configure it first, and then in any case of issues I will come back to you for help. As a general practice I recommend checking the log files too. We print very specific information there as well. Say for example you forgot to implement some methods from your EJBObject interface in your bean, we will print a list of every method you need to add. Say you decide to start using ejb3 annotations and you try something like this '@Resource EntityManager', we're going to output a message saying that you need to use '@PersistenceContext EntityManager' for injection of an EntityManager, etc. etc. It's our belief that if you make a mistake and we didn't catch it in a good way and tell you enough information to move forward that the mistake is really ours. So definitely let us know if you run into any situation where the error could be more helpful. -David -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14682665.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
Please ManojS can oyu send us the code to look at ? On Jan 8, 2008 7:15 AM, ManojS <[EMAIL PROTECTED]> wrote: > > > hmmm... I could able to configure openejb 3.0 locally. But for my > enterprise > application I must not use it for the timebeing since I am using java 1.4 > and tomcat 4.1.24 versions there. So I would prefer to solve the > datasource > issue mentioned earlier in openejb 1.0. Can anyone help me ? > > Manoj. > > > David Blevins wrote: > > > > > > On Jan 6, 2008, at 9:29 AM, ManojS wrote: > > > >> > >> Thank you very much Mohammad and Jacek for your quick replies. > >> > >> Yes, I missed to set the JNDI context factory setting at first. Now > >> the API > >> has changed as follows. > >> > >> public Connection getConnection () throws Exception { > >> Properties properties = new Properties(); > >>properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, > >> "org.apache.openejb.client.LocalInitialContextFactory"); > >> Context ctx = new InitialContext(properties); > >> Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); > >> return (ds!=null?ds.getConnection():null); > >> } > >> > >> I have implemented this method in a session bean only. Also, for your > >> information, I have added the datasource as resource referense in my > >> "ejb-jar.xml" and "openejb-jar.xml" files for the session bean as > >> follows. > >> > >> > >> MyDatasource > >> javax.sql.DataSource > >> > >> > >> Still the problem exist. > >> > >> Now, as you all suggested, I will use the latest openejb 3.0. Let me > >> configure it first, and then in any case of issues I will come back > >> to you > >> for help. > > > > As a general practice I recommend checking the log files too. We > > print very specific information there as well. Say for example you > > forgot to implement some methods from your EJBObject interface in your > > bean, we will print a list of every method you need to add. Say you > > decide to start using ejb3 annotations and you try something like this > > '@Resource EntityManager', we're going to output a message saying that > > you need to use '@PersistenceContext EntityManager' for injection of > > an EntityManager, etc. etc. > > > > It's our belief that if you make a mistake and we didn't catch it in a > > good way and tell you enough information to move forward that the > > mistake is really ours. So definitely let us know if you run into any > > situation where the error could be more helpful. > > > > -David > > > > > > > > -- > View this message in context: > http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14682665.html > Sent from the OpenEJB User mailing list archive at Nabble.com. > > -- Thanks - Mohammad Nour
Re: OpenEJB - Datasource lookup problem
hmmm... I could able to configure openejb 3.0 locally. But for my enterprise application I must not use it for the timebeing since I am using java 1.4 and tomcat 4.1.24 versions there. So I would prefer to solve the datasource issue mentioned earlier in openejb 1.0. Can anyone help me ? Manoj. David Blevins wrote: > > > On Jan 6, 2008, at 9:29 AM, ManojS wrote: > >> >> Thank you very much Mohammad and Jacek for your quick replies. >> >> Yes, I missed to set the JNDI context factory setting at first. Now >> the API >> has changed as follows. >> >> public Connection getConnection () throws Exception { >> Properties properties = new Properties(); >>properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, >> "org.apache.openejb.client.LocalInitialContextFactory"); >> Context ctx = new InitialContext(properties); >> Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); >> return (ds!=null?ds.getConnection():null); >> } >> >> I have implemented this method in a session bean only. Also, for your >> information, I have added the datasource as resource referense in my >> "ejb-jar.xml" and "openejb-jar.xml" files for the session bean as >> follows. >> >> >> MyDatasource >> javax.sql.DataSource >> >> >> Still the problem exist. >> >> Now, as you all suggested, I will use the latest openejb 3.0. Let me >> configure it first, and then in any case of issues I will come back >> to you >> for help. > > As a general practice I recommend checking the log files too. We > print very specific information there as well. Say for example you > forgot to implement some methods from your EJBObject interface in your > bean, we will print a list of every method you need to add. Say you > decide to start using ejb3 annotations and you try something like this > '@Resource EntityManager', we're going to output a message saying that > you need to use '@PersistenceContext EntityManager' for injection of > an EntityManager, etc. etc. > > It's our belief that if you make a mistake and we didn't catch it in a > good way and tell you enough information to move forward that the > mistake is really ours. So definitely let us know if you run into any > situation where the error could be more helpful. > > -David > > > -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14682665.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
On Jan 6, 2008, at 9:29 AM, ManojS wrote: Thank you very much Mohammad and Jacek for your quick replies. Yes, I missed to set the JNDI context factory setting at first. Now the API has changed as follows. public Connection getConnection () throws Exception { Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); Context ctx = new InitialContext(properties); Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); return (ds!=null?ds.getConnection():null); } I have implemented this method in a session bean only. Also, for your information, I have added the datasource as resource referense in my "ejb-jar.xml" and "openejb-jar.xml" files for the session bean as follows. MyDatasource javax.sql.DataSource Still the problem exist. Now, as you all suggested, I will use the latest openejb 3.0. Let me configure it first, and then in any case of issues I will come back to you for help. As a general practice I recommend checking the log files too. We print very specific information there as well. Say for example you forgot to implement some methods from your EJBObject interface in your bean, we will print a list of every method you need to add. Say you decide to start using ejb3 annotations and you try something like this '@Resource EntityManager', we're going to output a message saying that you need to use '@PersistenceContext EntityManager' for injection of an EntityManager, etc. etc. It's our belief that if you make a mistake and we didn't catch it in a good way and tell you enough information to move forward that the mistake is really ours. So definitely let us know if you run into any situation where the error could be more helpful. -David
Re: OpenEJB - Datasource lookup problem
On Jan 6, 2008 6:29 PM, ManojS <[EMAIL PROTECTED]> wrote: > Now, as you all suggested, I will use the latest openejb 3.0. Let me > configure it first, and then in any case of issues I will come back to you > for help. Please report any issues you come across here as it's much easier for us to configure openejb (if necessary at all) so you can concentrate on ejb3 rather than on openejb itself (which should be as minimally time-consuming and intrusive as possible). Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
Re: OpenEJB - Datasource lookup problem
Thank you very much Mohammad and Jacek for your quick replies. Yes, I missed to set the JNDI context factory setting at first. Now the API has changed as follows. public Connection getConnection () throws Exception { Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); Context ctx = new InitialContext(properties); Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); return (ds!=null?ds.getConnection():null); } I have implemented this method in a session bean only. Also, for your information, I have added the datasource as resource referense in my "ejb-jar.xml" and "openejb-jar.xml" files for the session bean as follows. MyDatasource javax.sql.DataSource Still the problem exist. Now, as you all suggested, I will use the latest openejb 3.0. Let me configure it first, and then in any case of issues I will come back to you for help. Thank you very much for your help. Manoj. Jacek Laskowski wrote: > > On Jan 6, 2008 10:51 AM, ManojS <[EMAIL PROTECTED]> wrote: > >> The openejb version I am using is 1.0, because the EJB version I was >> using >> is 2.0. > > OpenEJB 3.0 (and any EJB3-compliant container) is fully > backward-compatible with the previous ejb specs so using ejb 2.0 > doesn't necessarily mandate previous openejb releases. Having said > this, I'd stronly recommend using OpenEJB 3.0 as the ejb container of > your choice. > > Once you're at openejb3 level look it up via > java:openejb/Resource/MyDatasource (Connector element has recently > been deprecated). > > Download OpenEJB 3.0 from > http://people.apache.org/~jlaskowski/openejb-3.0.0-SNAPSHOT-bin.tar.gz. > It's a build from today's sources. > > Jacek > > -- > Jacek Laskowski > http://www.JacekLaskowski.pl > > -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14651115.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB - Datasource lookup problem
On Jan 6, 2008 4:37 PM, Mohammad Nour El-Din <[EMAIL PROTECTED]> wrote: > First thanks for using OpenEJB and thanks again for sharing your problems > with us to tyr make OpenEJB better :). I recommend to use OpenEJB 3.0 as it > is the most updated version and all of the current development is made on > it. I still can't understand from where you call this method, is it a method > in your bean ??? but from what I see in the code, you have to initialize the > naming conext first with the proper poperties to be able to use. If it is > applicable we would like to look at your code to give a more precise answer. I can't believe you responded the same time as I did! Some say: there're minds who think alike (it goes differently, but anyway it explains why we did so too ;-)). Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
Re: OpenEJB - Datasource lookup problem
On Jan 6, 2008 10:51 AM, ManojS <[EMAIL PROTECTED]> wrote: > The openejb version I am using is 1.0, because the EJB version I was using > is 2.0. OpenEJB 3.0 (and any EJB3-compliant container) is fully backward-compatible with the previous ejb specs so using ejb 2.0 doesn't necessarily mandate previous openejb releases. Having said this, I'd stronly recommend using OpenEJB 3.0 as the ejb container of your choice. Once you're at openejb3 level look it up via java:openejb/Resource/MyDatasource (Connector element has recently been deprecated). Download OpenEJB 3.0 from http://people.apache.org/~jlaskowski/openejb-3.0.0-SNAPSHOT-bin.tar.gz. It's a build from today's sources. Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
Re: OpenEJB - Datasource lookup problem
You can find OpenEJB 3.0 here http://openejb.apache.org/openejb-30-beta-1.html On Jan 6, 2008 5:37 PM, Mohammad Nour El-Din <[EMAIL PROTECTED]> wrote: > Hi ManojS... > > First thanks for using OpenEJB and thanks again for sharing your > problems with us to tyr make OpenEJB better :). I recommend to use OpenEJB > 3.0 as it is the most updated version and all of the current development > is made on it. I still can't understand from where you call this method, is > it a method in your bean ??? but from what I see in the code, you have to > initialize the naming conext first with the proper poperties to be able to > use. If it is applicable we would like to look at your code to give a more > precise answer. > > > On Jan 6, 2008 11:51 AM, ManojS <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > > I was playing with openejb and a test ejb application in my machine. My > > intention was to identify how much openejb is useful for me as an ejb > > container, so that I can recommend to use at my workplace. While I was > > trying to integrate openejb along with the application I cannot able to > > lookup the datasource connection defined in the openejb.conf file. If I > > explain in detail, my openejb.conf has the following connection > > configuration. > > > > > >JdbcDriver org.gjt.mysql.Driver > >JdbcUrl jdbc:mysql://localhost:3306/test_db > >UserName root > >Password 12345 > >jtamanaged true > > > > > > I am using the "Default Stateless Container" with ctype="STATELESS". And > > my > > ejb code (my ejbs are stateless session beans) for datasource lookup is > > as > > follows, > > > > public Connection getConnection () throws Exception { > >Context ctx = new InitialContext(); > >Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); > >return (ds!=null?ds.getConnection():null); > > } > > > > This code is throwing a javax.naming.NameNotFoundException. I tried with > > various other JNDI names like "java:comp/MyDatasource", > > "java:openejb/MyDatasource" etc. But the same result. > > > > The openejb version I am using is 1.0, because the EJB version I was > > using > > is 2.0. > > > > Can anyone help me to figure out what is the JNDI name to use for > > connector > > lookup ? > > > > Thanks in advance. > > > > Manoj. > > > > -- > > View this message in context: > > http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14645858.html > > > > Sent from the OpenEJB User mailing list archive at Nabble.com. > > > > > > > -- > Thanks > - Mohammad Nour -- Thanks - Mohammad Nour
Re: OpenEJB - Datasource lookup problem
Hi ManojS... First thanks for using OpenEJB and thanks again for sharing your problems with us to tyr make OpenEJB better :). I recommend to use OpenEJB 3.0 as it is the most updated version and all of the current development is made on it. I still can't understand from where you call this method, is it a method in your bean ??? but from what I see in the code, you have to initialize the naming conext first with the proper poperties to be able to use. If it is applicable we would like to look at your code to give a more precise answer. On Jan 6, 2008 11:51 AM, ManojS <[EMAIL PROTECTED]> wrote: > > Hello, > > I was playing with openejb and a test ejb application in my machine. My > intention was to identify how much openejb is useful for me as an ejb > container, so that I can recommend to use at my workplace. While I was > trying to integrate openejb along with the application I cannot able to > lookup the datasource connection defined in the openejb.conf file. If I > explain in detail, my openejb.conf has the following connection > configuration. > > >JdbcDriver org.gjt.mysql.Driver >JdbcUrl jdbc:mysql://localhost:3306/test_db >UserName root >Password 12345 >jtamanaged true > > > I am using the "Default Stateless Container" with ctype="STATELESS". And > my > ejb code (my ejbs are stateless session beans) for datasource lookup is as > follows, > > public Connection getConnection () throws Exception { >Context ctx = new InitialContext(); >Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); >return (ds!=null?ds.getConnection():null); > } > > This code is throwing a javax.naming.NameNotFoundException. I tried with > various other JNDI names like "java:comp/MyDatasource", > "java:openejb/MyDatasource" etc. But the same result. > > The openejb version I am using is 1.0, because the EJB version I was using > is 2.0. > > Can anyone help me to figure out what is the JNDI name to use for > connector > lookup ? > > Thanks in advance. > > Manoj. > > -- > View this message in context: > http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14645858.html > Sent from the OpenEJB User mailing list archive at Nabble.com. > > -- Thanks - Mohammad Nour
OpenEJB - Datasource lookup problem
Hello, I was playing with openejb and a test ejb application in my machine. My intention was to identify how much openejb is useful for me as an ejb container, so that I can recommend to use at my workplace. While I was trying to integrate openejb along with the application I cannot able to lookup the datasource connection defined in the openejb.conf file. If I explain in detail, my openejb.conf has the following connection configuration. JdbcDriver org.gjt.mysql.Driver JdbcUrl jdbc:mysql://localhost:3306/test_db UserName root Password 12345 jtamanaged true I am using the "Default Stateless Container" with ctype="STATELESS". And my ejb code (my ejbs are stateless session beans) for datasource lookup is as follows, public Connection getConnection () throws Exception { Context ctx = new InitialContext(); Datasource ds = (Datasource) ctx.lookup( "MyDatasource" ); return (ds!=null?ds.getConnection():null); } This code is throwing a javax.naming.NameNotFoundException. I tried with various other JNDI names like "java:comp/MyDatasource", "java:openejb/MyDatasource" etc. But the same result. The openejb version I am using is 1.0, because the EJB version I was using is 2.0. Can anyone help me to figure out what is the JNDI name to use for connector lookup ? Thanks in advance. Manoj. -- View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14645858.html Sent from the OpenEJB User mailing list archive at Nabble.com.