Common Java Exception types

Source: Internet
Author: User
Tags instance method unsupported xml parser tld

Java Exception:

1. Error
2. Runtime Exception run-time exception
3, Exception
4. Throw user Custom exception

There are two types of exception classes: the Error class represents compilation and system errors, does not allow capture, and the exception class represents exceptions that are fired by standard Java library methods. The exception class also contains two direct subclasses that run the exception class runtime_exception and the non-run exception class non_runtimeexception.

The run exception class corresponds to a compilation error, which refers to the various exceptions thrown by the interpreter at run time by the Java program. Running exceptions can occur anywhere and frequently, so the compiler does not check for exceptions in order to avoid huge system resource overhead. Therefore, running exceptions in the Java language are not necessarily captured. A running error often indicates an error in the code, such as an arithmetic exception (such as by 0), an subscript exception (such as an array out of bounds), and so on.

A non-running exception is an instance of the Non_runtimeexception class and its subclasses, also known as a detectable exception. The Java compiler detects whether the Java program contains a handler for detecting exceptions with the result of parsing methods or construction methods, and the throws clause for each possible detectable exception, method, or constructor must list the class corresponding to the exception. Exceptions defined in the Java standard package Java.lang Java.util and java.net are non-operational exceptions.

Arithmetic Exception class: Arithmeticexecption

Null pointer exception class: NullPointerException

Type cast Exception: ClassCastException

Array negative subscript exception: Negativearrayexception

Array subscript out-of-bounds exception: ArrayIndexOutOfBoundsException

Violation of security principle exception: Secturityexception

File ended exception: Eofexception

File not found exception: FileNotFoundException

string conversion to numeric exception: NumberFormatException


Manipulating Database Exceptions: SQLException


Input/Output exception: IOException


Method not found exception: Nosuchmethodexception

Java.lang.AbstractMethodError

Abstract method Error. Thrown when an application tries to invoke an abstract method.

Java.lang.AssertionError

Assertion is wrong. Used to indicate a condition in which an assertion failed.

Java.lang.ClassCircularityError

Class loop-dependent error. When a class is initialized, the exception is thrown if a circular dependency between the classes is detected.

Java.lang.ClassFormatError

The class format is incorrect. Thrown when a Java virtual machine attempts to read a Java class from a file and detects that the contents of the file do not conform to the valid format of the class.

Java.lang.Error

Error. is the base class for all errors that identify serious program run issues. These problems often describe anomalies that should not be captured by the application.

Java.lang.ExceptionInInitializerError

Initialization program error. Thrown when an exception occurs during the execution of a static initializer for a class. Static initializers refer to static statement segments that are included directly in the class.

Java.lang.IllegalAccessError

Illegal access error. This exception is thrown when an application attempts to access, modify, or invoke the domain (field) of a class or call its methods, but violate the visibility declaration of a domain or method.

Java.lang.IncompatibleClassChangeError

Incompatible class change error. This exception is thrown when an incompatible change is made to the class definition on which the method being executed depends. This error is easily thrown when you modify the declaration definition for some classes in your app without recompiling the entire application.

Java.lang.InstantiationError

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

Java.lang.InternalError

Internal error. Used to indicate an internal error occurred with the Java virtual machine.

Java.lang.LinkageError

Link error. The error and all its subclasses indicate that a class depends on another class, and after that class is compiled, the dependent class changes its class definition without recompiling all of the classes, which in turn raises the error condition.

Java.lang.NoClassDefFoundError

Class definition error not found. This error is thrown when a Java virtual machine or class loader attempts to instantiate a class and cannot find the definition of the class.

Java.lang.NoSuchFieldError

There are no errors in the domain. This error is thrown when an application attempts to access or modify a domain of a class that does not have a definition of that domain in the definition of that class.

Java.lang.NoSuchMethodError

Method has no errors. This error is thrown when an application attempts to invoke a method of a class that does not have the definition of the method in the definition of the class.

Java.lang.OutOfMemoryError

Insufficient memory error. This error is thrown when the available memory is insufficient for a Java virtual machine to be assigned to an object.

Java.lang.StackOverflowError

Stack overflow error. This error is thrown when the hierarchy of an application recursive call is too deep to cause a 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 a situation in which a Java virtual machine has an unknown critical error.

Java.lang.UnsatisfiedLinkError

An unsatisfied link error. Thrown when a Java virtual machine does not find a class that is declared as a native language definition of 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 discovers that the primary and minor version number of the file is not supported by the current Java virtual machine.

Java.lang.VerifyError

Validation error. This error is thrown when the validator detects an internal incompatibility or security issue in a class file.

Java.lang.VirtualMachineError

Virtual machine error. A condition that indicates that the virtual machine is compromised or that the resource required to continue performing the operation is insufficient.


Java.lang.ArithmeticException

Arithmetic condition exception. For example: integers except 0.

Java.lang.ArrayIndexOutOfBoundsException

Array index out-of-bounds exception. Thrown when the index value of an array is negative or greater than or equal to the size of the arrays.

Java.lang.ArrayStoreException

