| |

VerySource

 Forgot password?
 Register
Search
View: 715|Reply: 7

hibernate file not found, novice. Looking for a whole afternoon and passed out

[Copy link]

2

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-23 11:40:01
| Show all posts |Read mode
The error is as follows:
log4j: WARN No appenders could be found for logger (org.apache.catalina.startup.Embedded).
log4j: WARN Please initialize the log4j system properly.
log4j: WARN No appenders could be found for logger (org.apache.commons.beanutils.ConvertUtils).
log4j: WARN Please initialize the log4j system properly.
log4j: WARN No appenders could be found for logger (org.apache.commons.beanutils.ConvertUtils).
log4j: WARN Please initialize the log4j system properly.
aaaaaaaaaaaaaaa: 11
bbbbbbbbbbbbbbbbb: 1111111
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Error reading resource: com / test / hibernate / bean / User.hbm.xml
at org.hibernate.cfg.Configuration.addResource (Configuration.java:452)
at org.hibernate.cfg.Configuration.parseMappingElement (Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory (Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure (Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure (Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure (Configuration.java:1112)
at com.test.hibernate.my.HibernateSessionFactory.currentSession (HibernateSessionFactory.java:48)
at com.test.hibernate.dao.UserDAO.save (UserDAO.java:14)
at com.test.hibernate.my.struts.action.UserAction.execute (UserAction.java:46)
at org.apache.struts.action.RequestProcessor.processActionPerform (RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process (RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process (ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost (ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext (StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal (StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext (StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext (StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext (StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext (StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke (ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service (CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.processConnection (Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt (PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool $ ControlRunnable.run (ThreadPool.java:683)
at java.lang.Thread.run (Thread.java:595)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream (Configuration.java:399)
at org.hibernate.cfg.Configuration.addResource (Configuration.java:449)
... 38 more
Caused by: org.xml.sax.SAXParseException: Attribute "resource" must be declared for element type "hibernate-mapping".
Reply

Use magic Report

2

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Unknown

 Author| Post time: 2020-2-6 02:15:01
| Show all posts
The main thing is this sentence (org.hibernate.MappingException: Error reading resource: com / test / hibernate / bean / User.hbm.xml), what is causing this problem?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-6 09:00:02
| Show all posts
User.hbm.xml is wrong, must be declared for element type "hibernate-mapping".
Reply

Use magic Report

2

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-2-6 13:00:02
| Show all posts
This is it


<? xml version = "1.0" encoding = 'UTF-8'?>
<! DOCTYPE hibernate-mapping PUBLIC "-// Hibernate / Hibernate Mapping DTD 3.0 // EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package = "com.test.hibernate.bean">

    <class name = "User" table = "user">
        <id name = "id" column = "id" type = "java.lang.Integer">
            <generator class = "native" />
        </ id>
        <property name = "username">
            <column name = "username" type = "java.lang.String" />
        </ property>
        <property name = "password">
            <column name = "pwd" type = "java.lang.String" />
        </ property>
    </ class>
    
</ hibernate-mapping>
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-8 23:30:01
| Show all posts
<property name = "username" type = "java.lang.String">
            <column name = "username" />
        </ property>
Is your type wrong? Look again, can you?
Reply

Use magic Report

2

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-2-16 13:15:01
| Show all posts
I did it upstairs and it was such a problem
"Hibernate: insert into user (username, pwd) values ​​(?,?) Select scope_identity ()"
org.hibernate.exception.GenericJDBCException: could not insert: [com.test.hibernate.bean.User]

Don't understand why
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-17 18:45:02
| Show all posts
When you write the save () method, user.id must also be assigned. If you don't want to set the id, you need to write HQL to implement.
Reply

Use magic Report

2

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-2-18 23:30:02
| Show all posts
Thank you upstairs, solved. Primary key problem
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list