You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by lhe77 <la...@compart.net> on 2008/04/01 14:56:02 UTC

Error injecting bean into servicemix-drools service unit

Hi,

I did what is described on the servicemix-drools wiki page to inject an
additional bean.
When deploying it to smx it throws exception:


WARN  - AutoDeploymentService          - Directory: hotdeploy: Automatic
install of
/opt/apache-servicemix-3.3-SNAPSHOT/hotdeploy/cp-inputrouter-sa-1.0-SNAPSHOT.zip
failed
javax.jbi.management.DeploymentException: Failed to update Service Assembly:
cp-inputrouter-sa
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly(AutoDeploymentService.java:368)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:256)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
Caused by: java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
<jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message"
version="1.0">
<jbi-task-result>
<frmwk-task-result>
<frmwk-task-result-details>
<task-result-details>
<task-id>deploy</task-id>
<task-result>FAILED</task-result>
<message-type>ERROR</message-type>
</task-result-details>
</frmwk-task-result-details>
</frmwk-task-result>
<component-task-result
xmlns="http://java.sun.com/xml/ns/jbi/management-message">
        <component-name>servicemix-drools</component-name>
        <component-task-result-details>
                <task-result-details>
                        <task-id>deploy</task-id>
                        <task-result>FAILED</task-result>
                        <message-type>ERROR</message-type>
                        <task-status-msg>
<msg-loc-info>
<loc-token/>
<loc-message>Unable to deploy service unit</loc-message>
</msg-loc-info>
</task-status-msg>
                        <exception-info>
                                <nesting-level>1</nesting-level>
                                <msg-loc-info>
                                        <loc-token/>
                                        <loc-message>BeanFactory not
initialized or already closed - call 'refresh' before accessing beans via
the ApplicationContext</loc-message>
                                       
<stack-trace><![CDATA[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:121)
        at
org.springframework.context.support.AbstractApplicationContext.getLifecycleBeans(AbstractApplicationContext.java:912)
        at
org.springframework.context.support.AbstractApplicationContext.stop(AbstractApplicationContext.java:886)
        at
org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:682)
        at
org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:651)
        at
org.springframework.context.support.AbstractApplicationContext.destroy(AbstractApplicationContext.java:639)
        at
org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:106)
        at
org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(BaseServiceUnitManager.java:88)
        at
org.apache.servicemix.common.BaseServiceUnitManager.deploy(BaseServiceUnitManager.java:69)
        at
org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly(DeploymentService.java:508)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly(AutoDeploymentService.java:353)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:256)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
]]></stack-trace>
                                </msg-loc-info>
                        </exception-info>
                </task-result-details>
        </component-task-result-details>
</component-task-result>
</jbi-task-result>
</jbi-task>

        at
org.apache.servicemix.jbi.framework.ManagementSupport.failure(ManagementSupport.java:125)
        at
org.apache.servicemix.jbi.framework.ManagementSupport.failure(ManagementSupport.java:111)
        at
org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly(DeploymentService.java:543)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly(AutoDeploymentService.java:353)
        ... 6 more


The xbean:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:drools="http://servicemix.apache.org/drools/1.0"
       xmlns:cp="http://www.compart.net/ns/jbi">

  <drools:endpoint service="cp:inputRouter"
                   endpoint="inEndpoint"
                   namespaceContext="#nsContext"
                   ruleBaseResource="classpath:router.drl" 
                   globals="#globals" />

  <util:map id="globals">
  	<entry key="constants" value-ref="constants" />
  </util:map>
  <bean id="constants" class="ConstantsHelper" />

  <drools:namespace-context id="nsContext">
    <drools:namespaces>
      <drools:namespace
prefix="cp">http://www.compart.net/ns/jbi</drools:namespace>
    </drools:namespaces>
  </drools:namespace-context>
  
</beans>


The drl:


package org.apache.servicemix.drools

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.drools.model.Exchange;
import ConstantsHelper;

global org.apache.servicemix.drools.model.JbiHelper jbi;
global ConstantsHelper constants;

