Summary of Exception/error and solution records encountered

Source: Internet
Author: User
Tags connection reset apache tomcat

First, Java.net.SocketException

1. Java.net.SocketException:Connection Reset

First, if one end of the socket is closed (or is actively closed or closed due to an abnormal exit), the other end still sends the data, and the first packet sent throws the exception (Connect reset by peer).
Then, one end exits, but the connection is not closed when exiting, and the other end throws the exception if it reads data from the connection (Connection reset).
The simple thing is that the read and write operations are caused by the disconnection of the connection.

2, if the error is java.net.SocketInputStream.read (): Consider the input stream to read the resource does not exist or the format is wrong, it may be the path address error

3, socket-detailed analysis no buffer space available: see http://www.cnblogs.com/hjwublog/p/5114380.html

Second, org.hibernate.Exception

1. Org.hibernate.ObjectNotFoundException:No row with the given identifier exists:

The reason may be that the fields in the Pojo mapping file do not match the fields in the table in the database (inconsistent). Another possibility is that there is an association between table A and table B, and when you query the qualifying record in Table B from table A by a foreign key, the corresponding record is not found in table B, but the association continues to persist!

It is likely that the cascade operation was set. Or when you delete a record of table A, you do not delete the records associated with table B at the same time!!!

2, org.hibernate.PropertyAccessException:exception setting property value:

This is primarily an error caused by a null field in the number type in the database. It's pretty good to understand. Returns NULL when Hibernate gets empty, but an error occurs if the type in the mapping file you are configuring is a long or other base data type. There are 2 ways to solve this problem

First: Set the default value for the database, if it is a number type or other type after mapping is the base data.

Second: The set in the Pojo class passes through the wrapper class of the base data type, then makes a judgment, and assigns the default value if it is null.

3, Org.hibernate.LazyInitializationException:could not initialize proxy-no Session:

This is a lazy use of the exception, using a late load, in the session (Hibernate session), closed after using the object's non-loaded variables, that is, the session has been closed, not saved into memory, and then you used, causing the exception.

Reason:<may-to-one>or<one-to-may> The Lazy property defaults to: Lazy = "proxy"
Fix:<many-to-one> & <set> set lazy= "false"

Third, org.apache.jasper.jasperException

When accessing the JSP, Error: Attribute value is quoted with "which must was escaped when used within the value. I believe that many people have encountered, the following combination of my search information and personal practice to get the conclusion. (Please advise me of the wrong place.)
Where the error often occurs value= "<%=" "+request.getattribute (" name ")%>"
The cause of the error is because the Tomcat version has been upgraded (after 6.0) and the handling mechanism of the double quotation marks, which can occur if double quotation marks are present in the case of double quotes.
There are many solutions, most of the online opinion is changed to value= ' <%= "" +request.getattribute ("name")%> ' This can really solve this error, may not completely solve the problem, For example, there are many places in the project that used double quotes, which can be cumbersome and error prone.
View Tomact Documentation There is a paragraph of this description of the "If false the requirements for escaping quotes in JSP attributes would be a relaxed so this an unescaped q Uote won't cause an error.
If not specified, the specification compliant default of TRUE would be used. "This description is for Tomact Org.apache.jasper.compiler. The Parser.strict_quote_escaping property.
As a result, we know that this problem can be solved by setting this property to False when Tomcat starts.
So how do you set this property to Tomcat's system property, with at least two options:
One is to use Tomcat-initiated execution scripts to invoke setenv.sh during execution, where environment variables are set, such as: java_opts=%java_opts%:- Dorg.apache.jasper.compiler.parser.strict_quote_escaping=false
The other is to find the Conf/catalina.properties file and add Org.apache.jasper.compiler.parser.strict_quote_escaping=false at the end.

Iv. Java.lang.NoClassDefFoundError:TagSupport

This error should be the Jsp-api.jar of the jar package that was not successfully loaded with Tomcat.

On the internet to see a lot of netizens said to Tomcat/lib under the Jsp-api.jar copy to the project/web_inf/lib and import, I tried a bit this is problematic, so although in the start Tomcat will not error but in running the program (such as open Web page) The error occurs because the jar package is conflicting.

Workaround:

1. Quoting Jsp-api.jar

Project Right--->properties-->java Build path-->libraries-->add External jres-->tomcat under Jsp-api.jar

2. Directly integrated into Tomcat's jar package

Project Right-click-->properties-->java Build path-->libraries-->add library-->server runtime-->apache Tomcat xx

Note: When you have referenced the Jsp-api.jar under Tomcat/lib, the following error is reported when running the program:

Java.lang.ClassCastException:org.apache.struts.taglib.bean.CookieTei cannot is cast to Javax.servlet.jsp.tagext.TagExtraInfo

Need to go to your post project: that is/tomcat xxx/webapps/project name/web-inf/lib go down and delete Jsp-api.jar, then restart Tomcat.

Wu, Javax.net.ssl.SSLHandshakeException

I. Error: Javax.net.ssl.SSLHandshakeException

II. Cause Analysis:
CAS deployments often involve the issue of certificate publishing for HTTPS. Because CAs and application services often share a single PC in an experimental environment, they run on the same JRE environment and Tomcat server, ignoring the actual use of the certificate, and when the CAs and applications are deployed on separate machines, they faint!

This assumes the following experimental environment to illustrate the appropriate deployment
Machine A: Deploy CAS service
Machine B: Deploying OA applications
Machine C: User browser side

