Hallo,
ich habe einen ServletContextListener erstellt. Code-Auszug:
Theoretisch sollte beim Hoch- und anschließendem Runterfahren des Servers folgendes Verhalten zu beobachten sein:
Hochfahren:
Ausgabe "Initialized "+irgendetwas
Ausgabe "Starting OTP node"
Ausgabe "Node="+irgendetwas
Herunterfahren:
Ausgabe "Destroyed "+irgendetwas
Ausgabe "Closing OTP node"
Dies ist jedoch die Ausgabe, welche tatsächlich kommt:
Hochfahren (abgesehen, dass anscheinend 2 Servlet-Kontexte initialisiert werden - Ursache unbekannt, tritt vor allem das Problem auf, dass er anscheinend beim kurzzeitig darauffolgenden Herunterfahren von org.apache.catalina.core.ApplicationContextFacade@f7ce53 nichts mehr vom Context-Attribute ContextAttributes.OTP_NODE etwas weiß...)
Herunterfahren:
Auch hier weiß er beim Herunterfahren von org.apache.catalina.core.ApplicationContextFacade@c235e1 offensichtlich nichts von dem aktuellen Wert dieses Context-Attributs.
Ich habe hier echt schon alles, was mir einfällt probiert, aber ich kann nicht herausfinden, wie ich mein Programm dazu bringen kann, dass er, wenn contextDestroyed() vom Servlet-Container von Glassfish aufgerufen wird, diesen Attributwert noch "weiß".
Ich starte das ganze mit Netbeans+Glassfish über den "Ausführen"-Button.
Bonusfrage: warum werden 2 Kontexte erzeugt und der eine sofort wieder zerstört?
ich habe einen ServletContextListener erstellt. Code-Auszug:
Code:
public class ThinxelsOnFlowListener implements ServletContextListener,
HttpSessionListener, HttpSessionAttributeListener {
@Override
public void contextInitialized(ServletContextEvent e) {
Logger.getLogger(ThinxelsOnFlowListener.class.getName()).log(Level.INFO,
"Initialized "+e.getServletContext().toString());
e.getServletContext().setAttribute(ContextAttributes.SESSION_LIST,
new HashMap<String, HttpSession>());
try {
Logger.getLogger(ThinxelsOnFlowListener.class.getName()).log(Level.INFO,
"Starting OTP node");
OtpNode node = new OtpNode(
e.getServletContext().getInitParameter(ContextInitParameters.OTP_SELF_NODE),
e.getServletContext().getInitParameter(ContextInitParameters.OTP_COOKIE)
);
Logger.getLogger(ThinxelsOnFlowListener.class.getName()).log(Level.INFO,
"Node="+node);
e.getServletContext().setAttribute(ContextAttributes.OTP_NODE, node);
} catch (IOException ex) {
Logger.getLogger(ThinxelsOnFlowListener.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void contextDestroyed(ServletContextEvent e) {
Logger.getLogger(ThinxelsOnFlowListener.class.getName()).log(Level.INFO,
"Destroyed "+e.getServletContext().toString());
OtpNode node = (OtpNode) e.getServletContext().getAttribute(ContextAttributes.OTP_NODE);
if (node != null) {
Logger.getLogger(ThinxelsOnFlowListener.class.getName()).log(Level.INFO,
"Closing OTP node");
node.close();
}
else {
Logger.getLogger(ThinxelsOnFlowListener.class.getName()).log(Level.WARNING,
"No OTP node exists to close");
}
}
// ... Implementation der anderen Interfaces
}
Theoretisch sollte beim Hoch- und anschließendem Runterfahren des Servers folgendes Verhalten zu beobachten sein:
Hochfahren:
Ausgabe "Initialized "+irgendetwas
Ausgabe "Starting OTP node"
Ausgabe "Node="+irgendetwas
Herunterfahren:
Ausgabe "Destroyed "+irgendetwas
Ausgabe "Closing OTP node"
Dies ist jedoch die Ausgabe, welche tatsächlich kommt:
Hochfahren (abgesehen, dass anscheinend 2 Servlet-Kontexte initialisiert werden - Ursache unbekannt, tritt vor allem das Problem auf, dass er anscheinend beim kurzzeitig darauffolgenden Herunterfahren von org.apache.catalina.core.ApplicationContextFacade@f7ce53 nichts mehr vom Context-Attribute ContextAttributes.OTP_NODE etwas weiß...)
[...]
WEB0712: Sun-Java-System/Application-Server HTTP/1.1 wird gestartet auf 8080
WEB0712: Sun-Java-System/Application-Server HTTP/1.1 wird gestartet auf 8181
WEB0712: Sun-Java-System/Application-Server HTTP/1.1 wird gestartet auf 4848
Initialized org.apache.catalina.core.ApplicationContextFacade@f7ce53
Starting OTP node
Node=servlet_container@meinlaptop
SMGT0007: Selbstverwaltungsregeldienst ist aktiviert
Start des Anwendungsservers abgeschlossen.
Destroyed org.apache.catalina.core.ApplicationContextFacade@f7ce53
No OTP node exists to close
deployed with moduleid = ThinXelsOnFlow
Initialized org.apache.catalina.core.ApplicationContextFacade@c235e1
Starting OTP node
Node=servlet_container@meinlaptop
Herunterfahren:
WEB0303: Sun-Java-System/Application-Server wird gestoppt.
WEB0713: Sun-Java-System/Application-Server HTTP/1.1 wird gestoppt auf 8080
WEB0713: Sun-Java-System/Application-Server HTTP/1.1 wird gestoppt auf 8181
WEB0713: Sun-Java-System/Application-Server HTTP/1.1 wird gestoppt auf 4848
Destroyed org.apache.catalina.core.ApplicationContextFacade@c235e1
No OTP node exists to close
[...]
Auch hier weiß er beim Herunterfahren von org.apache.catalina.core.ApplicationContextFacade@c235e1 offensichtlich nichts von dem aktuellen Wert dieses Context-Attributs.
Ich habe hier echt schon alles, was mir einfällt probiert, aber ich kann nicht herausfinden, wie ich mein Programm dazu bringen kann, dass er, wenn contextDestroyed() vom Servlet-Container von Glassfish aufgerufen wird, diesen Attributwert noch "weiß".
Ich starte das ganze mit Netbeans+Glassfish über den "Ausführen"-Button.
Bonusfrage: warum werden 2 Kontexte erzeugt und der eine sofort wieder zerstört?