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: SMX4KNL-253
                 URL: https://issues.apache.org/activemq/browse/SMX4KNL-253
             Project: ServiceMix Kernel
          Issue Type: Bug
         Environment: ServiceMix Kernel
            Reporter: Charles Moulliard


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}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to