0
我有一個錯誤的休眠映射配置,而從Tomcat的戰爭文件中部署webapp時造成的問題。 錯誤的堆棧跟蹤如下:休眠xml配置文件
Grave: Critical error during deployment:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:449)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1653)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: javax.faces.FacesException: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
at com.sun.faces.config.ConfigManager.getAnnotatedClasses(ConfigManager.java:507)
at com.sun.faces.config.processor.AbstractConfigProcessor.processAnnotations(AbstractConfigProcessor.java:402)
at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:340)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:116)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:239)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:435)
... 14 more
Caused by: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at com.sun.faces.config.ConfigManager.getAnnotatedClasses(ConfigManager.java:503)
... 21 more
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at com.sun.faces.util.Util.loadClass(Util.java:325)
at com.sun.faces.config.AnnotationScanner.processClassList(AnnotationScanner.java:309)
at com.sun.faces.config.JavaClassScanningAnnotationScanner.getAnnotatedClasses(JavaClassScanningAnnotationScanner.java:128)
at com.sun.faces.config.DelegatingAnnotationProvider.getAnnotatedClasses(DelegatingAnnotationProvider.java:85)
at com.sun.faces.config.ConfigManager$AnnotationScanTask.call(ConfigManager.java:931)
at com.sun.faces.config.ConfigManager$AnnotationScanTask.call(ConfigManager.java:883)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:383)
... 14 more
Caused by: java.lang.NullPointerException
at es.smt.better.bd.utils.HibernateUtils.getCurrentSession(HibernateUtils.java:38)
at es.smt.better.bd.dao.UsuarioDAO.getNicks(UsuarioDAO.java:219)
at es.smt.better.converters.UserConverter.<clinit>(UserConverter.java:23)
... 24 more
它通過這段代碼造成的:
<many-to-one name="editor" class="es.smt.better.bd.model.Usuario" fetch="select">
<column name="UsuarioId" not-null="true" />
</many-to-one>
這是本Hibernate映射文件中:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 21-feb-2014 9:40:43 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="es.smt.better.bd.model.Edicion" table="EdicionProyecto" schema="dbo" catalog="BtterDevDatabase2">
<id name="edicionId" type="java.lang.Integer">
<column name="EdicionId" />
<generator class="native" />
</id>
<property name="fecha" type="timestamp">
<column name="Fecha" length="23" not-null="true" />
</property>
<many-to-one name="editor" class="es.smt.better.bd.model.Usuario" fetch="select">
<column name="UsuarioId" not-null="true" />
</many-to-one>
<many-to-one name="proyecto" class="es.smt.better.bd.model.Proyecto" fetch="select">
<column name="ProyectoId" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
我我試圖做的是添加一個名爲Edicion的新實體,其中包含對「proyecto」類的引用以及其他對「usuario」的引用。我在這裏不理解的是,proyecto的引用(數據庫中的外鍵)運行良好,但是usuario(外鍵也)在執行相同編碼時給我這個配置錯誤。如果我在部署工作之前發佈了一段「usuario」的代碼,但是如果我不留下它的話,它就會失敗。
如果你能告訴我任何關於它的可能性,我會非常感激的。
在此先感謝。
您在 es.smt.better.bd.utils.HibernateUtils.getCurrentSession(HibernateUtils.java:38) 得到NullPointerException異常,你應該檢查什麼是有沒有空。 –
在那一行我只做SessionFactory.openSession(),我怎麼知道NULL是什麼?我的意思是,這不是一個空置的領域或任何東西。這只是一個配置錯誤,正如我在問題中所說的,如果我退出了這段代碼 - >「<多對一名稱=」編輯器「class =」es.smt.better.bd.model.Usuario「fetch =「select」> many-to-one>「它不會拋出錯誤... 無論如何,非常感謝您的回答 –
Hugo