persistence@glassfish.java.net

Re: Proposed fix for issue 256

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Thu, 16 Mar 2006 15:43:45 -0800

Hello Gordon,

On the second thought, I'm not sure my proposal would work. Is there
a way to create a dummy DataSource? If there is none, I can add an inner
class that will throw exceptions on access, or we can fall back on option a)
and check the exact PUInfo class type to decide whether to throw an
exception or not.

What do you think?

thanks,
-marina

Marina Vatkina wrote:
> Hello Gordon,
>
> I need to create a javax.sql.DataSource from the JNDI name provide by
> the user:
> PersistenceUnitInfo API uses DataSource as the jta and non-jta
> datasource types.
>
> Can I use for this purpose:
> (new DatabaseLogin().useJTADataSource(name))
> and
> (new DatabaseLogin().useDataSource(name))
> respectively?
>
> thanks,
> -marina
>
> Gordon Yorke wrote:
>
>> Hello Marina,
>> Yes I agree, I think we need validation for EE deployment. Go
>> with option b.
>> --Gordon
>>
>> -----Original Message-----
>> From: Marina Vatkina [mailto:Marina.Vatkina_at_Sun.COM]
>> Sent: Thursday, March 16, 2006 1:26 PM
>> To: persistence_at_glassfish.dev.java.net
>> Cc: Tom Ware
>> Subject: Re: Proposed fix for issue 256
>>
>>
>> Gordon,
>>
>> EntityManagerSetupImpl.predeploy has the following code:
>>
>> if(!validationOnly && persistenceUnitInfo != null &&
>> persistenceUnitInfo.getTransactionType() ==
>> PersistenceUnitTransactionType.JTA) {
>> if(persistenceUnitInfo.getJtaDataSource() == null) {
>> throw new
>> PersistenceException(EntityManagerSetupException.jtaPersistenceUnitInfoMissingJtaD
>>
>> ataSource(persistenceUnitInfo.getPersistenceUnitName()));
>> }
>> }
>>
>>
>> And in Sava SE the persistenceUnitInfo is implemented by
>> oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitInfo which
>> getJtaDataSource() always returns null:
>>
>> public DataSource getJtaDataSource(){
>> // not required in Java SE
>> return null;
>> }
>>
>> Option a) is tweak EntityManagerSetupImpl.predeploy
>> Option b) is to change PersistenceUnitInfo to handle the value, and
>> PersistenceContentHandler to parse it (instead of ignoring right now).
>>
>> I prefer option b)
>>
>> Thanks,
>> -marina
>>
>> Gordon Yorke wrote:
>>
>>> Hello Marina,
>>> Without more specifics on the technical roots of the problem I
>>> would have to diagnose this case and provide a solution myself. If
>>> you can provide pointers to the broken code (class names, line
>>> numbers) and your proposed solution, this process will go much faster.
>>> --Gordon
>>>
>>> -----Original Message-----
>>> From: Marina Vatkina [mailto:Marina.Vatkina_at_Sun.COM]
>>> Sent: Wednesday, March 15, 2006 6:58 PM
>>> To: persistence_at_glassfish.dev.java.net
>>> Cc: Tom Ware
>>> Subject: Re: Proposed fix for issue 256
>>>
>>>
>>> Tom, Gordon,
>>>
>>> Did you look into this?
>>>
>>> thanks,
>>> -marina
>>>
>>> Marina Vatkina wrote On 03/14/06 17:31,:
>>>
>>>
>>>> Tom,
>>>>
>>>> The current code throws an exception if persistence.xml
>>>> contains a JTA PU even if it's not used by the app. The
>>>> exception is completely misleading, as it complains that
>>>> jta datasource is not provided, while it's TopLink code
>>>> that ignores the value.
>>>>
>>>> There are 2 options to fix this:
>>>> a) ignore JTA transaction type in Java SE. This can be either
>>>> accomplished by checking the actual class type of PUInfo instance,
>>>> or using any other available setting, if there is one;
>>>>
>>>> b) Change PUInfo processing to accept the JTA (and non-JTA for
>>>> simplicity) datasource from PersistenceContentHandler.
>>>>
>>>> I suggest option b). If you agree I can fix it.
>>>>
>>>> thanks,
>>>> -marina
>>>
>>>
>>>
>>