JAVA Common exceptions

Source: Internet
Author: User
Tags integer division tld

 

1. java. lang. nullpointerexception

This exception is often encountered by everyone. The exception is explained by & quot; the program encounters a null pointer & quot;. Simply put, it calls an uninitialized object or a non-existent object, this error often occurs when you create an image. When you call an array, the image is not initialized, or the path when the image is created is incorrect. There is a null pointer in array operations. In many cases, it is a common mistake for some friends who are just learning programming, that is, to confuse array initialization with the beginning of array elements. Array initialization allocates the required space to the array. The elements in the initialized array are not instantiated and are still empty, therefore, you also need to initialize each element (if you want to call it)

2. java. lang. classnotfoundexception

This exception is a common problem that many programmers originally developed in jb and other development environments put the packages in jb under wtk for compilation. The exception is interpreted as & quot; the specified class does not exist & quot;. Here, we mainly consider whether the class name and path are correct. If the package is made under jb, package is usually added by default, therefore, add the package path after you go to wtk.

3. java. lang. arithmeticexception

This exception is interpreted as a & quot; mathematical operation exception & quot;. For example, if an operation such as dividing by zero exists in a program, this exception occurs, we need to check whether the formula is inappropriate in the mathematical operations involved in our program.

4. java. lang. arrayindexoutofboundsexception

This exception is often encountered by many friends. The exception is explained as & quot; array subscript out of bounds & quot;. Currently, most programs have Array Operations, therefore, when calling an array, you must carefully check whether the subscript you call exceeds the range of the array. In general, it is displayed (that is, the constant is used as the subscript directly) the call is not easy to make such an error, but the implicit (that is, using the variable table to show the subscript) call is often wrong, there is another situation, the length of the array defined in the program is determined by some specific methods, not stated in advance. At this time, it is best to first check the length of the array to avoid this exception.

5. java. lang. illegalargumentexception

This exception is interpreted as a & quot; method parameter error & quot;. Many methods in the j2s' class library may cause such errors in some situations, for example, if the volume parameter in the volume adjustment method is written as a negative number, this exception occurs, for example, g. setcolor (int red, int green, int blue) three values in this method, if there is more than 255, this exception will also occur, so once this exception is found, what we need to do, check whether the parameter passing in the method call is incorrect.

6. java. lang. illegalaccessexception

This exception is interpreted as & quot; no access permission & quot;. This exception occurs when the application calls a class but the current method does not have access permission for this class. Pay attention to this exception when package is used in the program.

There are still many other exceptions. I will not list them one by one. What I want to note is that a qualified programmer needs to have a good understanding of common problems in the program and corresponding solutions, otherwise, if you only write the program without modifying the program, it will greatly affect your development. For details about all exceptions, refer to the api.

Arithmetic exception class: ArithmeticExecption

Null Pointer exception class: NullPointerException

Type forced conversion exception: ClassCastException

Array negative subscript exception: NegativeArrayException

Array subscript out of bounds exception: ArrayIndexOutOfBoundsException

Security violation exception: SecturityException

File ended exception: EOFException

File not found exception: FileNotFoundException

An error occurred while converting the string to a number: NumberFormatException

Database Operation exception: SQLException

Input and Output exceptions: IOException

Method not found exception: NoSuchMethodException

Java. lang. AbstractMethodError

Incorrect abstract method. Thrown when an application tries to call an abstract method.

Java. lang. AssertionError

Assertion error. Used to indicate an assertion failure.

Java. lang. ClassCircularityError

Class loop dependency error. When initializing a class, if the cyclic dependency between classes is detected, this exception is thrown.

Java. lang. ClassFormatError

Class format error. When the Java Virtual Machine attempts to read a Java class from a file and detects that the content of the file does not conform to the valid format of the class, it throws.

Java. lang. Error

Error. Is the base class for all errors, used to identify serious program running problems. These problems usually describe abnormal situations that should not be captured by the application.

Java. lang. ExceptionInInitializerError

Initialization program error. Thrown when an exception occurs during the execution of a class static initialization program. Static initialization programs are static statement segments directly included in the class.