rule UnkownOperation
    when
        me : Exchange( status == Exchange.ACTIVE, in : in != null,
                       operation != "{http://www.compart.net/ns/jbi}process"
)
    then
        jbi.fault("<UnknownOperation
xmlns='http://www.compart.net/ns/jbi'/>");
end

rule ProcessInputAFP
    when
        me : Exchange( status == Exchange.ACTIVE, in : in != null,
                       operation == "{http://www.compart.net/ns/jbi}process"
)
        eval (isOfType(getFileName(me), "afp"))                       
    then
        jbi.getLogger().info("File " + getFileName(me) + " is of type AFP");
        jbi.route("service:http://www.compart.net/ns/jbi/fileSender");
end

function boolean isOfType(String fileName, String type) {
    return fileName.toLowerCase().endsWith("." + type.toLowerCase());
}

function String getFileName(Exchange me) {
    if (me.getIn().getProperty("user-props") != null) {
        java.util.Map userProps =
(java.util.Map)me.getIn().getProperty("user-props");
        String fileName = userProps.get("file-name").toString();
        if (fileName != null) {
            return fileName;
        } else {
            return "";
        }
    } else {
        return "";
    }
}


The helper bean:

public class ConstantsHelper
{
    public String getFileNameProperty()
        {
        return "file-name";
        }
    
    public String getUserPropertiesKeyProperty()
        {
        return "user-props";
        }
}


I have no idea why the injection doesn't work. Any ideas?

Regards,
Lars

-- 
View this message in context: http://www.nabble.com/Error-injecting-bean-into-servicemix-drools-service-unit-tp16418402s12049p16418402.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Error injecting bean into servicemix-drools service unit

Posted by Lars Heinemann <la...@compart.net>.
Nice, it works.
Thanks a lot, Guillaume.

Lars

BTW: I'll commit it asap.



Guillaume Nodet schrieb:
> On Tue, Apr 1, 2008 at 3:45 PM, Lars Heinemann <la...@compart.net>
> wrote:
>
>   
>> Good hint, Guillaume.
>> I put in the try/catch block and retried.
>>     
>
>
> Cool. Wanna commit this change ?
>
> For the exception below, you just have to add the spring util namespace to
> the xbean.xml:
>      xmlns:util="http://www.springframework.org/schema/util"
>
>
>   
>> This is the result now:
>>
>> ERROR - DroolsComponent                -
>> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
>> Line 11 in XML document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml]
>> is invalid; nested exception is org.xml.sax.SAXParseException: The prefix
>> "util" for element "util:map" is not bound.
>> ERROR - FileSystemXmlApplicationContext - Exception thrown from
>> ApplicationListener handling ContextClosedEvent
>> java.lang.IllegalStateException: ApplicationEventMulticaster not
>> initialized - call 'refresh' before multicasting events via the context:
>> org.apache.xbean.spring.context.FileSystemXmlApplicationContext@c1d35:
>> display name [
>> org.apache.xbean.spring.context.FileSystemXmlApplicationContext@c1d35];
>> startup date [Tue Apr 01 15:42:46 CEST 2008]; root of context hierarchy
>>        at
>> org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster
>> (AbstractApplicationContext.java:259)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.publishEvent
>> (AbstractApplicationContext.java:246)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.doClose(
>> AbstractApplicationContext.java:676)
>>         at
>> org.springframework.context.support.AbstractApplicationContext.close(
>> AbstractApplicationContext.java:651)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.destroy(
>> AbstractApplicationContext.java:639)
>>         at org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy
>> (AbstractXBeanDeployer.java:108)
>>         at org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
>> BaseServiceUnitManager.java:88)
>>        at org.apache.servicemix.common.BaseServiceUnitManager.deploy(
>> BaseServiceUnitManager.java:69)
>>        at
>> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
>> (DeploymentService.java:508)
>>         at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(
>> AutoDeploymentService.java:482)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents
>> (AutoDeploymentService.java:535)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary
>> (AutoDeploymentService.java:317)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
>> AutoDeploymentService.java:254)
>>         at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
>> (AutoDeploymentService.java:658)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
>> AutoDeploymentService.java:62)
>>        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
>> AutoDeploymentService.java:622)
>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>        at java.util.TimerThread.run(Timer.java:462)
>> ERROR - DroolsComponent                - java.lang.IllegalStateException:
>> BeanFactory not initialized or already closed - call 'refresh' before
>> accessing beans via the ApplicationContext
>> ERROR - AutoDeploymentService          - Failed to update Service
>> Assembly: cp-inputrouter-sa-1.0-SNAPSHOT.0.tmp
>> java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
>> <jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message"
>> version="1.0">
>> <jbi-task-result>
>> <frmwk-task-result>
>> <frmwk-task-result-details>
>> <task-result-details>
>> <task-id>deploy</task-id>
>> <task-result>FAILED</task-result>
>> <message-type>ERROR</message-type>
>> </task-result-details>
>> </frmwk-task-result-details>
>> </frmwk-task-result>
>> <component-task-result xmlns="
>> http://java.sun.com/xml/ns/jbi/management-message">
>>        <component-name>servicemix-drools</component-name>
>>        <component-task-result-details>
>>                <task-result-details>
>>                        <task-id>deploy</task-id>
>>                        <task-result>FAILED</task-result>
>>                        <message-type>ERROR</message-type>
>>                        <task-status-msg>
>> <msg-loc-info>
>> <loc-token/>
>> <loc-message>Could not deploy xbean service unit</loc-message>
>> </msg-loc-info>
>> </task-status-msg>
>>                        <exception-info>
>>                                <nesting-level>1</nesting-level>
>>                                <msg-loc-info>
>>                                        <loc-token/>
>>                                         <loc-message>Line 11 in XML
>> document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml]
>> is invalid; nested exception is org.xml.sax.SAXParseException: The prefix
>> "util" for element "util:map" is not bound.</loc-message>
>>                                        <stack-trace><![CDATA[
>> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
>> Line 11 in XML document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml]
>> is invalid; nested exception is org.xml.sax.SAXParseException: The prefix
>> "util" for element "util:map" is not bound.
>> Caused by: org.xml.sax.SAXParseException: The prefix "util" for element
>> "util:map" is not bound.
>>        at
>> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
>> Source)
>>        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown
>> Source)
>>        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>>        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>>        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
>> Source)
>>        at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>> Source)
>>        at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
>> Source)
>>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
>> Source)
>>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
>> Source)
>>        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>>        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
>>        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
>>        at
>> org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(
>> DefaultDocumentLoader.java:76)
>>        at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions
>> (XmlBeanDefinitionReader.java:351)
>>        at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions
>> (XmlBeanDefinitionReader.java:303)
>>        at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions
>> (XmlBeanDefinitionReader.java:280)
>>        at
>> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
>> (AbstractBeanDefinitionReader.java:131)
>>        at
>> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
>> (AbstractBeanDefinitionReader.java:147)
>>        at
>> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
>> (AbstractBeanDefinitionReader.java:173)
>>        at
>> org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions
>> (AbstractXmlApplicationContext.java:112)
>>        at
>> org.apache.xbean.spring.context.FileSystemXmlApplicationContext.loadBeanDefinitions
>> (FileSystemXmlApplicationContext.java:168)
>>        at
>> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory
>> (AbstractRefreshableApplicationContext.java:101)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory
>> (AbstractApplicationContext.java:389)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.refresh(
>> AbstractApplicationContext.java:324)
>>        at org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(
>> AbstractXBeanDeployer.java:89)
>>         at org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
>> BaseServiceUnitManager.java:88)
>>        at org.apache.servicemix.common.BaseServiceUnitManager.deploy(
>> BaseServiceUnitManager.java:69)
>>        at
>> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
>> (DeploymentService.java:508)
>>         at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(
>> AutoDeploymentService.java:482)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents
>> (AutoDeploymentService.java:535)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary
>> (AutoDeploymentService.java:317)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
>> AutoDeploymentService.java:254)
>>         at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
>> (AutoDeploymentService.java:658)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
>> AutoDeploymentService.java:62)
>>        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
>> AutoDeploymentService.java:622)
>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>        at java.util.TimerThread.run(Timer.java:462)
>> ]]></stack-trace>
>>                                </msg-loc-info>
>>                        </exception-info>
>>                </task-result-details>
>>        </component-task-result-details>
>> </component-task-result>
>> </jbi-task-result>
>> </jbi-task>
>>
>>        at org.apache.servicemix.jbi.framework.ManagementSupport.failure(
>> ManagementSupport.java:125)
>>        at org.apache.servicemix.jbi.framework.ManagementSupport.failure(
>> ManagementSupport.java:111)
>>        at
>> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
>> (DeploymentService.java:543)
>>         at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(
>> AutoDeploymentService.java:482)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents
>> (AutoDeploymentService.java:535)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary
>> (AutoDeploymentService.java:317)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
>> AutoDeploymentService.java:254)
>>         at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
>> (AutoDeploymentService.java:658)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
>> AutoDeploymentService.java:62)
>>        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
>> AutoDeploymentService.java:622)
>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>        at java.util.TimerThread.run(Timer.java:462)
>>
>>
>> It seems the parser has no idea what to do with the <util:map> stuff in
>> the xbean config.
>>
>> What to do now? Is there a namespace I can add?
>>
>> Regards,
>> Lars
>>
>>
>>
>>
>> Guillaume Nodet schrieb:
>>     
>>> Sounds like another regression :-(
>>> Given the stack trace, it seems there is an exception that is swallowed
>>>       
>> by
>>     
>>> the exception displayed, because of the call to close/destroy.
>>> This may mean we need to enclose the applicationContext.destroy(); in a
>>> try/catch block in the AbstractXBeanDeployer#deploy() method.
>>> Could you try that ?
>>>
>>> On Tue, Apr 1, 2008 at 2:56 PM, lhe77 <la...@compart.net>
>>>       
>> wrote:
>>     
>>>       
>>>> Hi,
>>>>
>>>> I did what is described on the servicemix-drools wiki page to inject an
>>>> additional bean.
>>>> When deploying it to smx it throws exception:
>>>>
>>>>
>>>> WARN  - AutoDeploymentService          - Directory: hotdeploy:
>>>>         
>> Automatic
>>     
>>>> install of
>>>> /opt/apache-servicemix-3.3-SNAPSHOT/hotdeploy/cp-
>>>> inputrouter-sa-1.0-SNAPSHOT.zip
>>>> failed
>>>> javax.jbi.management.DeploymentException: Failed to update Service
>>>> Assembly:
>>>> cp-inputrouter-sa
>>>>        at
>>>>
>>>>
>>>>         
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
>>     
>>>> (AutoDeploymentService.java:368)
>>>>        at
>>>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive
>>>>         
>> (
>>     
>>>> AutoDeploymentService.java:256)
>>>>        at
>>>>
>>>>         
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
>>     
>>>> (AutoDeploymentService.java:658)
>>>>        at
>>>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
>>>> AutoDeploymentService.java:62)
>>>>        at
>>>> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
>>>> AutoDeploymentService.java:622)
>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>> Caused by: java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
>>>> <jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message"
>>>> version="1.0">
>>>> <jbi-task-result>
>>>> <frmwk-task-result>
>>>> <frmwk-task-result-details>
>>>> <task-result-details>
>>>> <task-id>deploy</task-id>
>>>> <task-result>FAILED</task-result>
>>>> <message-type>ERROR</message-type>
>>>> </task-result-details>
>>>> </frmwk-task-result-details>
>>>> </frmwk-task-result>
>>>> <component-task-result
>>>> xmlns="http://java.sun.com/xml/ns/jbi/management-message">
>>>>        <component-name>servicemix-drools</component-name>
>>>>        <component-task-result-details>
>>>>                <task-result-details>
>>>>                        <task-id>deploy</task-id>
>>>>                        <task-result>FAILED</task-result>
>>>>                        <message-type>ERROR</message-type>
>>>>                        <task-status-msg>
>>>> <msg-loc-info>
>>>> <loc-token/>
>>>> <loc-message>Unable to deploy service unit</loc-message>
>>>> </msg-loc-info>
>>>> </task-status-msg>
>>>>                        <exception-info>
>>>>                                <nesting-level>1</nesting-level>
>>>>                                <msg-loc-info>
>>>>                                        <loc-token/>
>>>>                                        <loc-message>BeanFactory not
>>>> initialized or already closed - call 'refresh' before accessing beans
>>>>         
>> via
>>     
>>>> the ApplicationContext</loc-message>
>>>>
>>>> <stack-trace><![CDATA[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:121)
>>>>        at
>>>>
>>>>
>>>>         
>> org.springframework.context.support.AbstractApplicationContext.getLifecycleBeans
>>     
>>>> (AbstractApplicationContext.java:912)
>>>>        at
>>>> org.springframework.context.support.AbstractApplicationContext.stop(
>>>> AbstractApplicationContext.java:886)
>>>>        at
>>>> org.springframework.context.support.AbstractApplicationContext.doClose(
>>>> AbstractApplicationContext.java:682)
>>>>        at
>>>> org.springframework.context.support.AbstractApplicationContext.close(
>>>> AbstractApplicationContext.java:651)
>>>>        at
>>>> org.springframework.context.support.AbstractApplicationContext.destroy(
>>>> AbstractApplicationContext.java:639)
>>>>        at
>>>> org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(
>>>> AbstractXBeanDeployer.java:106)
>>>>        at
>>>> org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
>>>> BaseServiceUnitManager.java:88)
>>>>        at
>>>> org.apache.servicemix.common.BaseServiceUnitManager.deploy(
>>>> BaseServiceUnitManager.java:69)
>>>>        at
>>>>
>>>>
>>>>         
>> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
>>     
>>>> (DeploymentService.java:508)
>>>>        at
>>>>
>>>>
>>>>         
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
>>     
>>>> (AutoDeploymentService.java:353)
>>>>        at
>>>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive
>>>>         
>> (
>>     
>>>> AutoDeploymentService.java:256)
>>>>        at
>>>>
>>>>         
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
>>     
>>>> (AutoDeploymentService.java:658)
>>>>        at
>>>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
>>>> AutoDeploymentService.java:62)
>>>>        at
>>>> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
>>>> AutoDeploymentService.java:622)
>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>> ]]></stack-trace>
>>>>                                </msg-loc-info>
>>>>                        </exception-info>
>>>>                </task-result-details>
>>>>        </component-task-result-details>
>>>> </component-task-result>
>>>> </jbi-task-result>
>>>> </jbi-task>
>>>>
>>>>        at
>>>> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
>>>> ManagementSupport.java:125)
>>>>        at
>>>> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
>>>> ManagementSupport.java:111)
>>>>        at
>>>>
>>>>
>>>>         
>> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
>>     
>>>> (DeploymentService.java:543)
>>>>        at
>>>>
>>>>
>>>>         
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
>>     
>>>> (AutoDeploymentService.java:353)
>>>>        ... 6 more
>>>>
>>>>
>>>> The xbean:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <beans xmlns:drools="http://servicemix.apache.org/drools/1.0"
>>>>       xmlns:cp="http://www.compart.net/ns/jbi">
>>>>
>>>>  <drools:endpoint service="cp:inputRouter"
>>>>                   endpoint="inEndpoint"
>>>>                   namespaceContext="#nsContext"
>>>>                   ruleBaseResource="classpath:router.drl"
>>>>                   globals="#globals" />
>>>>
>>>>  <util:map id="globals">
>>>>        <entry key="constants" value-ref="constants" />
>>>>  </util:map>
>>>>  <bean id="constants" class="ConstantsHelper" />
>>>>
>>>>  <drools:namespace-context id="nsContext">
>>>>    <drools:namespaces>
>>>>      <drools:namespace
>>>> prefix="cp">http://www.compart.net/ns/jbi</drools:namespace>
>>>>    </drools:namespaces>
>>>>  </drools:namespace-context>
>>>>
>>>> </beans>
>>>>
>>>>
>>>> The drl:
>>>>
>>>>
>>>> package org.apache.servicemix.drools
>>>>
>>>> import org.apache.commons.logging.Log;
>>>> import org.apache.commons.logging.LogFactory;
>>>> import org.apache.servicemix.drools.model.Exchange;
>>>> import ConstantsHelper;
>>>>
>>>> global org.apache.servicemix.drools.model.JbiHelper jbi;
>>>> global ConstantsHelper constants;
>>>>
>>>> rule UnkownOperation
>>>>    when
>>>>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
>>>>                       operation != "{
>>>>         
>> http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
>> <http://www.compart.net/ns/jbi%7Dprocess>
>>     
>>>> "
>>>> )
>>>>    then
>>>>        jbi.fault("<UnknownOperation
>>>> xmlns='http://www.compart.net/ns/jbi'/<http://www.compart.net/ns/jbi%27/><
>>>>         
>> http://www.compart.net/ns/jbi%27/>
>>     
>>>>> ");
>>>>>
>>>>>           
>>>> end
>>>>
>>>> rule ProcessInputAFP
>>>>    when
>>>>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
>>>>                       operation == "{
>>>>         
>> http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
>> <http://www.compart.net/ns/jbi%7Dprocess>
>>     
>>>> "
>>>> )
>>>>        eval (isOfType(getFileName(me), "afp"))
>>>>    then
>>>>        jbi.getLogger().info("File " + getFileName(me) + " is of type
>>>> AFP");
>>>>        jbi.route("service:http://www.compart.net/ns/jbi/fileSender");
>>>> end
>>>>
>>>> function boolean isOfType(String fileName, String type) {
>>>>    return fileName.toLowerCase().endsWith("." + type.toLowerCase());
>>>> }
>>>>
>>>> function String getFileName(Exchange me) {
>>>>    if (me.getIn().getProperty("user-props") != null) {
>>>>        java.util.Map userProps =
>>>> (java.util.Map)me.getIn().getProperty("user-props");
>>>>        String fileName = userProps.get("file-name").toString();
>>>>        if (fileName != null) {
>>>>            return fileName;
>>>>        } else {
>>>>            return "";
>>>>        }
>>>>    } else {
>>>>        return "";
>>>>    }
>>>> }
>>>>
>>>>
>>>> The helper bean:
>>>>
>>>> public class ConstantsHelper
>>>> {
>>>>    public String getFileNameProperty()
>>>>        {
>>>>        return "file-name";
>>>>        }
>>>>
>>>>    public String getUserPropertiesKeyProperty()
>>>>        {
>>>>        return "user-props";
>>>>        }
>>>> }
>>>>
>>>>
>>>> I have no idea why the injection doesn't work. Any ideas?
>>>>
>>>> Regards,
>>>> Lars
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>>>         
>> http://www.nabble.com/Error-injecting-bean-into-servicemix-drools-service-unit-tp16418402s12049p16418402.html
>>     
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>
>
>
>   

Re: Error injecting bean into servicemix-drools service unit

Posted by Guillaume Nodet <gn...@gmail.com>.
On Tue, Apr 1, 2008 at 3:45 PM, Lars Heinemann <la...@compart.net>
wrote:

> Good hint, Guillaume.
> I put in the try/catch block and retried.


Cool. Wanna commit this change ?

For the exception below, you just have to add the spring util namespace to
the xbean.xml:
     xmlns:util="http://www.springframework.org/schema/util"


>
>
> This is the result now:
>
> ERROR - DroolsComponent                -
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
> Line 11 in XML document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml]
> is invalid; nested exception is org.xml.sax.SAXParseException: The prefix
> "util" for element "util:map" is not bound.
> ERROR - FileSystemXmlApplicationContext - Exception thrown from
> ApplicationListener handling ContextClosedEvent
> java.lang.IllegalStateException: ApplicationEventMulticaster not
> initialized - call 'refresh' before multicasting events via the context:
> org.apache.xbean.spring.context.FileSystemXmlApplicationContext@c1d35:
> display name [
> org.apache.xbean.spring.context.FileSystemXmlApplicationContext@c1d35];
> startup date [Tue Apr 01 15:42:46 CEST 2008]; root of context hierarchy
>        at
> org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster
> (AbstractApplicationContext.java:259)
>        at
> org.springframework.context.support.AbstractApplicationContext.publishEvent
> (AbstractApplicationContext.java:246)
>        at
> org.springframework.context.support.AbstractApplicationContext.doClose(
> AbstractApplicationContext.java:676)
>         at
> org.springframework.context.support.AbstractApplicationContext.close(
> AbstractApplicationContext.java:651)
>        at
> org.springframework.context.support.AbstractApplicationContext.destroy(
> AbstractApplicationContext.java:639)
>         at org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy
> (AbstractXBeanDeployer.java:108)
>         at org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
> BaseServiceUnitManager.java:88)
>        at org.apache.servicemix.common.BaseServiceUnitManager.deploy(
> BaseServiceUnitManager.java:69)
>        at
> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
> (DeploymentService.java:508)
>         at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(
> AutoDeploymentService.java:482)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents
> (AutoDeploymentService.java:535)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary
> (AutoDeploymentService.java:317)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
> AutoDeploymentService.java:254)
>         at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
> (AutoDeploymentService.java:658)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
> AutoDeploymentService.java:62)
>        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
> AutoDeploymentService.java:622)
>        at java.util.TimerThread.mainLoop(Timer.java:512)
>        at java.util.TimerThread.run(Timer.java:462)
> ERROR - DroolsComponent                - java.lang.IllegalStateException:
> BeanFactory not initialized or already closed - call 'refresh' before
> accessing beans via the ApplicationContext
> ERROR - AutoDeploymentService          - Failed to update Service
> Assembly: cp-inputrouter-sa-1.0-SNAPSHOT.0.tmp
> java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
> <jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message"
> version="1.0">
> <jbi-task-result>
> <frmwk-task-result>
> <frmwk-task-result-details>
> <task-result-details>
> <task-id>deploy</task-id>
> <task-result>FAILED</task-result>
> <message-type>ERROR</message-type>
> </task-result-details>
> </frmwk-task-result-details>
> </frmwk-task-result>
> <component-task-result xmlns="
> http://java.sun.com/xml/ns/jbi/management-message">
>        <component-name>servicemix-drools</component-name>
>        <component-task-result-details>
>                <task-result-details>
>                        <task-id>deploy</task-id>
>                        <task-result>FAILED</task-result>
>                        <message-type>ERROR</message-type>
>                        <task-status-msg>
> <msg-loc-info>
> <loc-token/>
> <loc-message>Could not deploy xbean service unit</loc-message>
> </msg-loc-info>
> </task-status-msg>
>                        <exception-info>
>                                <nesting-level>1</nesting-level>
>                                <msg-loc-info>
>                                        <loc-token/>
>                                         <loc-message>Line 11 in XML
> document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml]
> is invalid; nested exception is org.xml.sax.SAXParseException: The prefix
> "util" for element "util:map" is not bound.</loc-message>
>                                        <stack-trace><![CDATA[
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
> Line 11 in XML document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml]
> is invalid; nested exception is org.xml.sax.SAXParseException: The prefix
> "util" for element "util:map" is not bound.
> Caused by: org.xml.sax.SAXParseException: The prefix "util" for element
> "util:map" is not bound.
>        at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
> Source)
>        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown
> Source)
>        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> Source)
>        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> Source)
>        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
> Source)
>        at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
>        at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
> Source)
>        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
> Source)
>        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
>        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
>        at
> org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(
> DefaultDocumentLoader.java:76)
>        at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions
> (XmlBeanDefinitionReader.java:351)
>        at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions
> (XmlBeanDefinitionReader.java:303)
>        at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions
> (XmlBeanDefinitionReader.java:280)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
> (AbstractBeanDefinitionReader.java:131)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
> (AbstractBeanDefinitionReader.java:147)
>        at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
> (AbstractBeanDefinitionReader.java:173)
>        at
> org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions
> (AbstractXmlApplicationContext.java:112)
>        at
> org.apache.xbean.spring.context.FileSystemXmlApplicationContext.loadBeanDefinitions
> (FileSystemXmlApplicationContext.java:168)
>        at
> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory
> (AbstractRefreshableApplicationContext.java:101)
>        at
> org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory
> (AbstractApplicationContext.java:389)
>        at
> org.springframework.context.support.AbstractApplicationContext.refresh(
> AbstractApplicationContext.java:324)
>        at org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(
> AbstractXBeanDeployer.java:89)
>         at org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
> BaseServiceUnitManager.java:88)
>        at org.apache.servicemix.common.BaseServiceUnitManager.deploy(
> BaseServiceUnitManager.java:69)
>        at
> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
> (DeploymentService.java:508)
>         at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(
> AutoDeploymentService.java:482)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents
> (AutoDeploymentService.java:535)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary
> (AutoDeploymentService.java:317)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
> AutoDeploymentService.java:254)
>         at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
> (AutoDeploymentService.java:658)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
> AutoDeploymentService.java:62)
>        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
> AutoDeploymentService.java:622)
>        at java.util.TimerThread.mainLoop(Timer.java:512)
>        at java.util.TimerThread.run(Timer.java:462)
> ]]></stack-trace>
>                                </msg-loc-info>
>                        </exception-info>
>                </task-result-details>
>        </component-task-result-details>
> </component-task-result>
> </jbi-task-result>
> </jbi-task>
>
>        at org.apache.servicemix.jbi.framework.ManagementSupport.failure(
> ManagementSupport.java:125)
>        at org.apache.servicemix.jbi.framework.ManagementSupport.failure(
> ManagementSupport.java:111)
>        at
> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
> (DeploymentService.java:543)
>         at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(
> AutoDeploymentService.java:482)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents
> (AutoDeploymentService.java:535)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary
> (AutoDeploymentService.java:317)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
> AutoDeploymentService.java:254)
>         at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
> (AutoDeploymentService.java:658)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
> AutoDeploymentService.java:62)
>        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
> AutoDeploymentService.java:622)
>        at java.util.TimerThread.mainLoop(Timer.java:512)
>        at java.util.TimerThread.run(Timer.java:462)
>
>
> It seems the parser has no idea what to do with the <util:map> stuff in
> the xbean config.
>
> What to do now? Is there a namespace I can add?
>
> Regards,
> Lars
>
>
>
>
> Guillaume Nodet schrieb:
> > Sounds like another regression :-(
> > Given the stack trace, it seems there is an exception that is swallowed
> by
> > the exception displayed, because of the call to close/destroy.
> > This may mean we need to enclose the applicationContext.destroy(); in a
> > try/catch block in the AbstractXBeanDeployer#deploy() method.
> > Could you try that ?
> >
> > On Tue, Apr 1, 2008 at 2:56 PM, lhe77 <la...@compart.net>
> wrote:
> >
> >
> >> Hi,
> >>
> >> I did what is described on the servicemix-drools wiki page to inject an
> >> additional bean.
> >> When deploying it to smx it throws exception:
> >>
> >>
> >> WARN  - AutoDeploymentService          - Directory: hotdeploy:
> Automatic
> >> install of
> >> /opt/apache-servicemix-3.3-SNAPSHOT/hotdeploy/cp-
> >> inputrouter-sa-1.0-SNAPSHOT.zip
> >> failed
> >> javax.jbi.management.DeploymentException: Failed to update Service
> >> Assembly:
> >> cp-inputrouter-sa
> >>        at
> >>
> >>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
> >> (AutoDeploymentService.java:368)
> >>        at
> >> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive
> (
> >> AutoDeploymentService.java:256)
> >>        at
> >>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
> >> (AutoDeploymentService.java:658)
> >>        at
> >> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
> >> AutoDeploymentService.java:62)
> >>        at
> >> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
> >> AutoDeploymentService.java:622)
> >>        at java.util.TimerThread.mainLoop(Timer.java:512)
> >>        at java.util.TimerThread.run(Timer.java:462)
> >> Caused by: java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
> >> <jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message"
> >> version="1.0">
> >> <jbi-task-result>
> >> <frmwk-task-result>
> >> <frmwk-task-result-details>
> >> <task-result-details>
> >> <task-id>deploy</task-id>
> >> <task-result>FAILED</task-result>
> >> <message-type>ERROR</message-type>
> >> </task-result-details>
> >> </frmwk-task-result-details>
> >> </frmwk-task-result>
> >> <component-task-result
> >> xmlns="http://java.sun.com/xml/ns/jbi/management-message">
> >>        <component-name>servicemix-drools</component-name>
> >>        <component-task-result-details>
> >>                <task-result-details>
> >>                        <task-id>deploy</task-id>
> >>                        <task-result>FAILED</task-result>
> >>                        <message-type>ERROR</message-type>
> >>                        <task-status-msg>
> >> <msg-loc-info>
> >> <loc-token/>
> >> <loc-message>Unable to deploy service unit</loc-message>
> >> </msg-loc-info>
> >> </task-status-msg>
> >>                        <exception-info>
> >>                                <nesting-level>1</nesting-level>
> >>                                <msg-loc-info>
> >>                                        <loc-token/>
> >>                                        <loc-message>BeanFactory not
> >> initialized or already closed - call 'refresh' before accessing beans
> via
> >> the ApplicationContext</loc-message>
> >>
> >> <stack-trace><![CDATA[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:121)
> >>        at
> >>
> >>
> org.springframework.context.support.AbstractApplicationContext.getLifecycleBeans
> >> (AbstractApplicationContext.java:912)
> >>        at
> >> org.springframework.context.support.AbstractApplicationContext.stop(
> >> AbstractApplicationContext.java:886)
> >>        at
> >> org.springframework.context.support.AbstractApplicationContext.doClose(
> >> AbstractApplicationContext.java:682)
> >>        at
> >> org.springframework.context.support.AbstractApplicationContext.close(
> >> AbstractApplicationContext.java:651)
> >>        at
> >> org.springframework.context.support.AbstractApplicationContext.destroy(
> >> AbstractApplicationContext.java:639)
> >>        at
> >> org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(
> >> AbstractXBeanDeployer.java:106)
> >>        at
> >> org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
> >> BaseServiceUnitManager.java:88)
> >>        at
> >> org.apache.servicemix.common.BaseServiceUnitManager.deploy(
> >> BaseServiceUnitManager.java:69)
> >>        at
> >>
> >>
> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
> >> (DeploymentService.java:508)
> >>        at
> >>
> >>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
> >> (AutoDeploymentService.java:353)
> >>        at
> >> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive
> (
> >> AutoDeploymentService.java:256)
> >>        at
> >>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
> >> (AutoDeploymentService.java:658)
> >>        at
> >> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
> >> AutoDeploymentService.java:62)
> >>        at
> >> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
> >> AutoDeploymentService.java:622)
> >>        at java.util.TimerThread.mainLoop(Timer.java:512)
> >>        at java.util.TimerThread.run(Timer.java:462)
> >> ]]></stack-trace>
> >>                                </msg-loc-info>
> >>                        </exception-info>
> >>                </task-result-details>
> >>        </component-task-result-details>
> >> </component-task-result>
> >> </jbi-task-result>
> >> </jbi-task>
> >>
> >>        at
> >> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
> >> ManagementSupport.java:125)
> >>        at
> >> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
> >> ManagementSupport.java:111)
> >>        at
> >>
> >>
> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
> >> (DeploymentService.java:543)
> >>        at
> >>
> >>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
> >> (AutoDeploymentService.java:353)
> >>        ... 6 more
> >>
> >>
> >> The xbean:
> >>
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <beans xmlns:drools="http://servicemix.apache.org/drools/1.0"
> >>       xmlns:cp="http://www.compart.net/ns/jbi">
> >>
> >>  <drools:endpoint service="cp:inputRouter"
> >>                   endpoint="inEndpoint"
> >>                   namespaceContext="#nsContext"
> >>                   ruleBaseResource="classpath:router.drl"
> >>                   globals="#globals" />
> >>
> >>  <util:map id="globals">
> >>        <entry key="constants" value-ref="constants" />
> >>  </util:map>
> >>  <bean id="constants" class="ConstantsHelper" />
> >>
> >>  <drools:namespace-context id="nsContext">
> >>    <drools:namespaces>
> >>      <drools:namespace
> >> prefix="cp">http://www.compart.net/ns/jbi</drools:namespace>
> >>    </drools:namespaces>
> >>  </drools:namespace-context>
> >>
> >> </beans>
> >>
> >>
> >> The drl:
> >>
> >>
> >> package org.apache.servicemix.drools
> >>
> >> import org.apache.commons.logging.Log;
> >> import org.apache.commons.logging.LogFactory;
> >> import org.apache.servicemix.drools.model.Exchange;
> >> import ConstantsHelper;
> >>
> >> global org.apache.servicemix.drools.model.JbiHelper jbi;
> >> global ConstantsHelper constants;
> >>
> >> rule UnkownOperation
> >>    when
> >>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
> >>                       operation != "{
> http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
> <http://www.compart.net/ns/jbi%7Dprocess>
> >> "
> >> )
> >>    then
> >>        jbi.fault("<UnknownOperation
> >> xmlns='http://www.compart.net/ns/jbi'/<http://www.compart.net/ns/jbi%27/><
> http://www.compart.net/ns/jbi%27/>
> >>
> >>> ");
> >>>
> >> end
> >>
> >> rule ProcessInputAFP
> >>    when
> >>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
> >>                       operation == "{
> http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
> <http://www.compart.net/ns/jbi%7Dprocess>
> >> "
> >> )
> >>        eval (isOfType(getFileName(me), "afp"))
> >>    then
> >>        jbi.getLogger().info("File " + getFileName(me) + " is of type
> >> AFP");
> >>        jbi.route("service:http://www.compart.net/ns/jbi/fileSender");
> >> end
> >>
> >> function boolean isOfType(String fileName, String type) {
> >>    return fileName.toLowerCase().endsWith("." + type.toLowerCase());
> >> }
> >>
> >> function String getFileName(Exchange me) {
> >>    if (me.getIn().getProperty("user-props") != null) {
> >>        java.util.Map userProps =
> >> (java.util.Map)me.getIn().getProperty("user-props");
> >>        String fileName = userProps.get("file-name").toString();
> >>        if (fileName != null) {
> >>            return fileName;
> >>        } else {
> >>            return "";
> >>        }
> >>    } else {
> >>        return "";
> >>    }
> >> }
> >>
> >>
> >> The helper bean:
> >>
> >> public class ConstantsHelper
> >> {
> >>    public String getFileNameProperty()
> >>        {
> >>        return "file-name";
> >>        }
> >>
> >>    public String getUserPropertiesKeyProperty()
> >>        {
> >>        return "user-props";
> >>        }
> >> }
> >>
> >>
> >> I have no idea why the injection doesn't work. Any ideas?
> >>
> >> Regards,
> >> Lars
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Error-injecting-bean-into-servicemix-drools-service-unit-tp16418402s12049p16418402.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >>
> >
> >
> >
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: Error injecting bean into servicemix-drools service unit

Posted by Lars Heinemann <la...@compart.net>.
Good hint, Guillaume.
I put in the try/catch block and retried.

This is the result now:

ERROR - DroolsComponent                - org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix "util" for element "util:map" is not bound.
ERROR - FileSystemXmlApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.apache.xbean.spring.context.FileSystemXmlApplicationContext@c1d35: display name [org.apache.xbean.spring.context.FileSystemXmlApplicationContext@c1d35]; startup date [Tue Apr 01 15:42:46 CEST 2008]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:259)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
        at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:676)
        at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:651)
        at org.springframework.context.support.AbstractApplicationContext.destroy(AbstractApplicationContext.java:639)
        at org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:108)
        at org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(BaseServiceUnitManager.java:88)
        at org.apache.servicemix.common.BaseServiceUnitManager.deploy(BaseServiceUnitManager.java:69)
        at org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly(DeploymentService.java:508)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(AutoDeploymentService.java:482)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents(AutoDeploymentService.java:535)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary(AutoDeploymentService.java:317)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:254)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
