项目在本地机器上运行,但是在服务器上部署之后找不到hibernate.cfg.xml,在本地机器tomcat上发现error.same war文件部署就可以了。
2015-07-13 07:00:00 ERROR JobRunShell:211 - Job grpPM.jobPM threw an unhandled Exception:
org.hibernate.HibernateException: Hibernate.cfg.xml not found
at org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2095)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2076)
at hibernet.HibernateConnection.getInstance(HibernateConnection.java:32)
at hibernet.HibernateData.getConnection(HibernateData.java:45)
at stockRefresh.Script330.runScript(Script330.java:34)
at StockRefresh330.execute(StockRefresh330.java:13)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
2015-07-13 07:00:00 ERROR ErrorLogger:2425 - Job (grpPM.jobPM threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.hibernate.HibernateException: Hibernate.cfg.xml not found]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.hibernate.HibernateException: Hibernate.cfg.xml not found
at org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2095)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2076)
at hibernet.HibernateConnection.getInstance(HibernateConnection.java:32)
at hibernet.HibernateData.getConnection(HibernateData.java:45)
at stockRefresh.Script330.runScript(Script330.java:34)
at StockRefresh330.execute(StockRefresh330.java:13)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
答案 0 :(得分:0)
将hibernate.cfg.xml放在类路径中。如果您不想要,请使用以下内容获取XML文件的上下文。
配置配置=新配置();
configuration.configure(" hibernate.cfg.xml"); //在这里,您可以在项目中提供确切的路径。
答案 1 :(得分:0)
如果文件与您的构建系统可能无法复制的Java文件相同,请将hibernate.cfg.xml
置于src/main/resources
下。