Exception in thread "SpringOsgiExtenderThread-22"
java.lang.IllegalStateException: BeanFactory not initialized or already closed
- call 'refresh' before ac cessing beans via the ApplicationContext Click to
flag this post
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: FELIX-1071
URL: https://issues.apache.org/jira/browse/FELIX-1071
Project: Felix
Issue Type: Bug
Components: Karaf
Reporter: Guillaume Nodet
The following error is generated by SMX Kernel / Spring DM during bundle start
after an update :
{code}
s...@root:osgi> Exception in thread "SpringOsgiExtenderThread-22"
java.lang.IllegalStateException: BeanFactory not initialized or already closed
- call 'refresh' before ac
cessing beans via the ApplicationContext
at
org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:153)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextExecutor.jav
a:345)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.fail(DependencyWaiterApplicationContextExecutor.java
:401)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.
java:287)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.j
ava:175)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)
at
org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)
at java.lang.Thread.run(Thread.java:619)
{code}
This is very difficult to reproduce it but it seems that the error is generated
when there is a syntactical error in the camel spring DSL file.
e.g.
<setHeader name="origin">
<simple>file</simple>
</setHeader>
<simple> can't be use but <constant>
The syntactical error is not the cause of the error message but I presume that
during the camel context and spring beans instantiation, there are interaction
responsible of the error returned.
Here is the my camel-context :
{code}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://camel.apache.org/schema/osgi
http://camel.apache.org/schema/osgi/camel-osgi.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
<bean id="bindyDataformat"
class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
<constructor-arg type="java.lang.String"
value="org.apache.camel.example.reportincident.model" />
</bean>
<bean id="incidentSaver"
class="org.apache.camel.example.reportincident.beans.IncidentSaver">
<property name="incidentService">
<osgi:reference
interface="org.apache.camel.example.reportincident.service.IncidentService"/>
</property>
</bean>
<bean id="webservice"
class="org.apache.camel.example.reportincident.beans.WebService" />
<bean id="feedback"
class="org.apache.camel.example.reportincident.beans.Feedback" />
<!-- webservice endpoint -->
<cxf:cxfEndpoint id="reportIncident"
address="http://localhost:8080/camel-example/incident"
serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint"
xmlns:s="http://reportincident.example.camel.apache.org">
</cxf:cxfEndpoint>
<osgi:reference id="queuingservice"
interface="org.apache.camel.Component" />
<camelContext trace="true" xmlns="http://camel.apache.org/schema/osgi">
<!-- File route -->
<camel:route>
<camel:from
uri="file://d:/temp/data/?move=d:/temp/done/${file:name}" />
<camel:setHeader headerName="origin">
<camel:constant>file</camel:constant>
</camel:setHeader>
<camel:unmarshal ref="bindyDataformat" />
<camel:to uri="queuingservice:queue:in" />
</camel:route>
<camel:route>
<camel:from uri="queuingservice:queue:in" />
<camel:to uri="bean:incidentSaver?method=process" />
<!--
<camel:marshal ref="bindyDataformat" />
<camel:to uri="file://d:/temp/data/queue" />
-->
</camel:route>
<!-- CXF route -->
<camel:route>
<camel:from uri="cxf:bean:reportIncident" />
<!-- -->
<camel:setHeader headerName="origin">
<camel:constant>webservice</camel:constant>
</camel:setHeader>
<camel:convertBodyTo
type="org.apache.camel.example.reportincident.InputReportIncident" />
<camel:to uri="bean:webservice" />
<!-- <camel:to uri="queuingservice:queue:in" /> -->
<camel:transform>
<camel:method bean="feedback" method="setOk" />
</camel:transform>
</camel:route>
</camelContext>
</beans>
{code}
===================
I confirm my hypothesis. Here is a scenario showing/generating the error :
1) Generate a syntactical error in the spring xml file :
{code}
<!-- Hibernate Transaction Manager exported as OSGI service because used -->
org.apache.camel.example.reportincident.service
<osgi:service id="transactionManagerOsgi"
ref="transactionManager"
interface="org.springframework.transaction.PlatformTransactionManager"/>
{code}
the line 'org.apache.camel.example.reportincident.service ' is not part of the
xml comments <!-- -->
2) Generate the osgi bundle containing the spring file using mvn
3) stop the bundle on SMX
4) update the bundle
5) start the bundle
On the SMX console, you will see :
{code}
s...@root:osgi> Exception in thread "SpringOsgiExtenderThread-19"
java.lang.IllegalStateException: BeanFactory not initialized or already closed
- call 'refresh' before ac
cessing beans via the ApplicationContext
at
org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:153)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextExecutor.jav
a:345)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.fail(DependencyWaiterApplicationContextExecutor.java
:401)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.
java:287)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.j
ava:175)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)
at
org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)
at java.lang.Thread.run(Thread.java:619)
{code}
and in the SM log
{code}
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'beans'
cannot have character [children], because the type's content type is
element-only.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:231)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:167)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:420)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:354)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:453)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3229)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(XMLSchemaValidator.java:3180)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3140)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3042)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2185)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:853)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1796)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2952)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:662)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:154)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:525)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:844)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:773)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:155)
at
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:271)
at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:320)
at
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
... 18 more
{code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.