<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="sessionFactory">
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/bestdb</property>
<property name="hibernate.connection.password">best123</property>
<property name="hibernate.connection.username">best</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.show_sql">false</property>
<mapping resource="Registration.hbm.xml"/>
</session-factory>
</hibernate-configuration>
这是我的Hibernate配置文件。错误堆栈跟踪为:
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1411)
at connectionHandler.ConnectionHandler.openConnection(ConnectionHandler.java:24)
at controller.RegistrationController.loginController(RegistrationController.java:240)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:387)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)
Caused by: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
... 46 more
这是我的连接处理程序。java代码是:
public class ConnectionHandler {
private static SessionFactory sesstioFactory;
public static SessionFactory getSesstioFactory() {
return sesstioFactory;
}
public static void setSesstioFactory(SessionFactory sesstioFactory) {
ConnectionHandler.sesstioFactory = sesstioFactory;
}
public static void openConnection(){
try{
System.out.println("Trying to build session factory");
sesstioFactory=new Configuration().configure().buildSessionFactory();
System.out.println("Session factory built successfully");
}
catch (Exception e) {
System.out.println("----------------Problem in opening connection--------------");
e.printStackTrace();
}
}
public static void closeConnection(){
try{
System.out.println("Trying to close session factory");
sesstioFactory.close();
System.out.println("Session factory closed successfully");
}
catch (Exception e) {
System.out.println("----------------Problem in opening connection--------------");
e.printStackTrace();
}
}
下面的代码段调用ConnectionHandler。java:
ConnectionHandler.openConnection(); // Calling for opening connection
// for the first time
SessionFactory sf = ConnectionHandler.getSesstioFactory();
Session s = sf.openSession();
Transaction t = s.beginTransaction();
我不知道为什么解析配置文件时会出现错误。我试着改变
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"到"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"
还包括所有所需的罐子。非常感谢。
在您的
Hibernate.cfg.xml
文件,请尝试更改
<罢工> 对此:
编辑:
在我的原始答案中,我从我的映射文件中复制了
DOCTYPE
;我应该从配置文件中复制。感谢RAS指出这一点。
您的配置文件似乎正确。我使用的是相同的<code>DOCTYPE</code>声明:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
对于映射文件,您可以尝试下面的
DOCTYPE
声明(如果您的不同)并确保没有拼写错误:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
问题内容: 大家好,我是hibernate的初学者,我知道这里有很多类似的问题。我试图从他们那里解决,但我做不到。我还试图在dtd中将SYSTEM从PUBLIC更改为,但是它不起作用。我用谷歌搜索它,但是到处都显示dtd语句错误。 这是我的配置文件。 我尝试将版本3.0更改为4.0,因为我正在使用hibernate版本4.3.6,但仍无法正常工作。请帮帮我。 这是我的userDetails类。 软
嘿,伙计们,我是冬眠的初学者,我知道这里有很多类似的问题。我试图从他们那里解决问题,但我做不到。我还试图在dtd中更改公共系统,但它不起作用。我在google上搜索了它,但它显示的每个地方都有dtd语句错误。 这是我的配置文件。 我尝试将版本3.0更改为4.0,因为我使用的是hibernate版本4.3.6,但它仍然不起作用。请帮帮我。 这是我的用户详细信息类... 包装组织。冬眠src; 我已将
问题内容: 我尝试配置ElasticSearch: 这是我执行“ http://mydomain.com:9200/test/_analyze?analyzer=autocomplete&text=rih ” 时的错误 有什么问题 ?谢谢 问题答案: 该错误显示“无法找到分析器[自动完成]”。在Elasticsearch中,默认情况下您可以使用多个分析器。尽管您可以创建一个自定义分析器,但我不知道
我想为Elasticsearch中的任何索引设置一个全局分析器。 这些行被添加到elasticsearch.yaml中: 重新启动Elasticsearch后,这些行如所示http://localhost:9200/_nodes/settings 然后我用url测试http://localhost:9200/_analyze?text=时间 它显示iAnalyzer已启用。然而,当谈到http:/
我在执行此错误发生在集成sonarqube之后。 [ERROR]无法执行目标org.springframework.boot:spall-boot-maven-plugin:2.6.4:在项目bootloader上运行(默认):无法解析mojoorg.springframework.boot的配置:spall-boot-maven-plugin:2.6.4:run for参数包括:无法在类org中
我想使用firebase数据库,但当我点击“连接到firebase”按钮时,我遇到了这个问题....有人能帮我吗???