2

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.

Nigel Espi
  • 21
  • 3

1 Answers1

0

In order to use Aspectj based load-time weaving on WildFly, you have to do following steps first:

  1. add JBOSS_MODULES_SYSTEM_PKGS="org.jboss.logmanager" to the beginning of $WILDFLY_HOME/bin/standalone.conf
  2. add -Djava.util.logging.manager=org.jboss.logmanager.LogManager to JAVA_OPTS at the end of $WILDFLY_HOME/bin/standalone.conf
  3. add -Xbootclasspath/p:$JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.0.Final.jar to JAVA_OPTS at the end of $WILDFLY_HOME/bin/standalone.conf

See https://issues.jboss.org/browse/WFLY-895 for more details.

Tomas Repel
  • 93
  • 1
  • 8