Hallo,
ich verwende in meiner Web- Application Spring und benötige den ApplicationContext in mehreren Klassen, um über die XML- Datei auf andere Objekte zuzugreifen.
Meine Frage wäre jetzt, ist es OK, mehrere Instanzen von ClassPathXmlApplicationContext zu haben (in diesem Fall 2 (unten))? Ich bekomme nämlich eine Exception (unten) und vermute mal, das diese 2 Instanzen zuviel sind, sprich das man nur eine Instanz von ClassPathXmlApplicationContext habe darf??
lg
in Klasse 1 und Klasse 2 steht genau dieser Code, also ich erzeuge 2 Instanzen von
ClassPathXmlApplicationContext
ich verwende in meiner Web- Application Spring und benötige den ApplicationContext in mehreren Klassen, um über die XML- Datei auf andere Objekte zuzugreifen.
Meine Frage wäre jetzt, ist es OK, mehrere Instanzen von ClassPathXmlApplicationContext zu haben (in diesem Fall 2 (unten))? Ich bekomme nämlich eine Exception (unten) und vermute mal, das diese 2 Instanzen zuviel sind, sprich das man nur eine Instanz von ClassPathXmlApplicationContext habe darf??
lg
in Klasse 1 und Klasse 2 steht genau dieser Code, also ich erzeuge 2 Instanzen von
ClassPathXmlApplicationContext
Code:
final ApplicationContext ctx = new ClassPathXmlApplicationContext(PATH);
startDatabase = (StartDatabase)ctx.getBean("startdatabase");
Code:
INFO: Illegal access: this web application instance has been stopped already. Could not load org.springframework.expression.spel.antlr.SpringExpressionsParserExtender.
The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: org/springframework/expression/spel/antlr/SpringExpressionsParserExtender
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at org.springframework.expression.spel.antlr.SpelAntlrExpressionParser.<init>(SpelAntlrExpressionParser.java:51)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)