I'm trying to deploy a multi-module Maven project from Eclipse to a local Tomcat using JRebel. The project has the following structure:
root [packaging: pom]
|
|--- domain [packaging: jar
|
|--- manager [packaging: jar]
|
|--- web [packaging: war]
I've created src/main/resources/rebel.xml
in each of the 3 child modules. I can deploy the web project to Tomcat (without using JRebel) from within Eclipse without any problems.
However, if I change the deployment to use JRebel, I get the following error:
SEVERE: Exception sending context initialized event to listener instance
of class com.web.listeners.WebAppListener
java.lang.IllegalArgumentException: Unknown entity: com.model.Role
....
....
Caused by: org.hibernate.MappingException: Unknown entity: com.model.Role
Role
is a persistent (JPA/Hibernate) class from the domain project and it appears to be the reference to it in WebAppListener
that is triggering the error:
public class WebAppListener implements ServletContextListener, HttpSessionListener,
HttpSessionAttributeListener {
private RoleManager roleManager;
@Override
public void contextInitialized(ServletContextEvent sce) {
BeanFactory beanFactory = WebApplicationContextUtils.
getRequiredWebApplicationContext(sce.getServletContext());
this.roleManager = beanFactory.getBean(RoleManager.class);
saveIfAbsent("USER", "Normal User");
}
private void saveIfAbsent(String roleName, String roleDescription) {
if (roleManager.getRole(roleName) == null) {
Role role = new Role();
role.setName(roleName);
role.setDescription(roleDescription);
roleManager.saveRole(role);
}
}
}
It looks like the domain
classes are not loaded when this code is executed, any idea how to fix this?