Common Java Exceptions (Baidu Library)

Source: Internet
Author: User
Tags xml parser tld

1. java.lang.NullPointerException

This exception everyone must often encounter, the exception of the explanation is that the " program encountered a null pointer &quot, simply called an uninitialized object or a nonexistent object, this error often occurs in the creation of images, call array of these operations, the chip is not initialized, or a path error when creating a picture, and so on. A null pointer appears in an array operation, and in many cases is a common mistake made by friends who are just beginning to learn programming, which confuses the initialization of arrays and the initialization of the array elements. The initialization of an array is the space required for the allocation of arrays, and the initialized array, where the elements are not instantiated, are still empty, so you also need to initialize each element (if it is to be called).

2. java.lang.ClassNotFoundException This anomaly is a lot of programmers developed in the development environment, such as JB, put the package under the JB under WTK to compile the frequently occurring problem, the explanation of the exception is " the specified class does not exist &quot, the main consideration here is the name and path of the class is correct, if the package is done under the JB, is usually the default plus the packages, so go to the WTK after you should pay attention to the package path Add.

3. Java.lang.arithmeticexception the explanation of this anomaly is the " mathematical operation Anomaly &quot, for example, in the program divided by 0 such an operation will be such an exception, for this anomaly, We have to check the process of their own procedures involved in mathematical operations, the formula is not inappropriate.

4. Java.lang.arrayindexoutofboundsexception This exception is believed many friends also frequently encountered, the abnormal explanation is the " array subscript crosses ", now most of the program has an array of operations, Therefore, in the invocation of the array must be carefully checked to see if the subscript itself is beyond the range of the array, in general, the display (that is, directly with the constant subscript) call is not too easy to make such a mistake, but the implicit (that is, the use of variable representation subscript) calls are often wrong, there is a situation, The length of the array defined in the program is determined by certain methods and is not declared beforehand, so it is better to look at the length of the array before this exception occurs.

5. Java.lang.illegalargumentexception the explanation of this anomaly is that the parameters of the " method are &quot, and many of the methods in the J2ME class library can cause such errors in some cases. For example, the volume adjustment method in the volume parameter if written as a negative number will appear this exception, such as G.setcolor (int red,int green,int Blue) This method of three values, if there are more than 255 of the exception will occur, so once you find this exception, All we have to do is go check it out. The parameter passing in the method call is not an error.

6. Java.lang.illegalaccessexception the explanation for this exception is that " does not have access rights " This exception occurs when the application is calling a class, but the current method does not have access to the class.    Be aware of this exception in cases where the package is used in the program. There are many other exceptions, I will not enumerate, I would like to explain that a qualified programmer, the program needs to have a good understanding of the common problems and corresponding solutions, or just stay in the write process error occurs when the Web application is running, mainly because the specified class file is not in the Web Classpath in the server (/web-inf/classes and/web-inf/lib). In the above error, the reason is that the Actionform class could not be found.

--------------------------------------------------------------------------------------------------------------- --Exception javax.servlet.jsp.JspException:Exception creating Bean of Class Org.apache.struts.action.ActionForm:

{1} possible cause instantiating struts-provided Actionform class directly instead of instantiating a class derived off Actionform . This mightoccur implicitly if you specify that a Form-bean are this Struts Actionform class rather than specifying a child  Of this classfor the Form-bean. Not associating a actionform-descended class with an action can also leads to this error.

--------------------------------------------------------------------------------------------------------------- --Exception Javax.servlet.jsp.JspException:Cannot find Actionmappings or Actionformbeans collection

The probable cause is not that the <servlet> tag that identifies the struts Actionservlet is the map. do extension <sevlet-mapping> tag or neither is declared in Web. Xml. Typing or spelling errors in Struts-config.xml can also cause this exception to occur. For example, a closed symbol/> is missing for a token. It is best to check with the Struts console tool. In addition, the Load-on-startup must be declared in Web. XML, which is either an empty tag or a numeric value that is used to prioritize the servlet's run, and the higher the value, the lower the priority level. There is also a load-on-startup about using struts to precompile JSP files that can also cause this exception.