Java. lang. IllegalAccessError

Illegal access error. This exception is thrown when an application attempts to access, modify the Field of a class, or call its method, but violates the visibility Declaration of the domain or method.

Java. lang. IncompatibleClassChangeError

Incompatible class change error. This exception is thrown when the class definition on which the method being executed depends is incompatible. This error is easily caused when the Declaration definition of some classes in the application is modified without re-compiling the entire application.

Java. lang. InstantiationError

Instantiation error. This exception is thrown when an application attempts to construct an abstract class or interface using the new operator of Java.

Java. lang. InternalError

Internal error. Indicates that an internal error has occurred to the Java VM.

Java. lang. LinkageError

Link error. This error and all its subclasses indicate that a class depends on other classes. After the class is compiled, the dependent class changes its class definition and does not recompile all the classes, in this case, an error occurs.

Java. lang. NoClassDefFoundError

Class Definition error not found. This error is thrown when the Java Virtual Machine or classloader tries to instantiate a class but cannot find the definition of the class.

Java. lang. NoSuchFieldError

Domain does not exist. This error is thrown when an application attempts to access or modify a certain domain without the definition of this domain.

Java. lang. NoSuchMethodError

The method does not exist. This error is thrown when an application attempts to call a certain method without the definition of this method.

Java. lang. OutOfMemoryError

Memory insufficiency error. This error is thrown when the available memory is insufficient for the Java Virtual Machine to allocate to an object.

Java. lang. StackOverflowError

Stack overflow error. This error is thrown when the hierarchy of recursive calls of an application is too deep, resulting in stack overflow.

Java. lang. ThreadDeath

The thread ends. This error is thrown when the stop method of the Thread class is called to indicate the end of the Thread.

Java. lang. UnknownError

Unknown error. Used to indicate that the Java Virtual Machine has encountered an unknown serious error.

Java. lang. UnsatisfiedLinkError

A link error is returned. Thrown when the Java Virtual Machine does not find the native language definition of a class declared as the native method.

Java. lang. UnsupportedClassVersionError

Unsupported class version error. This error is thrown when the Java Virtual Machine attempts to read a class file but finds that the main and secondary versions of the file are not supported by the current Java virtual machine.

Java. lang. VerifyError

Verification error. This error is thrown when the validators detect internal incompatibility or security issues in a class file.

Java. lang. VirtualMachineError

Virtual Machine error. Indicates that the virtual machine is damaged or the resources required to continue the operation are insufficient.

Java. lang. ArithmeticException

Arithmetic condition exception. For example, integer division by zero.

Java. lang. ArrayIndexOutOfBoundsException

An error occurred while exiting the array index. If the index value of the array is negative or greater than or equal to the size of the array, throw.

Java. lang. ArrayStoreException

An error occurred while storing the array. It is thrown when a non-array declared object is stored in the array.

Java. lang. ClassCastException

Class styling exception. Suppose there are classes A and B (A is not the parent class or subclass of B), and O is the instance of A, then this exception is thrown when an instance of Class B is forcibly constructed by O. This exception is often called a forced type conversion exception.

Java. lang. ClassNotFoundException

Class exception not found. This exception is thrown when the application tries to construct a class based on the class name in the string format and cannot find the class file with the corresponding name after traversing the CLASSPAH.

Java. lang. CloneNotSupportedException

Clone exceptions are not supported. If the Cloneable interface is not implemented or the clone method is not supported, this exception is thrown when the clone () method is called.

Java. lang. EnumConstantNotPresentException

The enumerated constant does not exist. This exception is thrown when an application attempts to access an enumeration object by name or enumeration type, but this enumeration object does not contain constants.

Java. lang. Exception

Root exception. Used to describe what the application wants to capture.

Java. lang. IllegalAccessException

Illegal access exception. When an application tries to create an instance of a class, access this class attribute, and call this class method through reflection, at that time, the exception could not be thrown when defining the category, attribute, method, or constructor.

Java. lang. IllegalMonitorStateException