Array storage exception. Thrown when a non-array declaration type object is placed into the array.

Java.lang.ClassCastException

Class shape exception. Assuming that there are classes A and B (A is not a parent or subclass of B), and O is an instance of a, the exception is thrown when an O is forced to be constructed as an instance of Class B. This exception is often called coercion type conversion exception.

Java.lang.ClassNotFoundException

The class exception could not be found. This exception is thrown when an application attempts to construct a class based on a class name in string form, and when a class file of the corresponding name is not found after traversing Classpah.

Java.lang.CloneNotSupportedException

Cloning exceptions are not supported. When the Cloneable interface is not implemented or the Clone method is not supported, the exception is thrown by calling its clone () method.

Java.lang.EnumConstantNotPresentException

An enumeration constant does not have an exception. This exception is thrown when an application attempts to access an enumeration object by name and enumeration type, but the enumeration object does not contain a constant.

Java.lang.Exception

The root exception. Used to describe what the application wants to capture.

Java.lang.IllegalAccessException

An illegal access exception. This exception is thrown when an application attempts to create an instance of a class by reflection, accesses the class property, calls the class method, and then cannot access the definition of a class, property, method, or constructor method.

Java.lang.IllegalMonitorStateException

Violations of the monitoring State anomalies. This exception is thrown when a thread tries to wait for a monitor that does not own the object (O) or notifies other threads to wait for the object (O).

Java.lang.IllegalStateException

An abnormal state of law. This exception is thrown when the Java environment and the application are not already in the legal invocation state of a method, and the method is called.

Java.lang.IllegalThreadStateException

An illegal thread state exception. An exception is thrown when the county seat is not in the legal calling state of a method and the method is called.

Java.lang.IndexOutOfBoundsException

Index out-of-bounds exception. This exception is thrown when an index value that accesses a sequence is less than 0 or greater than or equal to the sequence size.

Java.lang.InstantiationException

Instantiate the exception. This exception is thrown when an attempt is made to create an instance of a class through the newinstance () method, which is an abstract class or interface.

Java.lang.InterruptedException

Aborted exception. This exception is thrown when a thread is in a long wait, hibernate, or other paused state while another thread terminates the thread through the interrupt method of the thread.

Java.lang.NegativeArraySizeException

The array size is a negative value exception. This exception is thrown when an array is created with a negative size value.

Java.lang.NoSuchFieldException

No exception exists for the property. This exception is thrown when a property that does not exist for a class is accessed.

Java.lang.NoSuchMethodException

Method has no exception. This exception is thrown when a non-existent method of a class is accessed.

Java.lang.NullPointerException

Null pointer exception. This exception is thrown when an app tries to use null where the object is required. For example: Call an instance method of a Null object, access the properties of a null object, evaluate the length of a null object, throw null with a throw statement, and so on.

Java.lang.NumberFormatException

Number format exception. This exception is thrown when an attempt is made to convert a string to the specified number type, and the string does not satisfy the format required by the number type.

Java.lang.RuntimeException

Run-time exception. is the parent class of exceptions that can be thrown during normal operation of all Java virtual machines.

Java.lang.SecurityException

Security exception. Thrown by the security manager to indicate an exception that violates the security situation.

Java.lang.StringIndexOutOfBoundsException

String index out of bounds exception. This exception is thrown when an index value is used to access a character in a string, and the index value is less than 0 or greater than or equal to the sequence size.

Java.lang.TypeNotPresentException

There is no exception for type. The exception is thrown when an app tries to access the type as a string representation of a type name, but the type is not found according to the given name. The difference between this exception and ClassNotFoundException is that the exception is unchecked (not checked) and ClassNotFoundException is a checked (checked) exception.

Java.lang.UnsupportedOperationException

Unsupported method exception. An exception that indicates that the requested method is not supported.

Abnormal
Javax.servlet.jsp.JspException:Cannot Retrieve mapping for Action/login (/login is your action name)

Possible causes
Action is no longer defined in Struts-config.xml, or no matching action is found, such as using --------------------------------------------------------------------------------------------------------------- --
Abnormal
Org.apache.jasper.JasperException:Cannot retrieve definition for form bean null

Possible causes

This exception is because struts does not find the action-expected form bean according to mapping in Struts-config.xml. Most of the situation may be caused by a mismatch between the Name property set in Form-bean and the Name property set in the action. In other words, both the action and the form should have a name attribute and exact match, including case. This error occurs when there is no Name property associated with the action, and if the Name property is not specified in action, then there is no Name attribute associated with the action. Of course, when the action makes certain controls, such as jumping to the corresponding JSP page based on the value of the parameter instead of processing the form data, this is not the name attribute, which is also one of the ways to use the action.
--------------------------------------------------------------------------------------------------------------- --
Abnormal
No action instance for path/xxxx could be created

Possible causes
Special note: Because there are a lot of things that can cause this error, it is recommended that you increase the log/debug level of your Web server so that you can see from more information the potential errors that occur when you try to create an action class. This action class you have already set up an association in Struts-config.xml (that is, add <action> tags).

