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.
>
> <resource-ref>
> <res-ref-name>MyDatasource</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> </resource-ref>
>
> 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
|