I have scoured this site among others for answers in getting OpenEntityManagerInViewFilter to work. I have a standard User object that references a roles object with a many
But now!!
Let me make a guess: the name of your application is: board?
Correct? then go on and read the remaining answer!
Yes you have two entity manager, and even two identical application contexts (one app context and one web context) -- So you have every bean twice!
What happened is: you have only one (relevant) spring configuration file: 'board-servlet.xml' ('persistence-spring-beans.xml' is included in that file so at least it is one big logical file)
And you create a context from this file twice in the 'web.xml':
first:
contextConfigLocation
/WEB-INF/board-servlet.xml *****This file references the file with entityManager declared*****
/WEB-INF/board-security.xml
...
org.springframework.web.context.ContextLoaderListener
ContextLoaderListener load the application context specified by the files in 'contextConfigLocation' parameter.
second:
board
org.springframework.web.servlet.DispatcherServlet
1
Dispatcher Servlet create the web application context, which xml file is:
(For more details have a look at the Java Doc of FrameworkServlet)
In your case there is no explicitly named file, so it reads the 'board-servlet.xml' again.
What you need to do is separate them:
from board-servlet.xmlcontextConfigLocation in web.xml that it refers to classpath:persistence-spring-beans.xml and /WEB-INF/board-security.xml direclyboard-servlet.xml scan only for @Controller and the component scan in persistence-spring-beans.xml scan for the others (@Service, @Component, @Repository and @Dao)