I found the problem. So I am posting the solution bacause somebody could have the same situation:
My application context was divided in some files for make easy the maintenance. And these files had been grouped in a main file through the tag
import of spring.
The problem is that the
ContextLoaderListener read and load the bean definitions of this "main file" and after the
DispatcherServlet of spring mvc do the same thing again. So what happen?! I have two differents
sessionFactory objects because was load twice. Then the OSIV do not work, because always open and close one session. That it is not the one used by the Persistence Manager.
So, what I did to solve. I divided the main file in two. One with the spring mvc definitions (beans that spring mvc need). And other with my business and data access (includes the sessionFactory). So, the Spring DispacherServlet load the definitions that need and the ContextLoaderListener the other one, and everything is loaded once and works.
Pay attention that Spring DispactherServlet read the xml using the name of the
servlet (that you defined) more
-servlet.xml. Example:
(Your xml should be
dispatcher-servlet.xml)
And in your
contextConfigLocation, put the other xml. Like this:
Hope that it's clear.
Thank's