A summary of the problems arising during the construction of SSH2 frame

Source: Internet
Author: User

Previously contacted the SSH framework, but has not been used, and then this period of time to review again, of course, during the period also encountered a lot of problems, and then on the Internet to check the relevant information, toss some, also learned a lot of things, so decided to organize down. The IDE tool used is Myeclipse10.1, and there are a few questions that you encounter:

1. Issue 1--the console reports the exception that failed to load the struts configuration file.

exception Reason: mainly lacks the struts2-spring-plugin-2. x.x.x this plugin jar package.

Workaround: Import the jar package into the project.

A, you can directly download the required version such as: Struts2-spring-plugin-2.2.1.jar, and then put the jar into the Webroot/web-inf/lib directory, and then build path.

B, can also be directly through the MyEclipse tool to add, just add after this way, will introduce a few more packages, I do not know whether the project has been used, anyway deleted the other several projects can be normal operation, there is no impact, should be not used in the project.

Right-click on the project-"Select Build path--" to select Add Libraries.

Select MyEclipse Libraries

Tick Struts2 Spring Libraries

OK, the exception disappears.

It is important to note that the STRUTS2 has been managed by spring, that is, the configuration file has been properly configured, otherwise there may be other problems. As for what the problem I would not bother to try.

A. Spring snooping is turned on in the Web. XML configuration file.

b, then the Struts.xml configuration file is configured to delegate Struts2 to spring for management.

2, Problem 2--Object Relational mapping failed, entity mapping failed, can't find Pojo class, amount, I do not know can be called, estimated no, let's call it this way.

Exception Reason: entity class not found.
where to take place: Hibernate in the mapping file Xxxx.hbm.xml
workaround, change the path of the Pojo class in the Xxxx.hbm.xml mapping file
Wrong configuration:

Correct configuration: Full path to the Pojo class

3, Problem 3--spring Bean initialization injection is invalid. This problem bothered me for a long time, and my configuration was like this, The class property value of the action in the Struts.xml file is configured with the ID value of the bean injected by spring in the Applicationcontext.xml file, which was previously thought to be the path profile, causing spring to not initialize the injection and even suspect that it was a namespace n Amespace configuration problem, tried several times, the final effect is the same report exception.

Configuration of the Struts.xml:


Configuration of the Applicationcontext.xml file:

Then when you start Tomcat, the console doesn't have any exceptions, everything is fine, but when you run it, you can't instantiate an action exception.

Run, cannot instantiate action, cannot find action definition

After that, the next attempt was made to write the class property of the action of the Struts.xml file as the full path to the action. At this point, the pointer is empty, the program finds the action and enters the action, but the service defined in the action has the same problem, the injection fails, and it is initialized to null. So the control pointer is abnormal.

Service injection failed, report null pointer, with debug you can see that service is null.

Then, after some tossing and searching on the internet for a long time, finally found that the original Web. XML configuration file is configured in the spring to listen to the problem. The load path of the Applicationcontext.xml file is not configured correctly.

Workaround:
There are generally two approaches to the placement of applicationcontext.xml files,

A, placed under the project's top-level root directory src directory. The configuration method is as follows:

<context-param>    <param-name>contextConfigLocation</param-name>    <param-value>classpath:applicationContext.xml</param-value>  </context-param>

b, placed under the Webroot/web-inf directory of the project. The configuration method is as follows:

<context-param>    <param-name>contextConfigLocation</param-name>    <param-value>/WEB-INF/classes/applicationContext*.xml</param-value>  </context-param>

Alternatively, you can use the following method:

<context-param>    <param-name>contextConfigLocation</param-name>    <param-value>WEB-INF/classes/applicationContext*.xml</param-value>  </context-param>

Because spring's monitoring configuration is out of the question, so the program cannot find the Applicationcontext.xml file, so it can not complete the initial injection operation, through the above two methods of configuration correctly, the problem is resolved. Spring initialization injection succeeded.

4, Problem 4--About the database exception, drive the jar package conflict. The oracle11g database is used. The imported database-driven jar package file is Classes12.jar, and the following exception is reported after running:

Oracle. JDBC. Driver. Oracledatabasemetadata. Supportsgetgeneratedkeys()ZExceptioninchThread"Main"Java. Lang. Abstractmethoderror: Oracle. JDBC. Driver. Oracledatabasemetadata. Supportsgetgeneratedkeys()Zat org. Hibernate. Engine. JDBC. Internal. Jdbcservicesimpl. Configure(Jdbcservicesimpl. Java:142)

Workaround:

It doesn't matter if you switch to Ojdbc6.jar and then run. Problem solving,
It should be the version of the driver that conflicts with the version of Oracle, so this error is reported.

5, Problem 5-the use of the JSP tag to jump to the action, has no effect, the request is not a resource, but the browser directly enter the value of the page, can successfully jump.

Workaround:

The Dispatcher property needs to be configured in the filter map in the Struts.xml file.

Configure the request and forward properties to solve the problem,

OK, end, temporarily encountered problems on so many, this is also a few days learning SSH2 framework since a small summary, follow-up and slowly learn. Come on!!!

Summary of issues that arise during the construction of the SSH2 framework

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.