You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by jonesgeek <wi...@jonesgeeks.com> on 2010/09/15 16:04:43 UTC

Custom JBI component namespace issue SMX 4.2

Hello, I am trying to migrate from smx 3.3 to 4.2, and am getting stuck on a
custom JBI component.  This component (task) was written because we migrated
from a legacy system with a bunch of services that implements a simple
interface Task with a single method Task.process(Model ourModel).  The
custom component unmarshals our Model from the exchange, processes it with
the injected Task, marshals the Model, then puts the results on the
exchange.  This all worked well in smx 3.3, but I am having issues with the
custom namespace resolving in 4.2.

I tried to mirror the servicemix-file bundle as much as possible like
exporting the META-INF.services.org.apache.xbean.spring... file and so on. 
Everything looks to be there, and the bundle deploys correctly.

I am using Spring-DM to register the component as OSGi services:

<?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:ctx="http://www.springframework.org/schema/context"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context.xsd
  http://www.springframework.org/schema/util
  http://www.springframework.org/schema/util/spring-util.xsd
  http://www.springframework.org/schema/osgi
  http://www.springframework.org/schema/osgi/spring-osgi.xsd
  http://www.springframework.org/schema/osgi-compendium
 
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">

    <bean id="servicemix-task"
class="org.apache.servicemix.task.TaskComponent">
        <property name="executorFactory" ref="executorFactory" />
    </bean>

    <bean id="executorFactory"
class="org.apache.servicemix.executors.impl.ExecutorFactoryImpl">
        <property name="defaultConfig">
            <bean
class="org.apache.servicemix.executors.impl.ExecutorConfig">
                <property name="corePoolSize"
value="${threadPoolCorePoolSize}"/>
                <property name="maximumPoolSize"
value="${threadPoolMaximumPoolSize}"/>
                <property name="queueSize" value="${threadPoolQueueSize}"/>
            </bean>
        </property>
    </bean>

    <bean id="endpoint-tracker"
class="org.apache.servicemix.common.osgi.EndpointTracker">
        <property name="component" ref="servicemix-task" />
    </bean>

    <osgi:list id="endpoints"
               interface="org.apache.servicemix.common.osgi.EndpointWrapper"
               cardinality="0..N">
        <osgi:listener ref="endpoint-tracker" bind-method="register"
unbind-method="unregister" />
    </osgi:list>

    <osgi:service ref="servicemix-task"
interface="javax.jbi.component.Component">
        <osgi:service-properties>
            <entry key="NAME" value="servicemix-task" />
            <entry key="TYPE" value="service-engine" />
        </osgi:service-properties>
    </osgi:service>

    <osgix:cm-properties id="cmProps"
persistent-id="org.apache.servicemix.components.file">
        <prop key="threadPoolCorePoolSize">8</prop>
        <prop key="threadPoolMaximumPoolSize">32</prop>
        <prop key="threadPoolQueueSize">256</prop>
    </osgix:cm-properties>

    <ctx:property-placeholder properties-ref="cmProps" />
    
</beans>


and an example where I am trying to create the JBI endpoint:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:task="http://myorg.org/task/1.0"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:transformer="uri:myorg.org/task"
       xsi:schemaLocation="
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/util
         http://www.springframework.org/schema/util/spring-util.xsd
         http://www.springframework.org/schema/osgi
         http://www.springframework.org/schema/osgi/spring-osgi.xsd
         http://www.springframework.org/schema/osgi-compendium
        
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
         http://myorg.org/task/1.0
         http://myorg.org/task/1.0/servicemix-task.xsd
         http://www.springframework.org/schema/osgi
         http://www.springframework.org/schema/osgi/spring-osgi.xsd">

    <!-- Define a quartz endpoint, firing JBI exchangs every 500 ms -->
    <task:endpoint id="demoTransformerEndpoint" service="transformer:demo"
endpoint="TRANSFORMER">
        <property name="task" ref="demoTransformer" />
    </task:endpoint>
	
	<!-- Export the endpoints and create a service assembly -->
    <bean class="org.apache.servicemix.common.osgi.EndpointExporter" />

	<!-- Reference the Demo Transformer task that is exported from another
bundle -->
    <osgi:reference id="demoTransformer" interface="org.myorg.tasking.Task"
bean-name="demoTransformer" />
    
</beans>

Which results in a SAXParseException: Failed to read schema document
'http...'.  I don't get it, if I deploy a file-poller endpoint in the same
fashion, it works and resolves the namespace correctly.


Side note: I also tried to deploy using jbi packaging, but the
<osgi:reference> bean was giving me a deployment error saying "Error
creating bean with name 'demoTransformer': Invocation of init method failed;
nested exception is java.lang.IllegalArgumentException: Required
'bundleContext' property was not set.

Any help on this, or suggestions on how I could wrap these legacy tasks
differently using existing components would by tremendous, I've been banging
my head on this for over a week now.

Thanks, Will


-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Custom-JBI-component-namespace-issue-SMX-4-2-tp2840669p2840669.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Custom JBI component namespace issue SMX 4.2

Posted by jonesgeek <wi...@jonesgeeks.com>.
I figured out the namespacing issue, I was using an older version of the
xbean plugin, which created the spring.schemas file with the mappings like:

Http://org.myorg/task/1.0=servicemix-task.xsd

And with the new 3.5 version of the xbeans, it generates the mapping

Http://org.myorg/task/1.0/servicemix-task.xsd=servicemix-task.xsd

Which the spring extender was looking for.

-Will
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Custom-JBI-component-namespace-issue-SMX-4-2-tp2840669p2843233.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.