1. It is also the most annoying: nullpointerexception. Nullpointerexception often occurs during SSH integration. There are many reasons for this error. Bean injection, that is, errors in the spring configuration file; Integration of struts2 and spring. This error also occurs if integration fails. Let's talk more about the second case, because today I encountered this error. It is also a common sense error that struts2 does not integrate Spring applications.
Here we will briefly discuss the integration of struts2 and spring: first, the introduction of struts2Struts2-spring-plugin-2.2.1.jar and other struts2
The required package is then struts in the configuration file. XML should be added: <constant name = "struts. objectfactory "value =" org. apache. struts2.spring. strutsspringobjectfactory "/> indicates integration with spring.
I think it is necessary to describe in detail the problem I encountered today: I can test it successfully through the method in the action class configured by spring, but nullpointerexception occurs during access to the JSP page, it took half a day to discover this error !! But the error is solved !!
2.
Java. Lang. nosuchmethoderror: anlr. Collections. Ast. Getline (). This error is also quite prone. The cause of this error is the conflict between Alibaba Cloud and Alibaba Cloud. Antlr-2.7.6.jar in struts2 and Hibernate are there, respectively when using the framework is no problem but if the integration will appear such a problem, remove a lower version of The can be!
3. The form parameters cannot be instantiated after the interceptor is configured !! Why? The cause of this problem involves the struts automatic loader System, but the solution is quite simple, and the default interceptor of struts2 is also configured !! If no parameters passed by the interceptor form are configured in the application, they cannot be automatically loaded as objects !!
4. hibernate session management issues:Write operations are not allowed in read-only mode (flushmode. Never/manual)
! This is an exception caused by the use of spring opensessioninview !! There are a lot of online solutions. I used this solution:
< Init - Param >
< Param - Name > Singlesession </ Param - Name >
< Param - Value > True </ Param - Value >
< Param - Name > Flushmode </ Param - Name >
< Param - Value > Auto </ Param - Value >
</ Init - Param >
There is also a scheme to be configured in the spring configuration file:
< Bean ID = " Basetransaction "
Class = " Org. springframework. transaction. Interceptor. transactionproxyfactorybean "
Abstract = " True " >
< Property name = " Transactionmanager " Ref = " Transactionmanager " />
< Property name = " Proxytargetclass " Value = " True " />
< Property name = " Transactionattributes " >
< Props >
< Prop key = " Get * " > Propagation_required, readonly </ Prop >
< Prop key = " Find * " > Propagation_required, readonly </ Prop >
< Prop key = " Load * " > Propagation_required, readonly </ Prop >
< Prop key = " Save * " > Propagation_required </ Prop >
< Prop key = " Add * " > Propagation_required </ Prop >
< Prop key = " Update * " > Propagation_required </ Prop >
< Prop key = " Del * " > Propagation_required </ Prop >
</ Props >
</ Property >
</ Bean >
5. The ing between complex cross of hibernate. Today I met Org. springframework. orm. hibernate3.hibernatesystemexception: illegalargumentexception occurred while calling setter of Org. blog. po. user. ulog; Nested exception is Org. hibernate. propertyaccessexception: illegalargumentexception occurred while calling setter of Org. blog. po. user. errors such as ulog (the error type is the same, but the specific information is different ). The error message indicates Type Mismatch: The type does not match. I have been wondering because I have checked it several times and it's okay! Finally, we found the root cause of the problem. First, let me explain the relationship: associated objects, users, and groups. You can create a group with multiple users. It sounds simple, but an error occurs.
Analyze the cause: At the beginning, I used a two-way Association to solve the efficiency problem. In fact, this is the root cause of the Error. There are two associations between users and groups, hibernate cannot tell users who are creators and users, so this problem occurs. Simply abandon the two-way relationship, and both parties use one-way relationship. The problem is solved !!
6. The error message is: Nested exception is org. hibernate. Exception. sqlgrammarexception: cocould not execute JDBC batch update. I searched the internet for the answer to this question: (1) Because
Hibernate tools
(Or
Eclipse
Its own
Database Explorer
) Generate
*. Hbn. xml
The tool contains
Catalog = "***"
(
* Indicates the database.
So the database migration to other databases produces such an error. (2) the fields in the data table conflict with the attribute configuration in the hibernate ing file, resulting in insertion failure.
Finally, let me talk about my error: My error is actually similar to the second one. I created a class named limit. I don't know whether this is the MySQL keyword or the hibernate keyword, hibernate didn't help me automatically generate this limit data table, so...
7. About
Org. hibernate. hibernateexception: illegally attempted to associate a proxy with two open sessions error !! It took me almost two hours to make this mistake !! I tried my best to solve this problem, but after all, I am still a bird... you know the result !! But the old bird is still flying everywhere...
Oh... I forgot to describe the error scenario: Organization-individual (many-to-many relationship). This error occurs when updating members in the Organization. Update the update method I used !! Now let's talk about the solution: replace update with MERG !!
Let's briefly introduce the merge method:
Merge Method
When calling the merge method, Hibernate checks whether the persistent instance in the persistent context has the same identifier as the detached instance. If yes, the status of the unmanaged instance is in the persistent instance; if not, load the instance from the database and merge the status of the unmanaged instance and the obtained object; if no results are found in the database, create a new persistent instance, copy the status of the unmanaged instance to the new instance, insert it to the database, and return the result through the Merge () operation.
I think it is necessary for me to record the solution when I solve the error: the first thing I think is the fault caused by hibernate lazy loading, Because I configured lazy loading in the HBM configuration file. But the problem persists. So I changed the update (Team team, string tid) method to update (set <user> Users, string tid). The problem still cannot be solved, so it's totally no! It's a problem of lazy loading! However, I still don't quite understand the above solution. The SSH session problem must be a big problem !!
To be continued ......