2013-11-21 9 views
16

से पहले 'ताज़ा' कहते हैं यहाँ मेरी त्रुटि है:BeanFactory आरंभ नहीं किया या पहले से ही बंद कर दिया -

मैं इस त्रुटि हो रही है, किसी भी एक इस पर मेरी मदद कर सकते हैं।

> SEVERE: Exception sending context initialized event to listener 
> instance of class 
> org.springframework.web.context.ContextLoaderListener 
> java.lang.NoSuchMethodError: 
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.setEnvironment(Lorg/springframework/core/env/Environment;)V 
> at 
> org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:87) 
> at 
> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131) 
> at 
> org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522) 
> at 
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436) 
> at 
> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) 
> at 
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) 
> at 
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) 
> at 
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) 
> at 
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) 
> at 
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) 
> at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at 
> java.util.concurrent.FutureTask.run(Unknown Source) at 
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
> at java.lang.Thread.run(Unknown Source) Nov 21, 2013 12:54:38 PM 
> org.apache.catalina.core.StandardContext startInternal SEVERE: Error 
> listenerStart Nov 21, 2013 12:54:38 PM 
> org.apache.catalina.core.StandardContext startInternal SEVERE: Context 
> [/FLPalette] startup failed due to previous errors Nov 21, 2013 
> 12:54:38 PM org.apache.catalina.core.ApplicationContext log INFO: 
> Closing Spring root WebApplicationContext Nov 21, 2013 12:54:38 PM 
> org.apache.catalina.core.StandardContext listenerStop SEVERE: 
> Exception sending context destroyed event to listener instance of 
> class org.springframework.web.context.ContextLoaderListener 
> java.lang.IllegalStateException: BeanFactory not initialized or 
> already closed - call 'refresh' before accessing beans via the 
> ApplicationContext at 
> org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172) 
> at 
> org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066) 
> at 
> org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040) 
> at 
> org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:988) 
> at 
> org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556) 
> at 
> org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142) 
> at 
> org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4763) 
> at 
> org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5472) 
> at java.lang.Thread.run(Unknown Source)  at 
> org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5481) 
> at 
> org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225) 
> at 
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153) 
> at 
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033) 
> at 
> org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774) 
> at 
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 
> at 
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033) 
> at 
> org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291) 
> at 
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 
> at 
> org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) 
> at 
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 
> at 
> org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727) 
> at 
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 
> at org.apache.catalina.startup.Catalina.start(Catalina.java:620) at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at 
> java.lang.reflect.Method.invoke(Unknown Source) at 
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303) at 
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431) Nov 21, 
> 2013 12:54:38 PM org.apache.coyote.AbstractProtocol start INFO: 
> Starting ProtocolHandler ["http-bio-8080"] Nov 21, 2013 12:54:38 PM 
> org.apache.coyote.AbstractProtocol start INFO: Starting 
> ProtocolHandler ["ajp-bio-8009"] Nov 21, 2013 12:54:38 PM 
> org.apache.catalina.startup.Catalina start 

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.paypal.palette</groupId> 
    <artifactId>FLPalette</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <name>FLPalette</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
    <dependency> 
    <groupId>mysql</groupId> 
    <artifactId>mysql-connector-java</artifactId> 
    <version>5.1.5</version> 
</dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>${org.springframework.version}</version> 
      </dependency> 
      <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>${org.springframework.version}</version> 
     </dependency> 
     <dependency> 
     <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>${org.springframework.version}</version> 
     </dependency> 

    <dependency> 
    <groupId>wsdl4j</groupId> 
    <artifactId>wsdl4j</artifactId> 
    <version>1.6.3</version> 
    <scope>test</scope> 
</dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.8.1</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.14</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>jstl</groupId> 
     <artifactId>jstl</artifactId> 
     <version>1.1.2</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>taglibs</groupId> 
     <artifactId>standard</artifactId> 
     <version>1.1.2</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-jdbc</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-core</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-config</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-web</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-ldap</artifactId> 
     <version>3.1.1.RELEASE</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.jcraft</groupId> 
     <artifactId>jsch</artifactId> 
     <version>0.1.50</version> 
    </dependency> 
    <dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.5</version> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-taglibs</artifactId> 
    <version>3.1.0.RELEASE</version> 
    </dependency> 
    <dependency> 
    <groupId>org.json</groupId> 
    <artifactId>json</artifactId> 
    <version>20090211</version> 
    </dependency> 
    <dependency> 
    <groupId>commons-fileupload</groupId> 
    <artifactId>commons-fileupload</artifactId> 
    <version>1.2.1</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>1.4</version> 
    </dependency>   
    </dependencies> 
    <properties> 
     <org.springframework.version>3.0.2.RELEASE</org.springframework.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <build> 
    <finalName>${project.artifactId}</finalName> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>2.3.2</version> 
     <configuration> 
      <source>1.6</source> 
      <target>1.6</target> 
     </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId>   
     </plugin> 
    </plugins> 
    </build> 
</project> 

उत्तर

7