---------------------------------------------------------------------------------------------------------------  --Exception java.lang.NullPointerException at Org.apache.struts.util.RequestUtils.forwardURL (requestutils.java:1223) Possible cause The forward element in Struts-config.xml lacks the path property. For example, the following should be the form: <forward name= "Userhome" path= "/user/userhome.jsp"/>

---------------------------------------------------------------------------------------------------------------  --Exception Javax.servlet.jsp.JspException:Cannot find bean Org.apache.struts.taglib.html.BEAN in any scope probable causes An attempt was made to use a child element of a form outside of the form tag of struts. This often happens when you use struts in the HTML tags behind

------------------------------------------------------------------------------------------------------------ -----exception   Javax.servlet.jsp.JspException:Missing message for key xx.xx.xx probable causes  The value of this key is not defined in the resource file applicationresources.properties. If you often encounter this situation when you use Eclipse, eclipse will automatically delete the resource files in the classes directory when the project is recompiled.   Resource file applicationresources.properties not in Classpath should place the resource file in the Web-inf/classes directory, of course, defined in Struts-config.xml)  

--------------------------------------------------------------------------------------------------------------- --Exception cannot find message resources under key Org.apache.struts.action.MESSAGE possible cause it is obvious that this error occurred while using the resource file, and struts did not find the resource file. Implicitly trying to use message resources that is not available (such as using empty html:options tag instead of SPECIF Yingthe options in it body--This assumes options is specified in applicationresources.properties file) XML parser ISS UEs--too many, too few, incorrect/incompatible versions

---------------------------------------------------------------------------------------------------------------  --the exception Strange and seemingly the random characters in the HTML and on screen, and the not in original JSP or servlet.  Possible reasons for mixing the html:form tags with struts and the standard HTML tags are incorrect. The encoding style used is not supported on this page.

------------------------------------------------------------------------------------------------------------ -----exception   "Document contained no data" in netscape  no data rendered (completely empty) page in Microsoft Intern The ET Explorer may cause   use a derived class of action without implementing the Perform () method or the Execute () method. Implemented in Struts1.0 is the Perform () method, which is implemented in Struts1.1 with the Execute () method, but Struts1.1 backwards compatible with the perform () method. But you use Struts1.1 to create a derived class of action and implement the Execute () method, and you run it in Struts1.0, you get "Document contained NoData" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer. " Error message.  

------------------------------------------------------------------------------------------------------------ ---------------Exceptions   ServletException:BeanUtils.populate solutions   when uploading files with struts, Encountered an javax.servlet.ServletException:BeanUtils.populate exception.   My actionservlet does not use beanutils these tool classes. Later carefully check the code discovery is in the JSP file form forgot to add enctype=&quot;multipart/form-data&quot; The So writing programs that encounter errors or exceptions should consider the possibility of a problem in many ways, and think of something other than the system's cue message.  

------------------------------------------------------------------------------------------------------------ ----------------  1. After you define the action, if you specify name, you must define a Formbean with the same name as the form mapping. 2. If you define an action, "No input attribute for mapping path ..." appears when you submit a page Error, you need to define the page of the steering in its input property. 3. "Batch Update row count wrong: ..." appears when new data is inserted Error, the type of key specified in XXX.hbm.xml is the original type (int, long), because this type automatically assigns a value, and this value tends to make the system think that the record already exists. The correct approach is to use the Java.lang.Integer or Java.lang.Long object. 4. If you insert data with a "argument type mismatch" error, you may have used a special object such as date, Because struts cannot automatically convert from string to date, you need to manually convert the string type to date in the action. 5. In Hibernate, query iterator () is much faster than the list () method. 6. If the "equal symbol expected" error appears, your strtus tag contains another tag or variable, such as: 

