Red Militante [
http://community.jboss.org/people/redmond007] created the discussion
"Hibernate mapping resources - org.hibernate.MappingNotFoundException: resource:
User.hbm.xml not found"
To view the discussion, visit:
http://community.jboss.org/message/621940#621940
--------------------------------------------------------------
JBoss AS 7.0.1.Final, Hibernate 3. We have a MySQL datasource.
I have mapping resources pointing to *hbm.xml files. I get deployment errors that tell me
'resource: *hbm.xml not found', so entities are not being mapped correctly - this
stack trace is due to the User.hbm.xml not being found,
14:44:34,654 INFO [org.hibernate.cfg.Configuration] (MSC service thread 1-9)
HHH00042:Configuring from file: hibernate.cfg.xml
14:44:34,668 WARN [org.hibernate.internal.util.xml.DTDEntityResolver] (MSC service thread
1-9) HHH00223:Recognized obsolete hibernate namespace
http://hibernate.sourceforge.net/.
Use namespace
http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration
Guide!
14:44:34,670 INFO [org.hibernate.cfg.Configuration] (MSC service thread 1-9)
HHH00221:Reading mappings from resource: User.hbm.xml
14:44:34,697 SEVERE [com.mycompany.myapp.common.persistence.HibernateUtil] (MSC service
thread 1-9) Initial SessionFactory lookup failed.: org.hibernate.MappingNotFoundException:
resource: User.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:720)
[hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2083)
[hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2055)
[hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2035)
[hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1988)
[hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
at org.hibernate.cfg.Configuration.configure(Configuration.java:1961)
[hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
at
com.mycompany.myapp.common.persistence.HibernateUtil.<clinit>(HibernateUtil.java:42)
[classes:]
at
com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:216)
[classes:]
at
com.mycompany.myapp.common.servlet.SecurityFilter.init(SecurityFilter.java:55) [classes:]
at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3245)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3836)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)
[jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
at
org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[:1.6.0_26]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[:1.6.0_26]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
14:44:34,698 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapp-maventest]]
(MSC service thread 1-9) Exception starting filter EnterpriseSecurityFilter:
java.lang.NoClassDefFoundError: Could not initialize class
com.mycompany.myapp.common.persistence.HibernateUtil
at
com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:224)
[classes:]
at
com.mycompany.myapp.common.servlet.SecurityFilter.init(SecurityFilter.java:55) [classes:]
at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3245)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3836)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)
[jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
at
org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[:1.6.0_26]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[:1.6.0_26]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
14:44:34,699 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapp-maventest]]
(MSC service thread 1-9) Exception starting filter CompanySecurityFilter:
java.lang.NoClassDefFoundError: Could not initialize class
com.mycompany.myapp.common.persistence.HibernateUtil
at
com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:224)
[classes:]
at
com.mycompany.myapp.common.servlet.SecurityFilter.init(SecurityFilter.java:55) [classes:]
at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3245)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3836)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)
[jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
at
org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[:1.6.0_26]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[:1.6.0_26]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
14:44:34,701 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapp-maventest]]
(MSC service thread 1-9) Exception starting filter StationSecurityFilter:
java.lang.NoClassDefFoundError: Could not initialize class
com.mycompany.myapp.common.persistence.HibernateUtil
at
com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:224)
[classes:]
at
com.mycompany.myapp.common.servlet.SecurityFilter.init(SecurityFilter.java:55) [classes:]
at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3245)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3836)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)
[jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
at
org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[:1.6.0_26]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[:1.6.0_26]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
14:44:34,702 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapp-maventest]]
(MSC service thread 1-9) Exception starting filter StudioSecurityFilter:
java.lang.NoClassDefFoundError: Could not initialize class
com.mycompany.myapp.common.persistence.HibernateUtil
at
com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:224)
[classes:]
at
com.mycompany.myapp.studio.StudioSecurityFilter.init(StudioSecurityFilter.java:46)
[classes:]
at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3245)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3836)
[jbossweb-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)
[jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
at
org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[:1.6.0_26]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[:1.6.0_26]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
Our project is structured like
Project
|
|-pom.xml
|
|-src
| |-main
| |-java
| | |-com... businessobjects
| |-resources
| | |-META-INF
| |-webapp
|
|-test
we have hibernate.cfg.xml in src/main/resources/META-INF, and various *.class and *hbm.xml
in src/main/java/com/businessobjects/. Our hibernate.cfg.xml looks like
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property
name="datasourceName">java:jboss/datasources/MySqlDS</property>
<property
name="dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping
resource="com/mycompany/myapp/common/businessobjects/User.hbm.xml"/>
<mapping
resource="com/mycompany/myapp/common/businessobjects/Company.hbm.xml"/>
<mapping
resource="com/mycompany/myapp/common/businessobjects/ServerSettings.hbm.xml"/>
<mapping
resource="com/mycompany/myapp/common/businessobjects/Station.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I've tried different paths to point to the *hbm.xml files - none seem to work.
I've even tried giving it the absolute path to the *hbm.xml files, that didn't
work either.
I've also tried copying the *hbm.xml into the same directory as hibernate.cfg.xml -
that also didn't work, same error.
Looks like it errors out at this point in the code of my HibernateUtil class
static {
try {
InitialContext ctx = new InitialContext();
Configuration configuration = new Configuration();
Properties properties = new Properties();
sessionFactory = configuration.configure(new
File("/path/to/src/main/resources/META-INF/hibernate.cfg.xml")).buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
log.error("Initial SessionFactory lookup failed.", ex);
throw new ExceptionInInitializerError(ex);
}
}
Any ideas what's going on? Thanks
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/621940#621940]
Start a new discussion in Beginner's Corner at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]