Reputation: 187499
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?
Upvotes: 1
Views: 1990
Reputation: 187499
I fixed the problem by removing
<dir name="/absolute/path/to/projectname/src/main/resources"></dir>
from the rebel.xml file in the domain project as described here
Upvotes: 0
Reputation: 1514
What is the contents of your rebel files? They should look like
<classpath>
<dir name="/absolute/path/to/projectname/target/classes"></dir>
</classpath>
If you're using maven, you can also take a look at a related topic: Getting JRebel to work with 'mvn tomcat:run'
Note: if rebel.xml also contains a reference to src/main/resources, it sometimes confuses some frameworks and you should try removing it from all rebel.xml files if errors occur. For example, the following conf is quite common, but may not always work:
<classpath>
<dir name="/absolute/path/to/projectname/target/classes"></dir>
<dir name="/absolute/path/to/projectname/src/main/resources"></dir>
</classpath>
Upvotes: 2