users@glassfish.java.net

Re: Hibernate and Spring not working on Glassfish 2

From: Gerald Holl <gerald_at_holl.co.at>
Date: Fri, 02 Nov 2007 16:56:25 +0100

Sahoo wrote:
>
> Gerald Holl wrote:
>> Hello,
>>
>> I'm trying to port my app from Tomcat 6 to Glassfish 2.
>> I'm using Spring 2 and Hibernate 3.2
>> In persistence.xml I set the transaction-type to RESOURCE_LOCAL but
>> Glassfish complains every time that this can't be used:
>>
>> com.sun.enterprise.deployment.backend.IASDeploymentException:
>> Deployment Error -- The persistence-context-ref-name
>> [GenericService/em] in module
>> [C:\glassfish\domains\domain1\applications\j2ee-modules\bla] resolves
>> to a persistence unit called [bla] which is of type RESOURCE_LOCAL.
>> Only persistence units with transaction type JTA can be used as a
>> container managed entity manager. Please verify your application.
>>
>> Here is the persistence.xml:
>> http://holl.co.at/download/glassfish/persistence.txt
>>
>> And Springs applicationContext.xml:
>> http://holl.co.at/download/glassfish/applicationContext.txt
>>
>>
>> Why is it not possible to use RESOURCE_LOCAL?
>>
> The reason is stated in the exception. It as follows:
> *only persistence units with transaction type JTA can be used as a
> container managed entity manager.*
>
> You may ask what is a container managed entity manager. An entity
> manager whose life cycle (i.e., create & close) is controlled by
> container is called a container managed life cycle. An injected entity
> manager is an example of such type.
>
> Two possible solutions:
> 1. Change transaction type to JTA in persistence.xml. OR
> 2. Use Application Managed entity manager (i.e. use EntityManagerFactory
> API to create EntityManager).
>
> I don't know which of the two options is more appropriate for you. I
> guess it's the former one.

I switched to EJB completely and removed all the Spring and Hibernate stuff.

Gerald
-- 
http://holl.co.at