posted 12 years ago
hi ranchers ,
i created a small application in which i track all the life cycle events of LifeServlet servlet. And use the MyLogger class to log the event using the Log4j tool.
everything is working fine .But when is see the log file of server i get this :
[#|2011-12-08T11:23:06.078-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=10;_ThreadName=Thread-2;|0 [main] INFO org.MyLogger - ServletContext object is Initialized
|#]
[#|2011-12-08T11:23:06.093-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0671: Loading application [LifeCycle] at [/LifeCycle]|#]
[#|2011-12-08T11:23:06.093-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=10;_ThreadName=Thread-2;|CORE10010: Loading application LifeCycle done in 453 ms|#]
[#|2011-12-08T11:23:06.093-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=10;_ThreadName=Thread-2;|Oracle GlassFish Server 3.1.1 (12) startup time : Felix (1,219ms), startup services(3,093ms), total(4,312ms)|#]
[#|2011-12-08T11:23:06.125-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.tools.admin.com.sun.enterprise.container.common|_ThreadID=16;_ThreadName=Thread-2;|User [admin] from host localhost does not have administration access|#]
[#|2011-12-08T11:23:06.265-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.tools.admin.org.glassfish.server|_ThreadID=17;_ThreadName=Thread-2;|JMXStartupService: Started JMXConnector, JMXService URL = service:jmx:rmi://sunmicro-fe959d:8686/jndi/rmi://sunmicro-fe959d:8686/jmxrmi|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - intit() is called
|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - intit() is called
|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - service() is called
|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - service() is called
|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - ServletRequest object is Initialized
|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - ServletRequest object is Initialized
|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - ServletResponse object is Initialized
|#]
[#|2011-12-08T11:23:07.765-0800|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|1687 [http-thread-pool-8080(2)] INFO org.MyLogger - ServletResponse object is Initialized
|#]
I have two question
Q1 : why ServletContext is initialized before LifeCycle application is loaded ? shouln't be other ways around ?
Q2: why init() and service() is called twice?
for more understating here is my code of LifeServlet