यहां मुद्दा यह है कि आप प्रयोग कर रहे हैं spring-web के संस्करण (3.1.1 जारी) spring-beans के संस्करण के साथ संगत नहीं है कि आप ' पुनः उपयोग कर रहे हैं (3.0.2-रिलीज)। आप NoSuchMethodError जो बारी में BeanFactory not initialized... अपवाद चलाता है देख सकते हैं ढेर के शीर्ष पर।

NoSuchMethodError वजह से क्योंकि विधि मंगलाचरण spring-web में XmlWebApplicationContext.loadBeanDefinitions() कोशिश कर रहा है spring-beans में XmlBeanDefinitionReader.setEnvironment() कॉल करने के लिए जो 3.0.2 रिलीज में मौजूद नहीं है है। हालांकि यह 3.1.1 रिलीज में मौजूद है - के रूप में setEnvironment माता पिता AbstractBeanDefinitionReader से प्राप्त होती है।

हल करने के लिए, तो आप शायद 3.1.1 जारी करने के लिए spring-beans जार उन्नत करने के लिए सबसे अच्छा होगा। इस जार के लिए संस्करण अपने pom.xml में parameterized प्रतीत होता है और आगे की फ़ाइल में नीचे संपत्ति org.springframework.version द्वारा नियंत्रित है।

16

यह अपवाद आने के कारण आप श्रोता ContextLoaderListener

<listener> 
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

प्रदान कर रहे हैं, लेकिन आप अपने वसंत विन्यास फाइल के लिए context-param प्रदान नहीं कर रहे। जैसे applicationContext.xml आप अपने विन्यास

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>applicationContext.xml</param-value> 
</context-param> 

आप जावा आधारित वसंत विन्यास प्रदान कर रहे हैं, तो आप उस समय आप नीचे दिए गए कोड प्रदान करना होगा पर वसंत विन्यास के लिए xml फ़ाइल का उपयोग नहीं कर रहे हैं इसका मतलब के लिए स्निपेट के नीचे प्रदान करनी चाहिए :

<!-- Configure ContextLoaderListener to use AnnotationConfigWebApplicationContext 
instead of the default XmlWebApplicationContext --> 
<context-param> 
    <param-name>contextClass</param-name> 
    <param-value> 
    org.springframework.web.context.support.AnnotationConfigWebApplicationContext 
    </param-value> 
</context-param> 

<!-- Configuration locations must consist of one or more comma- or space-delimited 
fully-qualified @Configuration classes. Fully-qualified packages may also 
be specified for component-scanning --> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>com.nirav.modi.config.SpringAppConfig</param-value> 
</context-param> 
2

मैं इस मुद्दे को जब तक मैं सर्वर की तैनाती (JBoss देव स्टूडियो में से प्रश्न में परियोजना निकाल दिया था, सर्वर राइट क्लिक करें और सर्वर में परियोजना "निकालें" देखें), फिर निम्नलिखित किया:

  1. किसी भी परियोजना के बिना जेबॉस ईएपी 6.1 सर्वर को पुनरारंभ किया गया।
  2. सर्वर शुरू होने के बाद, मैंने सर्वर को प्रश्न में परियोजना को जोड़ा।

इसके बाद, सर्वर का चयन करके बस सर्वर (डीबग या रन मोड में) को पुनरारंभ करें, प्रोजेक्ट को ही नहीं।

यह किसी भी पिछली सेटिंग/राज्यों/स्मृति/जो कुछ भी है कि इस मुद्दे को पैदा कर रहा था फ्लश करने के लिए लग रहा था, और मैं अब त्रुटि मिली।

1

मेरे मामले में, त्रुटि "BeanFactory नहीं प्रारंभ या पहले से ही बंद कर दिया - पहले 'ताज़ा' कहते हैं" पिछले एक त्रुटि है कि मैं सर्वर स्टार्टअप में देखा नहीं था का एक परिणाम था। मुझे लगता है कि यह हमेशा समस्या का असली कारण नहीं है।

0

मैं 3.2.1 से 3.2.18 और 4.3.5 से 4.3.5 तक अपग्रेड करने के बाद दो बार इस मुद्दे पर आया था। दोनों मामलों में, यह त्रुटि वसंत मॉड्यूल के विभिन्न संस्करणों की वजह से है

1

मेरे मामले में, यह त्रुटि नेटवर्क कनेक्शन त्रुटि के कारण थी जो मुझे लॉग में देखा गया था।

0

मेरे मामले में, त्रुटि वैध था और यह संसाधन

try (ConfigurableApplicationContext cxt = new ClassPathXmlApplicationContext(
        "classpath:application-main-config.xml")) {.. 
} 

यह ऑटो धारा जो ऐसा नहीं होना चाहिए अगर मैं अन्य सेम में इस संदर्भ का पुन: उपयोग करना चाहते हैं बंद कर देता है के साथ की कोशिश का उपयोग कर के कारण था।

0

मुझे एक ही त्रुटि थी और मैंने एप्लिकेशन कॉन्फ़िगरेशन या web.xml में कोई भी परिवर्तन नहीं किया था। कोड में कुछ मामूली परिवर्तनों को वापस करने के लिए कई प्रयास अपवादों को साफ़ नहीं कर रहे थे। अंत में यह एसटीएस को पुनरारंभ करने के बाद काम किया।

संबंधित मुद्दे

 संबंधित मुद्दे