1. A. KeyStore certificate file generated by machine A, the certificate issuer is the full domain name of machine A
2. The configuration of the HTTPS in the Server.xml file for the tomcat that is used to deploy CAS on machine A, point to the. keystore File Certificate
3. The credential file exported from. KeyStore is copied to machine B and imported into the certificate Library of Machine B's JRE environment
4. Tomcat deploying OA on machine B must specify that it is running on the import credentials JRE environment, not the JDK, which is often mistaken.

III. Import Certificate steps:
1. Locate the JRE
1) The OA application of Machine B is deployed directly in Tomcat
>>> Independent JRE
If you choose to install the JRE at the same time when installing the JDK, the system runs on a separate JRE.
Why? Because the program automatically helps you to add the JRE's java.exe to the system variables when installing the standalone JRE, the verification method is simple, and we see that the system environment variable has "%systemroot%system32;%systemroot%" in the front of the path. Such a configuration,

Then go to windows/system32 below to see it, find out what? There is a java.exe.
JRE in >>>JDK.
If the standalone JRE is not installed at the same time, the system runs on the JRE that comes with the JDK.
2) The OA application of Machine B is developed and tested in MyEclipse.
myeclipse-right Project-java Build path-libraries-Double-click jre-is generally workspace default JRE;
Myeclipse-windows-preferences-java-installed jres-to the right of the MyEclipse default comes with the JDK, double-click to find the JRE home;
2. Copy the certificate to machine a xxx.cer file to machine B
3. Import commands
CMD into the command line window; CD into JRE directory \lib\security;
Keytool-import-alias cacerts-keystore JRE Directory \lib\security\cacerts-file certificate directory \xxx.cer-trustcacerts;
Prompt Enter password: changeit;
OK: Y
4. If Keytool is not available, see if the Path,classpath is configured correctly.

Iv. Self-summarized certificate import step (cmd into command Line window, CD into JRE directory \lib\security):

1. View Certificate: Keytool-list-keystore/xxx/cacerts-storepass Changeit

2. Delete the certificate with the same name: Keytool-delete-alias certificate name-keystore/xxx/cacerts-keypass Changeit

3. Import Certificate: Keytool-import-alias certificate name-file/xxx/server.cer-keystore/xxx/cacerts-storepass Changeit or

Keytool-import-v-rfc-trustcacerts-alias certificate name-file/xxx/server.cer-keystore/xxx/cacerts-storepass Changeit-keysto Re Cacerts is located in the full path-storetype JKS;

4. If Keytool is not available (hints are not internal commands); Cd/xxx/jdk1.xxx/bin

or directly inside the classpath configuration%java_home%\lib\tools.jar;

Six, casauthenticationexception:unable to validate Proxyticketvalidator

Single Sign-On error: Unable to validate Proxyticketvalidator
Edu.yale.its.tp.cas.client.CASAuthenticationException:Unable to validate Proxyticketvalidator
[[Edu.yale.its.tp.cas.client.ProxyTicketValidator proxylist = [NULL]
[Edu.yale.its.tp.cas.client.ServiceTicketValidator Casvalidateurl =
[https://sourcesite:8443/cas/proxyvalidate] TICKET=[ST-0-UMJSI0YOHF15RHUTNKHW]
Service=[http%3a%2f%2fdestsite%3a8080%2fservlets-examples%2fservlet%2fhelloworldexample]
Renew=false]]
...

Possible causes:
1. The certificate was not correctly generated and imported. In the SSL handshake, CAS client does not recognize the CAS server certificate (x), which means that a trust path from the Cacerts Trust certificate to x cannot be established, and the reader can see a specification called the PKIX.
The workaround is to check the trusted certificate path used by Tomcat, usually the Jre/lib/security/cacerts file, to see if the required trust certificate has been imported.
2. The domain name is not used as the access server.
3. The JVM used by Tomcat is not the JVM of the system's default JDK, which often occurs.

Vii. Java.lang.OutOfMemoryError:Java Heap Space

1, first of all to determine whether to run multiple Java processes,
2, and then look at the Tomcat/wapps below is not forgot to remove the project (I just closed a previous project, but still in Wapps not removed)

3, cause Java.lang.OutOfMemoryError:Java heap space exception, may be caused by the Java stack setting is too small

There are two ways to solve these questions on the Internet:

1), at the front of the D:/apache-tomcat-6.0.18/bin/catalina.bat join: Set java_opts=-xms384m-xmx384m

Note: Only Startup.bat starts Tomcat, the settings will take effect, and if you start the Tomcat service with Windows system services, the settings above will not take effect.
Which means set java_opts=-xms384m-xmx384m doesn't work.

2), modify the startup parameters in Eclilpse, add-xms384m-xmx384m in VM arguments, set as shown

        

Viii. java.lang.RuntimeException:Unable to create XMLReader

XmlReader Read File exception:

Java.lang.RuntimeException:Unable to create XMLReader
Org.jasig.cas.client.util.XmlUtils.getXmlReader (xmlutils.java:44)
Org.jasig.cas.client.util.XmlUtils.getTextForElement (xmlutils.java:116)
Root cause

Java.lang.ClassNotFoundException:org.apache.xerces.parsers.SAXParser

...

Workaround: (Jar package download)

Import Dom4j.jar and Xerces.jar; In particular, a later jar package is required.

Nine:

Summary of Exception/error and solution records encountered

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.