Illegal monitoring status exception. This exception is thrown when a thread tries to wait for a monitor of an object (O) that it does not own or notifies other threads to wait for the monitor of this object (O.

Java. lang. IllegalStateException

Illegal status exception. If a method is called while the Java environment and application are not in the valid call state of a method, this exception is thrown.

Java. lang. IllegalThreadStateException

The invalid thread status is abnormal. When the county seat is not in the valid call status of a method and the method is called, an exception is thrown.

Java. lang. IndexOutOfBoundsException

An exception occurred when the index was out of bounds. This exception is thrown when the index value for accessing a sequence is smaller than 0 or greater than or equal to the sequence size.

Java. lang. InstantiationException

Instantiation exception. This exception is thrown when an instance of a class is created using the newInstance () method and the class is an abstract class or interface.

Java. lang. InterruptedException

Aborted exception. This exception is thrown when a Thread is in a long wait, sleep, or other pause State and other threads terminate the Thread through the interrupt method of the Thread.

Java. lang. NegativeArraySizeException

An error occurred while the array size is negative. This exception is thrown when an array is created with a negative value.

Java. lang. NoSuchFieldException

The property does not exist. This exception is thrown when you access a non-existent attribute of a class.

Java. lang. NoSuchMethodException

Method does not have an exception. This exception is thrown when a method that does not exist to access a class.

Java. lang. NullPointerException

Null Pointer exception. This exception is thrown when the application tries to use null where the object is required. For example, call the instance method of the null object, access the attribute of the null object, calculate the length of the null object, and throw null using the throw statement.

Java. lang. NumberFormatException

The number format is incorrect. This exception is thrown when you try to convert a String to a specified numeric type that does not meet the numeric type requirements.

Java. lang. RuntimeException

Exception during running. It is the parent class of all exceptions that can be thrown during normal operations of Java virtual machines.

Java. lang. SecurityException

Security exception. Thrown by the security manager to indicate exceptions that violate security conditions.

Java. lang. StringIndexOutOfBoundsException

An exception occurred when the string index was out of bounds. If the index value is used to access a character in a string and the index value is smaller than 0 or greater than or equal to the sequence size, this exception is thrown.

Java. lang. TypeNotPresentException

Type does not exist. When an application attempts to access a type by using a string expression of a type name, but cannot find the type based on the given name, this exception is thrown. This exception differs from ClassNotFoundException because it is an unchecked (not checked) exception, while ClassNotFoundException is a checked (checked) exception.

Java. lang. UnsupportedOperationException

The method is not supported. Exception that indicates that the requested method is not supported.

Exception

Javax. servlet. jsp. JspException: Cannot retrieve mapping for action/Login (/Login is your action name)

Possible causes

The action has no strutsconfig. the action is defined in xml, or no matching action is found. For example, in the JSP file, use

Exception

Org. apache. jasper. JasperException: Cannot retrieve definition for form bean null

Possible causes

This exception occurs because Struts does not find the form bean expected by the action according to the mapping in strutsconfig. xml. In most cases, the reason may be that the name attribute set in formbean does not match the name attribute set in action. In other words, action and form should each have a name attribute and must be exactly matched, including case sensitivity. This error occurs when no name attribute is associated with action. If the name attribute is not specified in action, no name attribute is associated with action. Of course, when an action creates some controls, for example, jump to the corresponding jsp page based on the parameter value, instead of processing the form data, this does not require the name attribute, which is also one of the methods to use the action.

Exception

No action instance for path/xxxx cocould be created

Possible causes

Note: This error may occur in many cases. We recommend that you increase the log/debugging level of your web server, in this way, we can see the potential errors that occur when trying to create an action class from more information. This action class is already in strutsconfig. the <action> tag is added ).

In strutsconfig. xml, the action class specified by the class attribute of the action tag cannot be found for many reasons, for example, locating the compiled. class file fails. Failure to place compiled. class file for the action in the classpath (in web development, the class is located in r WEBINF/classes, so your action class must be in this directory. For example, if your action class is in WEBINF/classes/action/Login. class, set the action attribute type in strutsconfig. xml to action. Login ).

