java - @Named annotation can't load a bean in a Servlet - javax.naming.NameNotFoundException: Name student is not bound in this Context -
i used @component bean(student.java) being called in servlet. changed @component @named. used use following code student bean in servlet.
student student = (student)applicationcontext.getbean("student")
after changed @named, bean no longer being detected. getting following error messages. tell me problem? placed javax.inject-1.jar file under webapps\student-enrollment\web-inf\lib\
context init... logger name context: student-enrollment context logger config file: logback-student-enrollment.xml adding logger context: student-enrollment map context: student-enrollment 2014-09-10 20:46:19.361 servlet /student-enrollment threw load() exception javax.naming.namenotfoundexception: name student not bound in context @ org.apache.naming.namingcontext.lookup(namingcontext.java:770) ~[catalina-6.0.36.jar:6.0.36] @ org.apache.naming.namingcontext.lookup(namingcontext.java:153) ~[catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.util.defaultannotationprocessor.lookupfieldresource(defaultannotationprocessor.java:276) ~[catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.util.defaultannotationprocessor.processannotations(defaultannotationprocessor.java:187) ~[catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1153) ~[catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.standardwrapper.load(standardwrapper.java:1026) ~[catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:4421) [catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.standardcontext.start(standardcontext.java:4734) [catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.containerbase.start(containerbase.java:1057) [catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.standardhost.start(standardhost.java:840) [catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.containerbase.start(containerbase.java:1057) [catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.core.standardengine.start(standardengine.java:463) [catalina-6.0.36.jar:6.0.36] @ org.apache.catalina.startup.embedded.start(embedded.java:825) [catalina-6.0.36.jar:6.0.36] @ org.red5.server.tomcat.tomcatloader.init(tomcatloader.java:517) [tomcatplugin-1.3.jar:na] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.6.0_43] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) ~[na:1.6.0_43] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) ~[na:1.6.0_43] @ java.lang.reflect.method.invoke(method.java:597) ~[na:1.6.0_43] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokecustominitmethod(abstractautowirecapablebeanfactory.java :1581) [spring-beans-3.1.1.release.jar:3.1.1.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1522 ) [spring-beans-3.1.1.release.jar:3.1.1.release]
edit 1
here part of student.java , studentenrollmentservlet class.
@named(student.named) public class student { public static final string named = "student"; ....... } @named(studentenrollmentservlet.named) public class studentenrollmentservlet extends httpservlet { public static final string named = "studentenrollmentservlet"; @resource(name = student.named) private student student; @override protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { processrequest(request, response); } ....... }
it looks need give bean name
@named("student")
Comments
Post a Comment