Now, the SSH framework for "Customer Information maintenance" has ended, and the back-end operations involved include adding, deleting, checking, changing, generating Excel tables, and so on. Now I'm talking about a few of the problems that I often encounter during the creation process.
Question one:
Appear
class org.springframework.web.context.ContextLoaderListener ' Entitymanagerfactory ' defined inservletcontext resource [/web-inf/classes/applicationcontext.xml]:invocation of Init method failed; Nested exception isjava.lang.ExceptionInInitializerError caused By:java.lang.ExceptionInInitializerError
Or
class"Org.apache.commons.collections.SequencedHashMap
The above two errors are due to a version conflict between some jar files shared by spring and Hibernate, delete Web-inf/lib/asm-2.2.3.jar
Question two:
Org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:Line XML document from ServletContext Resource [/web-inf/applicationcontext.xml] is invalid;
The markup in the document following the root element must is well-formed.
Start the service, the above error, the Internet search for a bit, the main reasons are:
1, copy and paste, may be pasted in garbled. Manual input required.
2, in the Applicationcontext.xml file, the beginning of a space, resulting in the identification of the file. That is to ensure that the first sentence of the XML <?xml version= "1.0" encoding= "UTF-8"?> before there are no spaces.
3. The context is missing from the configuration file declaration.
4, when configuring the Spring configuration file, throw nested exception is org.xml.sax.SAXParseException; linenumber:15; ColumnNumber the exception because the namespace is not properly added.
5. In XML this refers to the properties file: <import resource= "Classpath:application.properties"/>
Change to <context:property-placeholder location= "classpath:application.properties"/> Just fine.
6, the element ' property ' must contain no characters [children], because the type's content type is "element only".
can add
<property name= "url" >${hibernate.connection.url}</property>
Switch
<property name= "url" >${hibernate.connection.url}/>
7, the beginning of the lack of <web-app>, that is, the XML document marked in the local format is not valid, but the DTD validation, so to conform to the specification, at the beginning of the XML file plus
<web-app version= "2.5" xmlns= "Http://java.sun.com/xml/ns/javaee" xmlns:xsi = "http://www.w3.org/ 2001/xmlschema-instance " xsi:schemalocation=" Http://java.sun.com/xml/ns/javaee http:// java.sun.com/xml/ns/javaee/web-app_2_5.xsd "> </web-app>
Question three:
Org.springframework.beans.factory.BeanDefinitionStoreException:IOException parsing XML document from ServletContext resource [/web-inf/classes/applicationcontext.xml]; Nested exception is java.io.FileNotFoundException:Could not open ServletContext resource [/web-inf/classes/ applicationcontext.xml]caused by:java.io.FileNotFoundException:Could not open ServletContext resource [/web-inf /classes/applicationcontext.xml]
View Code
appear as above error, checked, online said the error reason is basically: occurred in the configuration of Web. XML is problematic, add the following code as follows:
In the Web. xml file, add:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/ Web-inf/config/applicationcontext.xml</param-value> </context-param>
Or
<init-param> <param-name>contextConfigLocation</param-name> <param-value>/ Web-inf/classes/applicationcontext.xml</param-value> </init-param>
The main reason for the problem is that the problem is mainly due to the fact that the default profile location for loading spring is typically found under/web-inf/applicationcontext.xml file, and the eclipse file automatically generated ApplicationContext file is placed in/ Web-inf/classes/applicationcontext.xml, so the Applicationcontext.xml file cannot be found in the default load and must be added to the configuration above.
No matter what kind of addition, my plus later reported the following error:
Org.springframework.beans.factory.BeanDefinitionStoreException:IOException parsing XML document from ServletContext resource [/web-inf/classes/applicationcontext.xml]; Nested exception is java.io.FileNotFoundException:Could not open ServletContext resource [/web-inf/classes/ applicationcontext.xml]caused by:java.io.FileNotFoundException:Could not open ServletContext resource [/web-inf /classes/applicationcontext.xml]
1. Problems and solutions found are the same as above, that is, add these configurations in Web. xml
<context-param> <param-name>contextconfiglocation </param-name> <param-value>/ Web-inf/classes/applicationcontext.xml </param-value></context-param>
Or, you can put the IDE auto-generated applicationcontext.xml into the Web-inf folder.
2, may be your applicationcontext.xml did not introduce the external data source correctly
For example,:<!--introduce data sources--
<context:property-placeholder location= "Classpath:db.properties"/>
Question four:
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' sessionfactory ' defined in ServletContext resource [/web-inf/Applicationcontext.xml]: Invocation of Init method failed; nested exception is org. Hibernate. Invalidmappingexception:could not parse mapping document from input streamcaused by: Org.hibernate.InvalidMappingException:Could not parse mapping document from input stream
This error I met several times, online to find a lot of ways to try, did not succeed.
Finally, in the Cust.hbm.xml file under the bean,
"Http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
Switch
"Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
That's all you can do.
MyEclipse 6.5 integrated SSH (iii)