Spelling error. This also occurs from time to time and is not easy to find. Pay special attention to the case of the first letter and the name of the package.

Exception

Javax. servlet. jsp. JspException: No getter method for property username of bean org.apache.struts.taglib.html. BEAN

Possible causes

No variable in form bean defines the getter Method

This error occurs mainly in FormBean submitted by form. When

Exception

Java. lang. NoClassDefFoundError: org/apache/struts/action/ActionForm

Possible causes

This error mainly occurs when the corresponding Java. class file cannot be found in classpath. If this error occurs when the web application runs, it is mainly because the specified class file is not in the classpath of the web server (/WEBINF/classes and/WEBINF/lib ). In the above error, the cause is that the ActionForm class cannot be found.

Exception

Javax. servlet. jsp. JspException: Exception creating bean of class org. apache. struts. action. ActionForm: {1}

Possible causes

Instantiating Strutsprovided ActionForm class directly instead of instantiating a class derived off ActionForm. This variable implicitly if you specify that a formbean is this Struts ActionForm class rather than specifying a child of this classfor the formbean.

Not associating an ActionFormdescended class with an action can also lead to this error.

Exception

Javax. servlet. jsp. JspException: Cannot find ActionMappings or ActionFormBeans collection

Possible causes

The <servlet> tag that does not identify Struts actionServlet is the <sevletmapping> tag mapped to the. do extension, or neither of them is declared in web. xml.

Typing or spelling errors in strutsconfig. xml can also cause this exception. For example, a flag of the close symbol/> is missing. It is best to use the struts console tool to check.

In addition, loadonstartup must be declared in web. xml. This is either an empty tag or a value. This value is used to indicate the priority of the servlet operation. The higher the value, the lower the priority.

Another issue related to using loadonstartup is that this exception may also occur when JSP files are pre-compiled using Struts.

Exception

Java. lang. NullPointerException at org. apache. struts. util. RequestUtils. forwardURL (RequestUtils. java: 1223)

Possible causes

The forward element in strutsconfig. xml lacks the path attribute. For example, the format is as follows:

<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

Try to use the child element of form outside the form tag of Struts. This often happens when you use the html Tag of Struts after

Exception

Javax. servlet. jsp. JspException: Missing message for key xx. xx. xx

Probable Causes

The value pair of this key is not defined in the resource file ApplicationResources. properties. If you often encounter this situation when using eclipse, eclipse will automatically delete the resource files under the classes directory when the project is re-compiled.

The resource file ApplicationResources. properties does not include the resource file in classpath, which must be defined in strutsconfig. xml)

Exception

Cannot find message resources under key org. apache. struts. action. MESSAGE

Possible causes

Obviously, this error occurs when the resource file is used, and Struts does not find the resource file.

Implicitly trying to use message resources that are not available (such as using empty html: options tag instead of specifyingthe options in its body this assumes options are specified in ApplicationResources. properties file)

XML parser issues too records, too few, incorrect/incompatible versions

Exception

Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet.

Possible causes

The html: form tag and standard HTML tag used in combination with Struts 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 Internet Explorer

Possible causes

Use a derived class of an Action without implementing the perform () method or the execute () method. In Struts1.0, The perform () method is implemented. In Struts1.1, The execute () method is implemented, but Struts1.1 is backward compatible with the perform () method. However, you use Struts1.1 to create an Action derived class and implement the execute () method. If you run it in Struts1.0, the "Document contained nodata" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer is displayed. "error message.

Exception

ServletException: BeanUtils. populate

Solution

When uploading files with Struts, A javax. servlet. ServletException: BeanUtils. populate exception occurs.

BeanUtils is not used in my ActionServlet. Later, I checked the code and found that the form in the jsp file forgot to add enctype = & amp; quot; multipart/formdata & quot. Therefore, when a program encounters an error or exception, you should consider the possibility of the problem from many aspects and think of something other than the system prompts.

