java - Servlet: Cannot instantiate javaURLContextFactory only if load-on-startup -
in tomcat 7 (jdk 1.7) have servlet in load on startup returns error:
javax.naming.noinitialcontextexception: cannot instantiate class: org.apache.naming.java.javaurlcontextfactory [root exception java.lang.classnotfoundexception: org.apache.naming.java.javaurlcontextfactory]
but if call same servlet browser runs.
the error occurs on servlet init() method invoked on start only. seems missing 1 or more jar files classpath
tomcat 6 , 7 support servlet 2.5 standard. standard includes better way web-server-bootstrap actions, through servletcontextlistener interface.
tomcat 7 supports servlet 3.0 standard, can annotate class avoid web.xml configuratiuon
import javax.servlet.*; import javax.servlet.annotation.*; @weblistener public class bootstrapthewebserver implements servletcontextlistener { @override public void contextinitialized(servletcontextevent event) { // invoked on web server start // event.getservletcontext() servlet context } @override public void contextdestroyed(servletcontextevent event) { // invoked on web server shutdown } }
Comments
Post a Comment