--------------------------------------------------------------------------------------------------------------- ------------error: Exception in thread ' main ' org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch UPDA Te reason and resolution: because Hibernate tools (or eclipse itself's database Explorer) generates a *.hbn.xml tool that contains properties such as catalog= "* * *" (* for database names), deleting this property is OK

--------------------------------------------------------------------------------------------------------------- ------------Error: Org.hibernate.ObjectDeletedException:deleted object would is re-saved by cascade (remove deleted Object From associations) cause and Resolution: Method 1 Removes the Cascade method of the set party after resolving the association relationship, and then deleting Method 3 increases the cascade in the Many-to-one side but the value cannot be none the last trick: Check the hashcode eq Uals whether the ID is used as a unique option; I don't have a problem with Uuid.hex, but with native, I can't. Delete it!

--------------------------------------------------------------------------------------------------------------- -------------  PROBLEM: Today with Tomcat 5.5.12, found that the original very useful system can not be used, repeated testing found that the page can not contain taglib, otherwise the following prompt: HTTP Status 500-type  Exception Reportmessage Description The server encountered an internal error (), prevented it from fulfilling This&nbs P Request.exceptionorg.apache.jasper.JasperException:/index.jsp (unable) to read TLD "meta-inf/tlds/ Struts-bean.tld "from Jar file" File:*****/web-inf/lib/struts.jar ": Reason: Updated JAR under project Lib folder, Servlet.jar and Jsp-api.jar were also released at the time of publication. FIX: Remove Jsp-api.jar to solve this problem. --------------------------------------------------------------------------------------------------------------- --------------Error: java.lang.nullpointerexception  reason: Found DAO instance, manage instance and so on need to inject something not injected (commonly known as null pointer exception) Resolved: This time, You should look at the log file, the default is the log file of the application server, such as Tomcat is the [Tomcat installation directory]/logs ; you'll find a hint: maybe:org.springframework.beans.factory.beancreationexception:error  creating bean with Name ' SF ' Defined in Servletcontextresource [/web-inf/applicationcontext.xml]: Initialization of Bean failed; Nested exception isorg.hibernate.HibernateException:could not configure from url:  file:src/ Hibernate.cfg.xmlorg.hibernate.HibernateException:could not configure from url:  file:src/hibernate.cfg.xml "" " „„„„„„. caused by:  java.io.filenotfoundexception:src\ Hibernate.cfg.xml may be: Org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Sessionfactory ' defined Inservletcontext resource [/web-inf/applicationcontext.xml]: Initialization of Bean failed; Nested exception Isorg.hibernate.mappingexception:resource:com/mcc/coupon/model/userrole.hbm.xml not  foundorg.hibernate.mappingexception:resource:  Com/mcc/coupon/model/userrole.hbm.xml not Found then you know the reason is because the configuration file parsing error, this through the Web page is not visible. More is the persistence of the mapping of the errors of the file, resulting in not being parsed, of course, the functionality you need is not available. --------------------------------------------------------------------------------------------------------------- -------------error: standardwrappervalve[action]: Servlet.service () for Servlet Action threw exception  Javax.servlet.jsp.JspException:Cannot Retrieve mapping for action/settlementtypemanage  or:    & nbsp;  type Status report      message Servlet action is not available   & nbsp;  Description The requested resource (Servlet action is not available) is not available. Reason: Ditto  --------------------------------------------------------------------------------------------------- -------------------------  Error standardwrappervalve[jsp]: Servlet.service () for Servlet JSP threw exceptionjava.lang.classnotfoundexception:  Org.apache.struts.taglib.bean.CookieTei Interface Error specific description:  org.apache.jasper.JasperException:Failed to load or instantiate Tagextrainfo class: org.apache.struts.taglib.bean.cookietei        Causes and Solutions:    < Scenario One > your "HTML:" label does not fit in a

Common Java Exceptions (Baidu Library)

Related Article

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.