1. after an Action is defined, if the name is specified, a FormBean with the same name must be defined before form ing can be performed. 2. if "No input attribute for mapping path... "error, You need to define the page for turning in its input attribute. 3. if "Batch update row count wrong :... "error, indicating XXX. hbm. the type of the key specified in xml is the original type (int, long), because a value is automatically assigned for this type, which often makes the system think that the record already exists, the correct method is to use java. lang. integer or java. lang. long object. 4. if the "argument type mismatch" error occurs during data insertion, you may have used special objects such as Date, because struts cannot automatically convert the String type to the Date type, you need to manually convert String type to Date type in Action. 5. in Hibernate, The iterator () of Query is much faster than the list () method. 6. if the error "equal symbol expected" occurs, it indicates that your strtus tag contains another tag or variable, for example:

<Html: select property = "test" onchange = "<% = test %>"/>

Or

<Html: hidden property = "test" value = "<bean: write name =" t "property =" p "/>"/>

This situation...

Error: Exception in thread "main" org. hibernate. exception. SQLGrammarException: Cause and solution of cocould not execute JDBC batch update: it is generated by Hibernate Tools (or the Database Explorer of Eclipse *. hbn. the xml tool contains an attribute such as catalog = "***" (* indicates the database name). You can delete this attribute.

Error: org. hibernate. ObjectDeletedException: deleted object wocould be resaved by cascade (remove deleted object from associations)

Cause and solution:

Method 1 Delete the cascade of the Set side

Method 2 Delete the link after it is resolved

Method 3 add cascade on the manytoone side, but the value cannot be none.

Last move:

Check if hashCode equals uses id as the unique identifier. I use uuid. hex, but native is not used. What should I do? Delete!

Problem: Tomcat 5.5.12 is used today, and it is found that a very useful system is unavailable. repeated tests show that the page cannot contain taglib. Otherwise, the following prompt is displayed: HTTP Status 500 type Exception reportMessage description The server encountered an internal error () that prevented it from fulfilling this request. predictionorg. apache. jasper. jasperException:/index. jsp (1, 1) Unable to read TLD "METAINF/tlds/strutsbean. tld "from JAR file" file: *****/WEBINF/lib/struts. jar ": cause: updated the jar in the lib folder of the project, and se is also released at the time of release. Rvlet. jar and jspapi. jar. Solution: delete jspapi. jar to solve this problem.

Error: java. lang. NullPointerException

Cause: the dao instance, manage instance, and other things to be injected have not been injected (commonly known as a null pointer exception) solved: at this time, you should view the log file; the default is the log file of the application server. For example, Tomcat is the [Tomcat installation directory]/logs. You will find the prompt: org. springframework. beans. factory. beanCreationException: Error creating bean with name 'sf 'defined in ServletContextresource [/WEBINF/applicationContext. xml]: Initialization of bean failed; nested exception isorg. hibernate. hibernateException: cocould not configure from URL: file: sr C/hibernate. cfg. xmlorg. hibernate. HibernateException: cocould 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 [/WEBINF/applicationContext. xml]: Initialization of bean failed; nested exception isorg. hibernate. mappingException: Resource: com/mcc/coupon/model/UserRole. hbm. xml not foundorg. hibernate. mappingEx Ception: Resource: com/mcc/coupon/model/UserRole. hbm. xml not found then you will know the reason is that the parsing of the configuration file is incorrect, which cannot be seen through the Web page. What's more is the error of the persistent shadow file, which causes the file to be not parsed. Of course, the functions you need cannot be used.

Error: StandardWrapperValve [action]: Servlet. service () for servlet action threw exception

Javax. servlet. jsp. JspException: Cannot retrieve mapping for action/settlementTypeManage

Or: type Status report message Servlet action is not available description The requested resource (Servlet action is not available) is not available.

Cause: Same as above

Error StandardWrapperValve [jsp]: Servlet. service () for servlet jsp threw exceptionjava. lang. ClassNotFoundException: org. apache. struts. taglib. bean. CookieTei interface error details:

Org. apache. jasper. JasperException: Failed to load or instantiate TagExtraInfo class: org. apache. struts. taglib. bean. CookieTei

Cause and solution: <solution 1> the tag starting with "html:" is not placed in

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.