- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
JBoss AS 7.0.1.Final,Hibernate 3。我们有一个 MySQL 数据源。
我有指向 *hbm.xml 文件的映射资源。我收到部署错误,告诉我“资源:* hbm.xml 未找到”,因此实体未正确映射 - 此堆栈跟踪是由于未找到 User.hbm.xml,
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]
我们的项目结构如下
Project
|
|-pom.xml
|
|-src
| |-main
| |-java
| | |-com... businessobjects
| |-resources
| | |-META-INF
| |-webapp
|
|-test
我们在 src/main/resources/META-INF 中有 hibernate.cfg.xml,在 src/main/java/com/businessobjects/中有各种 *.class 和 *hbm.xml。我们的 hibernate.cfg.xml 看起来像
<?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>
我尝试了不同的路径来指向 *hbm.xml 文件 - 似乎都不起作用。我什至尝试过为它提供 *hbm.xml 文件的绝对路径,但这也不起作用。
我也试过将 *hbm.xml 复制到与 hibernate.cfg.xml 相同的目录中 - 这也没有用,同样的错误。
看起来我的 HibernateUtil 类的代码此时出错了
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);
}
}
有什么想法吗?谢谢
最佳答案
将您的映射文件移至 src/main/resources。只有 .java 文件属于 src/main/java。
编辑:我设置了一个 example project on github显示如何从 hibernate.cfg.xml 正确引用 XML 映射文件。
关于java - org.hibernate.MappingNotFoundException : resource: *hbm. 找不到 xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7127608/
我正在寻找外行人对计算机硬件和组织的介绍。以下是我想讨论的一些主题。 Brief intro to electronics. Gates and state machines, intro to re
有没有人在 Visual Basic 2010 中看到过这个错误,如果有的话......关于如何解决它的任何想法? 错误是 module 'Resources' and module 'Resourc
这个问题在这里已经有了答案: Why ?attr/colorAccent dose not work below lollipop version? (2 个答案) 关闭 5 年前。 我收到以下错误
我正在尝试通过 ring 学习 clojure 网络开发和 compojure我有点不清楚 compojure.route/resources 和 ring.middleware.resource/w
是否必须放置内部 try-with-resources 或其中一个 try-with-resources 中的所有内容都会自动关闭? try (BasicDataSource ds = Bas
我有一本包含多个食谱的 Chef 食谱,用于安装服务。 Chef-client 的工作方式是每 15 分钟(或其他固定时间间隔)重新收敛一次。现在我的食谱的第一步是停止服务,所以服务将每 15 分钟停
我有资源组“MyResources”,其中包含 4 个资源: AppService - 我的服务器, AppServicePlan - MyServerWestEuFarm, ApplicationI
我有资源组“MyResources”,其中包含 4 个资源: AppService - 我的服务器, AppServicePlan - MyServerWestEuFarm, ApplicationI
我有一个返回 ResponseEntity 的休息终点. 需要检查如何在 Swagger 规范中创建这种类型的响应。这里包中的资源是 org.springframework.core.io.Resou
In my azure portal I have 6 separate applications, I have to list all of the employed resources u
In my azure portal I have 6 separate applications, I have to list all of the employed resources u
我有一个问题,设计师不会显示表单。它失败,错误 Designer 给出警告,如下所示: 我该如何解决这个问题? 最佳答案 您似乎缺少在应用程序中加载此表单所需的项目 资源 . 您可以访问 资源右键单击
我是 angularJS 世界的新手,我可能误解了一些东西。 我的应用程序使用 Controller 、指令和服务,所有这些都运行完美,直到我使用带有 $resource 的服务,然后出现“冲突”或其
我在 Unity3D 工作。 我使用 Resources.LoadAll(path);加载文件夹和子文件夹中的所有项目。执行此操作后,我想获取对象的子文件夹名称或完整路径。这可能吗? 并且不建议使用
我需要监控每个客户端环境(一个订阅、多个资源组)的 Azure 支出。在我的研究中,我发现了 2 个可以使用的 API: 资源费率卡( https://msdn.microsoft.com/fr-fr
在 RDF 1.1 XML 语法文档中 rdf:resource 在定义 Empty Property Elements 时用作缩写形式: When a predicate arc in an RDF
这是一种常见的情况,我们需要在用户更新/创建一些数据后向用户显示错误/成功消息,我们如何在 AngularJS 中实现它? 我想添加回调但找不到解决方案。使用 $http.post().success
我正在使用 android studio 作为 IDE 开发一个 android 应用程序。 我的问题是: 如何在构建APK过程中排除某个目录下的某些文件? 在我的例子中,我想从构建中排除一些图像,因
在编译我的 Visual Studio C# 项目时,出现以下错误: 在“Resources”参数中多次指定项目“obj\Debug\SampleProject.Forms.MDIMain.resou
使用 CoffeeScript、Angular 和 $resource,我创建了以下工厂: angular.module('myapp', ['ngResource']).factory 'MyObj
我是一名优秀的程序员,十分优秀!