我正在尝试使用 JRebel 将多模块 Maven 项目从 Eclipse 部署到本地 Tomcat。该项目具有以下结构:
root [packaging: pom]
|
|--- domain [packaging: jar
|
|--- manager [packaging: jar]
|
|--- web [packaging: war]
我在src/main/resources/rebel.xml
3 个子模块中的每一个中都创建了。我可以从 Eclipse 中将 Web 项目部署到 Tomcat(不使用 JRebel),而不会出现任何问题。
但是,如果我将部署更改为使用 JRebel,则会收到以下错误:
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
是来自域项目的持久(JPA/Hibernate)类,它似乎是对它的引用,它WebAppListener
触发了错误:
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);
}
}
}
执行此代码时似乎domain
未加载类,知道如何解决此问题吗?