ERROR - DroolsComponent                - java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
ERROR - AutoDeploymentService          - Failed to update Service Assembly: cp-inputrouter-sa-1.0-SNAPSHOT.0.tmp
java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
<jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message" version="1.0">
<jbi-task-result>
<frmwk-task-result>
<frmwk-task-result-details>
<task-result-details>
<task-id>deploy</task-id>
<task-result>FAILED</task-result>
<message-type>ERROR</message-type>
</task-result-details>
</frmwk-task-result-details>
</frmwk-task-result>
<component-task-result xmlns="http://java.sun.com/xml/ns/jbi/management-message">
        <component-name>servicemix-drools</component-name>
        <component-task-result-details>
                <task-result-details>
                        <task-id>deploy</task-id>
                        <task-result>FAILED</task-result>
                        <message-type>ERROR</message-type>
                        <task-status-msg>
<msg-loc-info>
<loc-token/>
<loc-message>Could not deploy xbean service unit</loc-message>
</msg-loc-info>
</task-status-msg>
                        <exception-info>
                                <nesting-level>1</nesting-level>
                                <msg-loc-info>
                                        <loc-token/>
                                        <loc-message>Line 11 in XML document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix "util" for element "util:map" is not bound.</loc-message>
                                        <stack-trace><![CDATA[org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from file [/opt/apache-servicemix-3.3-SNAPSHOT/data/smx/service-assemblies/cp-inputrouter-sa/version_1/sus/servicemix-drools/cp-inputrouter-su/xbean.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix "util" for element "util:map" is not bound.
Caused by: org.xml.sax.SAXParseException: The prefix "util" for element "util:map" is not bound.
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
        at org.apache.xbean.spring.context.FileSystemXmlApplicationContext.loadBeanDefinitions(FileSystemXmlApplicationContext.java:168)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
        at org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:89)
        at org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(BaseServiceUnitManager.java:88)
        at org.apache.servicemix.common.BaseServiceUnitManager.deploy(BaseServiceUnitManager.java:69)
        at org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly(DeploymentService.java:508)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(AutoDeploymentService.java:482)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents(AutoDeploymentService.java:535)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary(AutoDeploymentService.java:317)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:254)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
]]></stack-trace>
                                </msg-loc-info>
                        </exception-info>
                </task-result-details>
        </component-task-result-details>
