I am wanting to use AspectJ for load-time weaving of my service layer JAR that contains DAO & domain classes and the session and transaction beans that are shared with multiple web projects inside an EAR running on WildFly (JBoss), but am getting a "No session found for current thread" exception whenever I try to use the hibernate session.
Here is the structure of my EAR:
testapp.ear
|
|------ /lib/testapp-service.jar + all required libraries as I'm using skinny WARs.
|
|------ testapp.web1.war
|
|------ testapp-web2.war
I am using the following tech:
WildFly 9
Hibernate 4.1.8
Spring 3.1.1
Maven 4
Spring config:
I am using spring's parentContextKey context-param to load the shared context as per the spring documentation. I'm using AspectJ for load time weaving of my transaction manager.
Here is a link to my source: https://github.com/Nigel-funguru/testapp.git
NOTE: If I remove the load-time AspectJ weaving from the spring config, this configuration does work.
Here is my stack trace:
Caused by: org.hibernate.HibernateException: No Session found for current thread
at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:978)
at com.testapp.db.hibernate.EmployeeHibernateRepository.findAll(EmployeeHibernateRepository.java:31)
at com.testapp.service.impl.EmployeeManagerImpl.findAll(EmployeeManagerImpl.java:34)
at com.testapp.mvc.HomeController.showHomePage(HomeController.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
... 30 more
For full stack trace see: http://pastebin.ca/3090734
Any help would be much appreciated.