The action class specified in Struts-config.xml by the class property of the action tag cannot be found for a number of reasons, such as the failure to locate the compiled. class file. Failure to places compiled. class file for the action in the Classpath (in WEB development, the position of class is in R web-inf/classes, so your action Clas s must be in this directory. For example, if your action class is in Web-inf/classes/action/login.class, then setting the action's property type in Struts-config.xml is Action.login).
Spelling errors, this also occurs, and is not easy to find, pay special attention to the first letter of the case and the name of the package.
--------------------------------------------------------------------------------------------------------------- --
Abnormal
Javax.servlet.jsp.JspException:No Getter method for property username of Bean Org.apache.struts.taglib.html.BEAN

Possible causes
The Getter method is not defined for a variable in a bit form bean

This error occurs mainly in the form submission Formbean, when --------------------------------------------------------------------------------------------------------------- --
Abnormal
Java.lang.noclassdeffounderror:org/apache/struts/action/actionform

Possible causes
This error mainly occurs when the corresponding Java. class file is not found in classpath. If this error occurs when the Web application is running, it is primarily because the specified class file is not in the classpath of the Web server (/web-inf/classes and/web-inf/lib). In the above error, the reason is that the Actionform class could not be found.
--------------------------------------------------------------------------------------------------------------- --
Abnormal
Javax.servlet.jsp.JspException:Exception creating Bean of Class Org.apache.struts.action.ActionForm: {1}

Possible causes
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.
--------------------------------------------------------------------------------------------------------------- --
Abnormal
Javax.servlet.jsp.JspException:Cannot find Actionmappings or Actionformbeans collection

Possible causes
The <servlet> tag that does not identify 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.
--------------------------------------------------------------------------------------------------------------- --
Abnormal
Java.lang.NullPointerException at Org.apache.struts.util.RequestUtils.forwardURL (requestutils.java:1223)

Possible causes
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"/>
--------------------------------------------------------------------------------------------------------------- --
Abnormal
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 --------------------------------------------------------------------------------------------------------------- --
Abnormal
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 files applicationresources.properties not in classpath should be placed in the Web-inf/classes directory, of course, defined in Struts-config.xml)
--------------------------------------------------------------------------------------------------------------- --
Abnormal
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 is not available (such as using empty html:options tag instead of specify Ingthe options in it body--This assumes options is specified in Applicationresources.properties file)

XML parser Issues--too many, too few, incorrect/incompatible versions
--------------------------------------------------------------------------------------------------------------- --
Abnormal
Strange and seemingly random characters in the HTML and on screens, but not in original JSP or servlet.

Possible causes
Mixed use of struts with html:form tags and standard HTML tags is incorrect.

The encoding style used is not supported on this page.
--------------------------------------------------------------------------------------------------------------- --
Abnormal
"Document contained no data" in Netscape

No data rendered (completely empty) page in Microsoft Internet Explorer

Possible causes
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.

--------------------------------------------------------------------------------------------------------------- ------------
Abnormal
ServletException:BeanUtils.populate
Solution Solutions
A Javax.servlet.ServletException:BeanUtils.populate exception was encountered while uploading a file with struts.
My actionservlet does not use beanutils these tool classes. Later carefully check the code found in the JSP file in the form forgot to add enctype= "Multipart/form-data". 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, for example:
Or
Such a situation ...
--------------------------------------------------------------------------------------------------------------- ------------
Error: Exception in thread ' main ' org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update reason and resolution: because HI Bernate tools (or the database Explorer of the eclipse itself) generates a *.hbn.xml tool that contains properties such as catalog= "* * *" (* for the name of the databases), which can be removed by deleting the property.
--------------------------------------------------------------------------------------------------------------- ------------
Error: Org.hibernate.ObjectDeletedException:deleted object would is re-saved by cascade (remove deleted object from Associati Ons
Reasons and Solutions:
Method 1 Delete The cascade of the Set party
Method 2 resolves the association relationship and then deletes
Method 3 adds cascade to the Many-to-one side but the value cannot be none
Last trick:
Check to see if Hashcode equals uses the ID as the only option, and I don't have a problem with Uuid.hex, but with native, I can't. Delete it!
--------------------------------------------------------------------------------------------------------------- -------------
Question: 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 prompts: HTTP Status 500-type Exception reportmessage Description The server encountered an internal error () that prevented it from fulfilling this 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: The jar under the project Lib folder was updated, and Servlet.jar and Jsp-api.jar were released as well. FIX: Remove Jsp-api.jar to solve this problem. --------------------------------------------------------------------------------------------------------------- --------------
Error: Java.lang.NullPointerException
Cause: Found DAO instances, manage instances, and so on need to inject something is not injected (commonly known as null pointer exception) to solve: this time, you should view the log file, the default is the application server log file, such as Tomcat is the [Tomcat installation directory]/logs; : May be: 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 and then you justKnow 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: Type Status report message servlet action was not available description The requested resource (Servlet action is not a vailable) is not available.
Reason: Ibid.
--------------------------------------------------------------------------------------------------------------- -------------
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
Reason and resolution: < plan one > your "HTML:" tag is not placed in a

Common Java Exception types

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.