在Tomcat中从war文件部署webapp时,我遇到了由错误的hibernate映射配置引起的问题。 错误的堆栈跟踪如下:
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”代码片段,但如果我将其取消注释,则会失败。
如果你能告诉我任何可能的信息,我会花费数小时试图解决它,我会非常感激。
提前致谢。
答案 0 :(得分:0)
好的,它已经解决了,这是一个愚蠢的错误。我在Edicion.java中更改了一个属性名称,而没有在相应的getter和setter中更改其命名。因愚蠢的错误而浪费了几个小时...... grrrr
非常感谢!
度过愉快的一天