</component-task-result>
</jbi-task-result>
</jbi-task>

        at org.apache.servicemix.jbi.framework.ManagementSupport.failure(ManagementSupport.java:125)
        at org.apache.servicemix.jbi.framework.ManagementSupport.failure(ManagementSupport.java:111)
        at org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly(DeploymentService.java:543)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(AutoDeploymentService.java:482)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents(AutoDeploymentService.java:535)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary(AutoDeploymentService.java:317)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:254)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62)
        at org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)


It seems the parser has no idea what to do with the <util:map> stuff in the xbean config.

What to do now? Is there a namespace I can add?

Regards,
Lars




Guillaume Nodet schrieb:
> Sounds like another regression :-(
> Given the stack trace, it seems there is an exception that is swallowed by
> the exception displayed, because of the call to close/destroy.
> This may mean we need to enclose the applicationContext.destroy(); in a
> try/catch block in the AbstractXBeanDeployer#deploy() method.
> Could you try that ?
>
> On Tue, Apr 1, 2008 at 2:56 PM, lhe77 <la...@compart.net> wrote:
>
>   
>> Hi,
>>
>> I did what is described on the servicemix-drools wiki page to inject an
>> additional bean.
>> When deploying it to smx it throws exception:
>>
>>
>> WARN  - AutoDeploymentService          - Directory: hotdeploy: Automatic
>> install of
>> /opt/apache-servicemix-3.3-SNAPSHOT/hotdeploy/cp-
>> inputrouter-sa-1.0-SNAPSHOT.zip
>> failed
>> javax.jbi.management.DeploymentException: Failed to update Service
>> Assembly:
>> cp-inputrouter-sa
>>        at
>>
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
>> (AutoDeploymentService.java:368)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
>> AutoDeploymentService.java:256)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
>> (AutoDeploymentService.java:658)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
>> AutoDeploymentService.java:62)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
>> AutoDeploymentService.java:622)
>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>        at java.util.TimerThread.run(Timer.java:462)
>> Caused by: java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
>> <jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message"
>> version="1.0">
>> <jbi-task-result>
>> <frmwk-task-result>
>> <frmwk-task-result-details>
>> <task-result-details>
>> <task-id>deploy</task-id>
>> <task-result>FAILED</task-result>
>> <message-type>ERROR</message-type>
>> </task-result-details>
>> </frmwk-task-result-details>
>> </frmwk-task-result>
>> <component-task-result
>> xmlns="http://java.sun.com/xml/ns/jbi/management-message">
>>        <component-name>servicemix-drools</component-name>
>>        <component-task-result-details>
>>                <task-result-details>
>>                        <task-id>deploy</task-id>
>>                        <task-result>FAILED</task-result>
>>                        <message-type>ERROR</message-type>
>>                        <task-status-msg>
>> <msg-loc-info>
>> <loc-token/>
>> <loc-message>Unable to deploy service unit</loc-message>
>> </msg-loc-info>
>> </task-status-msg>
>>                        <exception-info>
>>                                <nesting-level>1</nesting-level>
>>                                <msg-loc-info>
>>                                        <loc-token/>
>>                                        <loc-message>BeanFactory not
>> initialized or already closed - call 'refresh' before accessing beans via
>> the ApplicationContext</loc-message>
>>
>> <stack-trace><![CDATA[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:121)
>>        at
>>
>> org.springframework.context.support.AbstractApplicationContext.getLifecycleBeans
>> (AbstractApplicationContext.java:912)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.stop(
>> AbstractApplicationContext.java:886)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.doClose(
>> AbstractApplicationContext.java:682)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.close(
>> AbstractApplicationContext.java:651)
>>        at
>> org.springframework.context.support.AbstractApplicationContext.destroy(
>> AbstractApplicationContext.java:639)
>>        at
>> org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(
>> AbstractXBeanDeployer.java:106)
>>        at
>> org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
>> BaseServiceUnitManager.java:88)
>>        at
>> org.apache.servicemix.common.BaseServiceUnitManager.deploy(
>> BaseServiceUnitManager.java:69)
>>        at
>>
>> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
>> (DeploymentService.java:508)
>>        at
>>
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
>> (AutoDeploymentService.java:353)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
>> AutoDeploymentService.java:256)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
>> (AutoDeploymentService.java:658)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
>> AutoDeploymentService.java:62)
>>        at
>> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
>> AutoDeploymentService.java:622)
>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>        at java.util.TimerThread.run(Timer.java:462)
>> ]]></stack-trace>
>>                                </msg-loc-info>
>>                        </exception-info>
>>                </task-result-details>
>>        </component-task-result-details>
>> </component-task-result>
>> </jbi-task-result>
>> </jbi-task>
>>
>>        at
>> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
>> ManagementSupport.java:125)
>>        at
>> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
>> ManagementSupport.java:111)
>>        at
>>
>> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
>> (DeploymentService.java:543)
>>        at
>>
>> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
>> (AutoDeploymentService.java:353)
>>        ... 6 more
>>
>>
>> The xbean:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <beans xmlns:drools="http://servicemix.apache.org/drools/1.0"
>>       xmlns:cp="http://www.compart.net/ns/jbi">
>>
>>  <drools:endpoint service="cp:inputRouter"
>>                   endpoint="inEndpoint"
>>                   namespaceContext="#nsContext"
>>                   ruleBaseResource="classpath:router.drl"
>>                   globals="#globals" />
>>
>>  <util:map id="globals">
>>        <entry key="constants" value-ref="constants" />
>>  </util:map>
>>  <bean id="constants" class="ConstantsHelper" />
>>
>>  <drools:namespace-context id="nsContext">
>>    <drools:namespaces>
>>      <drools:namespace
>> prefix="cp">http://www.compart.net/ns/jbi</drools:namespace>
>>    </drools:namespaces>
>>  </drools:namespace-context>
>>
>> </beans>
>>
>>
>> The drl:
>>
>>
>> package org.apache.servicemix.drools
>>
>> import org.apache.commons.logging.Log;
>> import org.apache.commons.logging.LogFactory;
>> import org.apache.servicemix.drools.model.Exchange;
>> import ConstantsHelper;
>>
>> global org.apache.servicemix.drools.model.JbiHelper jbi;
>> global ConstantsHelper constants;
>>
>> rule UnkownOperation
>>    when
>>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
>>                       operation != "{http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
>> "
>> )
>>    then
>>        jbi.fault("<UnknownOperation
>> xmlns='http://www.compart.net/ns/jbi'/ <http://www.compart.net/ns/jbi%27/>
>>     
>>> ");
>>>       
>> end
>>
>> rule ProcessInputAFP
>>    when
>>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
>>                       operation == "{http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
>> "
>> )
>>        eval (isOfType(getFileName(me), "afp"))
>>    then
>>        jbi.getLogger().info("File " + getFileName(me) + " is of type
>> AFP");
>>        jbi.route("service:http://www.compart.net/ns/jbi/fileSender");
>> end
>>
>> function boolean isOfType(String fileName, String type) {
>>    return fileName.toLowerCase().endsWith("." + type.toLowerCase());
>> }
>>
>> function String getFileName(Exchange me) {
>>    if (me.getIn().getProperty("user-props") != null) {
>>        java.util.Map userProps =
>> (java.util.Map)me.getIn().getProperty("user-props");
>>        String fileName = userProps.get("file-name").toString();
>>        if (fileName != null) {
>>            return fileName;
>>        } else {
>>            return "";
>>        }
>>    } else {
>>        return "";
>>    }
>> }
>>
>>
>> The helper bean:
>>
>> public class ConstantsHelper
>> {
>>    public String getFileNameProperty()
>>        {
>>        return "file-name";
>>        }
>>
>>    public String getUserPropertiesKeyProperty()
>>        {
>>        return "user-props";
>>        }
>> }
>>
>>
>> I have no idea why the injection doesn't work. Any ideas?
>>
>> Regards,
>> Lars
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Error-injecting-bean-into-servicemix-drools-service-unit-tp16418402s12049p16418402.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>>     
>
>
>   

Re: Error injecting bean into servicemix-drools service unit

Posted by Guillaume Nodet <gn...@gmail.com>.
Sounds like another regression :-(
Given the stack trace, it seems there is an exception that is swallowed by
the exception displayed, because of the call to close/destroy.
This may mean we need to enclose the applicationContext.destroy(); in a
try/catch block in the AbstractXBeanDeployer#deploy() method.
Could you try that ?

On Tue, Apr 1, 2008 at 2:56 PM, lhe77 <la...@compart.net> wrote:

>
> Hi,
>
> I did what is described on the servicemix-drools wiki page to inject an
> additional bean.
> When deploying it to smx it throws exception:
>
>
> WARN  - AutoDeploymentService          - Directory: hotdeploy: Automatic
> install of
> /opt/apache-servicemix-3.3-SNAPSHOT/hotdeploy/cp-
> inputrouter-sa-1.0-SNAPSHOT.zip
> failed
> javax.jbi.management.DeploymentException: Failed to update Service
> Assembly:
> cp-inputrouter-sa
>        at
>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
> (AutoDeploymentService.java:368)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
> AutoDeploymentService.java:256)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
> (AutoDeploymentService.java:658)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
> AutoDeploymentService.java:62)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
> AutoDeploymentService.java:622)
>        at java.util.TimerThread.mainLoop(Timer.java:512)
>        at java.util.TimerThread.run(Timer.java:462)
> Caused by: java.lang.Exception: <?xml version="1.0" encoding="UTF-8"?>
> <jbi-task xmlns="http://java.sun.com/xml/ns/jbi/management-message"
> version="1.0">
> <jbi-task-result>
> <frmwk-task-result>
> <frmwk-task-result-details>
> <task-result-details>
> <task-id>deploy</task-id>
> <task-result>FAILED</task-result>
> <message-type>ERROR</message-type>
> </task-result-details>
> </frmwk-task-result-details>
> </frmwk-task-result>
> <component-task-result
> xmlns="http://java.sun.com/xml/ns/jbi/management-message">
>        <component-name>servicemix-drools</component-name>
>        <component-task-result-details>
>                <task-result-details>
>                        <task-id>deploy</task-id>
>                        <task-result>FAILED</task-result>
>                        <message-type>ERROR</message-type>
>                        <task-status-msg>
> <msg-loc-info>
> <loc-token/>
> <loc-message>Unable to deploy service unit</loc-message>
> </msg-loc-info>
> </task-status-msg>
>                        <exception-info>
>                                <nesting-level>1</nesting-level>
>                                <msg-loc-info>
>                                        <loc-token/>
>                                        <loc-message>BeanFactory not
> initialized or already closed - call 'refresh' before accessing beans via
> the ApplicationContext</loc-message>
>
> <stack-trace><![CDATA[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:121)
>        at
>
> org.springframework.context.support.AbstractApplicationContext.getLifecycleBeans
> (AbstractApplicationContext.java:912)
>        at
> org.springframework.context.support.AbstractApplicationContext.stop(
> AbstractApplicationContext.java:886)
>        at
> org.springframework.context.support.AbstractApplicationContext.doClose(
> AbstractApplicationContext.java:682)
>        at
> org.springframework.context.support.AbstractApplicationContext.close(
> AbstractApplicationContext.java:651)
>        at
> org.springframework.context.support.AbstractApplicationContext.destroy(
> AbstractApplicationContext.java:639)
>        at
> org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(
> AbstractXBeanDeployer.java:106)
>        at
> org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(
> BaseServiceUnitManager.java:88)
>        at
> org.apache.servicemix.common.BaseServiceUnitManager.deploy(
> BaseServiceUnitManager.java:69)
>        at
>
> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
> (DeploymentService.java:508)
>        at
>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
> (AutoDeploymentService.java:353)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(
> AutoDeploymentService.java:256)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory
> (AutoDeploymentService.java:658)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(
> AutoDeploymentService.java:62)
>        at
> org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(
> AutoDeploymentService.java:622)
>        at java.util.TimerThread.mainLoop(Timer.java:512)
>        at java.util.TimerThread.run(Timer.java:462)
> ]]></stack-trace>
>                                </msg-loc-info>
>                        </exception-info>
>                </task-result-details>
>        </component-task-result-details>
> </component-task-result>
> </jbi-task-result>
> </jbi-task>
>
>        at
> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
> ManagementSupport.java:125)
>        at
> org.apache.servicemix.jbi.framework.ManagementSupport.failure(
> ManagementSupport.java:111)
>        at
>
> org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly
> (DeploymentService.java:543)
>        at
>
> org.apache.servicemix.jbi.framework.AutoDeploymentService.updateServiceAssembly
> (AutoDeploymentService.java:353)
>        ... 6 more
>
>
> The xbean:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:drools="http://servicemix.apache.org/drools/1.0"
>       xmlns:cp="http://www.compart.net/ns/jbi">
>
>  <drools:endpoint service="cp:inputRouter"
>                   endpoint="inEndpoint"
>                   namespaceContext="#nsContext"
>                   ruleBaseResource="classpath:router.drl"
>                   globals="#globals" />
>
>  <util:map id="globals">
>        <entry key="constants" value-ref="constants" />
>  </util:map>
>  <bean id="constants" class="ConstantsHelper" />
>
>  <drools:namespace-context id="nsContext">
>    <drools:namespaces>
>      <drools:namespace
> prefix="cp">http://www.compart.net/ns/jbi</drools:namespace>
>    </drools:namespaces>
>  </drools:namespace-context>
>
> </beans>
>
>
> The drl:
>
>
> package org.apache.servicemix.drools
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.servicemix.drools.model.Exchange;
> import ConstantsHelper;
>
> global org.apache.servicemix.drools.model.JbiHelper jbi;
> global ConstantsHelper constants;
>
> rule UnkownOperation
>    when
>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
>                       operation != "{http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
> "
> )
>    then
>        jbi.fault("<UnknownOperation
> xmlns='http://www.compart.net/ns/jbi'/ <http://www.compart.net/ns/jbi%27/>
> >");
> end
>
> rule ProcessInputAFP
>    when
>        me : Exchange( status == Exchange.ACTIVE, in : in != null,
>                       operation == "{http://www.compart.net/ns/jbi}process<http://www.compart.net/ns/jbi%7Dprocess>
> "
> )
>        eval (isOfType(getFileName(me), "afp"))
>    then
>        jbi.getLogger().info("File " + getFileName(me) + " is of type
> AFP");
>        jbi.route("service:http://www.compart.net/ns/jbi/fileSender");
> end
>
> function boolean isOfType(String fileName, String type) {
>    return fileName.toLowerCase().endsWith("." + type.toLowerCase());
> }
>
> function String getFileName(Exchange me) {
>    if (me.getIn().getProperty("user-props") != null) {
>        java.util.Map userProps =
> (java.util.Map)me.getIn().getProperty("user-props");
>        String fileName = userProps.get("file-name").toString();
>        if (fileName != null) {
>            return fileName;
>        } else {
>            return "";
>        }
>    } else {
>        return "";
>    }
> }
>
>
> The helper bean:
>
> public class ConstantsHelper
> {
>    public String getFileNameProperty()
>        {
>        return "file-name";
>        }
>
>    public String getUserPropertiesKeyProperty()
>        {
>        return "user-props";
>        }
> }
>
>
> I have no idea why the injection doesn't work. Any ideas?
>
> Regards,
> Lars
>
> --
> View this message in context:
> http://www.nabble.com/Error-injecting-bean-into-servicemix-drools-service-unit-tp16418402s12049p16418402.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/