Summary of reasons for Java error

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

1. java.lang.NullPointerException

This exception is often encountered, the exception of the explanation is "the program encountered a null pointer", simply called an uninitialized object or a non-existent object, this error often occurs in the creation of images, call array of these operations, than the slice is not initialized, or the image is created by the path error, 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 developers originally developed in the development environment such as JB, put JB under the package under the WTK to compile frequently problems, the explanation of the exception is "The specified class does not exist", here the main consideration is the name and path of the class is correct, if it is in JB under the package, It is usually the default plus package, so go to the WTK and pay attention to add the package path.

3. Java.lang.arithmeticexception

The explanation of this anomaly is "mathematical operation Anomaly", for example, the program appears divided by 0 such an operation will be such an exception, for this anomaly, we will have to check the application of their own procedures involved in the mathematical operation of the place, the formula is not inappropriate.

4. Java.lang.arrayindexoutofboundsexception

This exception is believed many friends also often encountered, abnormal explanation is "array subscript out of bounds", now most of the program has an array of operations, so in the call arrays must be carefully checked, to see whether the subscript is beyond the range of the array, in general, The display (that is, directly with the constant subscript) call is not easy to make such a mistake, but the implicit (that is, the use of variable-subscript) calls are often wrong, there is also a case, the length of the array defined in the program is determined by certain methods, is not declared beforehand, it is better to look at the array length, To prevent this exception from occurring.

5. Java.lang.illegalargumentexception

The explanation of this exception is "parameter error of the method", and many methods in the J2ME class library can cause such errors in some cases, such as the volume parameter in the volume adjustment method, if it is written as a negative number, then the exception will occur, such as g.setcolor (int red,int green,int Blue) Three values in this method, if there are more than 255 of the exception will also occur, so once the exception is found, we have to do is to quickly check the method call in the parameter passed is not an error occurred.

6. Java.lang.illegalaccessexception

This exception is interpreted as "no access", which 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 state that a qualified programmer, the program needs to have a good understanding of common problems and corresponding solutions, otherwise just stay in writing procedures and will not change the program, will greatly affect their own development. The full description of the exception is available in the API.

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 Strutsconfig.xml, or no matching action is found, such as in a JSP file

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 Strutsconfig.xml. Most of the situation may be caused by a mismatch between the Name property set in Formbean 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 Strutsconfig.xml (that is, adding a tag).

The action class specified in Strutsconfig.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 webinf/classes, so your action class Must be in this directory. For example, if your action class is in Webinf/classes/action/login.class, then setting the action's property type in Strutsconfig.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 primarily in the form submission Formbean, which must have a getusername () method in Formbean when tagged with struts. Note the letter "U".

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 (/webinf/classes and/webinf/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 strutsprovided Actionform class directly instead of instantiating a class derived off actionform. This mightoccur implicitly if you specify that a Formbean are this Struts Actionform class rather than specifying a child O F this classfor the Formbean.

Not associating a actionformdescended class with an action can also leads to this error.

Abnormal

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

Possible causes

The tag that is not the actionservlet that identifies the struts is the mapping. do extension tags or both are not declared in Web. Xml.

Typing or spelling errors in Strutsconfig.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 Loadonstartup 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 loadonstartup 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 Strutsconfig.xml lacks the path property. For example, the following should be the form:



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 back of the HTML tag. Also note that you may inadvertently use a non-subject tag, such as the Web server parsing as a non-principal tag, and then all the tags used are considered outside the tag, such as the use of the taglib to introduce the HTML tag library, The value of the prefix you are using is not HTML.

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 Webinf/classes directory, of course, defined in Strutsconfig.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=& amp;quot;multipart/formdata ". 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 resaved by cascade (remove deleted object from Associatio ns

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 Manytoone 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 of 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 ' metainf/tlds/strutsbean.tld ' from JAR file ' file:*****/webinf/lib/ Struts.jar ": Reason: The jar under the project Lib folder was updated, and Servlet.jar and Jspapi.jar were released as well. FIX: Remove Jspapi.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 ; you'll find a hint: the org.springframework.beans.factory.BeanCreationException:Error creating Bean with the name ' SF ' defined in Servletcontextresource [/webinf/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 Yes: 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.mappingexception:resource:com/mcc/coupon/model/userrole.hbm.xml not found and then you know the reason is because the configurationFile parsing error, this is not visible through the Web page. 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 AV ailable) 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 solution:< > your "HTML:" tag is not placed in one of the < scenario two > Restart your application server, automatically without this problem

Summary of reasons for Java error

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.