SSH Framework Problem--listener (listener) configuration error: Javax.naming.NameNotFoundException:Name com............__ssh

Source: Internet
Author: User
Tags ssh

Today, when the listener is configured, an error has been encountered: Javax.naming.NameNotFoundException:Name Com.xxx.xxx.xxxListener is isn't bound in the context,

4 hours later, I finally figured out why.

Because of the use of spring injection, it is used in the listener class that you define

@Resource
Private Iusermanage usermanage;

annotation, but spring's injection is after filter and listener, (in the Order of listener >> filter >> servlet > > Spring)

Therefore, it is not possible to use spring injection in the listener class, and you need to write such a piece of code:

Private Iusermanage usermanage;
Classpathxmlapplicationcontext ctx=new classpathxmlapplicationcontext ("Applicationcontext.xml");
Usermanage= (iusermanage) Ctx.getbean ("Usermanageimp");

This way you get an instance of the service layer, and the Web.xml configuration file remains the same.

Similarly, it is the same to speculate that you write the filter, but it is not validated, only for reference.

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.