tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: OpenEJB - Datasource lookup problem
Date Tue, 08 Jan 2008 19:17:05 GMT

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:

<Connector id="MyDatasource" provider="Default JDBC Database">
    JdbcDriver   org.gjt.mysql.Driver
    JdbcUrl      jdbc:mysql://localhost:3306/test_db
    UserName     root
    Password     12345
</Connector>


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.
>>>
>>> <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
>>
>>
>>
>
> -- 
> 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.
>
>


Mime
View raw message