struts2.1.8+hibernate2.5.6+spring3.0 common exception causes and solutions

Source: Internet
Author: User
Tags filter mysql database tomcat

After the summer two months of SSH2 learning and OA Project training, I am in the Java technology well-known three major framework Ssh2 has gradually understand and grasp. From the construction of SSH2 framework environment began to write the first simple SSH2 landing procedures, to the end of the entire OA project, during the actual combat, encountered difficulties and obstacles, even the construction of the environment spent a whole day of Kung Fu, and the successful operation of the first SSH2 program spent several days, Of course, I believe that this is the most learning SSH2 this technology will experience the process, I believe that every programmer to learn any new technology will take the journey. Now, the project has been successfully concluded, in this joy, I would like to learn ssh2 some common problems encountered in the summary below, I hope we can take some detours, or in the face of problems can be resolved in a timely manner.

PS: My programming operating environment is MyEclipse8.6 + Tomcat6.1.3 + MySql

Problem one: Abnormal java.lang.NoSuchMethodError:antlr.collections.AST.getLine () problem

Reason: Is the jar package conflict, packet antlr2.7.2 and antlr2.7.6 conflict (one is tomcat under the package, one is to introduce their own SSH2 package)

Solution: Delete Package antlr2.7.2, specific methods:

Under MyEclipse,windows-->preferences--> search for struts2--> selection in the text box Antlr2.7.2-->remove

or delete Antlr2.7.2.jar directly in the directory web-inf\lib the application of Tomcat

Problem two: Abnormal java.lang.NullPointerException

Cause: The main reason for null pointer exceptions is as follows:

(1) When an object does not exist and then call its method will produce an exception

Obj.method ()//obj object does not exist

(2) An exception occurs when a field that does not exist for an object is accessed or modified

Obj.method ()//method does not exist

Solution: Debugging, to find out the specific causes of abnormal, and then specifically solve the specific reasons

Question three: Abnormal the Struts dispatcher cannot be found. This are usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the struts Dispatche R needed for this tag. -[Unknown Location]

Reason: struts2 filter mapping path was incorrectly written

Solution: Configure the Struts2 filter in Web.xml as follows:

<filter-mapping>

<filter-name>struts2</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

Notice:<url-pattern> here must be * *

Question four: org.hibernate.util.JDBCExceptionReporterorg.hibernate.util.JDBCExceptionReporter.logExceptions

(jdbcexceptionreporter.java:101)-Unknown type ' 246 in column 2 of 6 in binary-encoded result set.

Reason: When using MySQL database, some field values use Type decimal, bigint, etc.

Solution: Use MySQL database, avoid field value with decimal, bigint, etc., otherwise use Hibernate execution HQL statement will appear above the exception

Question five: After the action jump to get the page CSS and JS style introduction can not be applied

Reason: After the action jump the page path changed, not your page storage path

Solution: It is best to use the absolute path to introduce CSS and JS, such as the introduction of CSS available

<link href= "${pagecontext.request.contextpath}/css/css.css" rel= "stylesheet" type= "Text/css"/>

PS: You can also use the project name as an absolute path, such as the project name is OA, the above can also be introduced as follows:

<link href= "/oa/css/css.css" rel= "stylesheet" type= "Text/css"/>

It seems to be more brief, but personally not recommended, because once your project name is replaced, all the pages of OA will be followed by replacement, very cumbersome.

Question six: When using the Struts2 label <s:textfield/>, you cannot display more than one text box on a single line (one TextField for a row)

Reason: Beginner struts2, in the mind has been thinking about a problem, is for struts2, when applying its own label, for example:

<s:form>

<s:textfield name= "a" ></s:textfield>

</s:form>

When you view the source code:

<form>

<table>

<tr><td><input type= "text" Name=a/></td></tr>

</table>

</form>

The table TR TD tag is automatically added, and you cannot display multiple text boxes on one line.

Solution: Add the concept of theme (theme) in Struts2, by setting different themes, you can get struts code to output different HTML code, and you will have different layout effects accordingly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.