Jeroen, The XML syntax you're using is the one for creating a lightweight container with a static configuration of the endpoints. If you want to deploy a SU with your provider endpoint, the xbean.xml only needs to contain the endpoint definition itself, something like...
<beans xmlns:sm="http://servicemix.apache.org/config/1.0" xmlns:file="http://servicemix.apache.org/file/1.0" xmlns:tut="urn:servicemix:tutorial" xmlns:my="http://org.apache.servicemix.samples.helloworld.bc/1.0"> <my:provider service="test:service" endpoint="endpoint"/> </beans> However, are you absolutely sure you need to write your own BC? For a lot of use cases, it's also an option to write a POJO and deploy that in a servicemix-bean SU. Your POJO can connect to the external service/protocol and send/receive JBI MessageExchanges -- the benefit of the POJO approach is that it's a lot easier to write and maintain. Have a look at http://servicemix.apache.org/should-i-create-my-own-jbi-components.html for a bit of background... Regards, Gert Vanthienen ------------------------ Open Source SOA: http://fusesource.com Blog: http://gertvanthienen.blogspot.com/ 2009/11/12 Jeroen Verhagen <[email protected]>: > > Hi all, > > I evaluating Servicemix (3.2.3) for the company I work for, I've gone > through the simple tutorial that moves files. > Because we'll need to write a custom component I followed the tutorial for > writing a custom BC and added that to my existing tutorial project. I've got > everything to compile but when I deploy the SA with the SU for the custom BC > I get the following error: > > WARN - AutoDeploymentService - Directory: hotdeploy: Automatic > install of > Z:\java\apache-servicemix-3.2.3\hotdeploy\tutorial-sa-1.0-SNAPSHOT.zip > failed > javax.jbi.management.DeploymentException: Failed to update Service Assembly: > tutorial-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:667) > at > org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:62) > at > org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:631) > 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>hello-world-bc</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>No endpoints found</loc-message> > </msg-loc-info> > </task-status-msg> > </task-result-details> > </component-task-result-details> > </component-task-result> > > > The beans.xml for the custom SU contains this: > > <beans xmlns:sm="http://servicemix.apache.org/config/1.0" > xmlns:file="http://servicemix.apache.org/file/1.0" > xmlns:tut="urn:servicemix:tutorial" > xmlns:my="http://org.apache.servicemix.samples.helloworld.bc/1.0"> > <sm:container id="jbi" embedded="true" createMBeanServer="false"> > <sm:activationSpecs> > <sm:activationSpec> > <sm:component> > <my:component> > <my:endpoints> > <my:provider service="test:service" > endpoint="endpoint"/> > </my:endpoints> > </my:component> > </sm:component> > </sm:activationSpec> > </sm:activationSpecs> > </sm:container> > </beans> > > I'm really stuck with this problem, can anybody please help me? > > Thanks and regards, > > Jeroen > > Btw: source of my custom component: > > /* > * Licensed to the Apache Software Foundation (ASF) under one or more > * contributor license agreements. See the NOTICE file distributed with > * this work for additional information regarding copyright ownership. > * The ASF licenses this file to You under the Apache License, Version 2.0 > * (the "License"); you may not use this file except in compliance with > * the License. You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > package org.apache.servicemix.samples.helloworld.bc; > > import java.util.List; > > import javax.jbi.servicedesc.ServiceEndpoint; > > import org.apache.servicemix.common.DefaultComponent; > import org.apache.servicemix.common.Endpoint; > > /** > * @org.apache.xbean.XBean element="component" > */ > public class MyComponent extends DefaultComponent { > > private MyEndpointType[] endpoints; > > public MyEndpointType[] getEndpoints() { > return endpoints; > } > > public void setEndpoints(MyEndpointType[] endpoints) { > this.endpoints = endpoints; > } > > protected List getConfiguredEndpoints() { > return asList(getEndpoints()); > } > > protected Class[] getEndpointClasses() { > return new Class[] {MyConsumerEndpoint.class, > MyProviderEndpoint.class}; > } > > protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception { > MyProviderEndpoint endpoint = new MyProviderEndpoint(this, ep); > // TODO: initialize endpoint here > endpoint.activate(); > return endpoint; > } > > } > > and my MyProviderEndpoint: > > /* > * Licensed to the Apache Software Foundation (ASF) under one or more > * contributor license agreements. See the NOTICE file distributed with > * this work for additional information regarding copyright ownership. > * The ASF licenses this file to You under the Apache License, Version 2.0 > * (the "License"); you may not use this file except in compliance with > * the License. You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > package org.apache.servicemix.samples.helloworld.bc; > > import javax.jbi.management.DeploymentException; > import javax.jbi.messaging.MessageExchange; > import javax.jbi.messaging.NormalizedMessage; > import javax.jbi.servicedesc.ServiceEndpoint; > import javax.xml.namespace.QName; > import javax.xml.transform.dom.DOMSource; > > import com.sun.org.apache.xpath.internal.CachedXPathAPI; > import org.apache.servicemix.common.DefaultComponent; > import org.apache.servicemix.common.ServiceUnit; > import org.apache.servicemix.common.endpoints.ProviderEndpoint; > import org.apache.servicemix.jbi.jaxp.SourceTransformer; > import org.apache.servicemix.jbi.jaxp.StringSource; > import org.w3c.dom.Node; > > /** > * @org.apache.xbean.XBean element="provider" > */ > public class MyProviderEndpoint extends ProviderEndpoint implements > MyEndpointType { > > public MyProviderEndpoint() { > } > > public MyProviderEndpoint(ServiceUnit serviceUnit, QName service, String > endpoint) { > super(serviceUnit, service, endpoint); > } > > public MyProviderEndpoint(DefaultComponent component, ServiceEndpoint > endpoint) { > super(component, endpoint); > } > > public void validate() throws DeploymentException { > super.validate(); > } > > protected void processInOnly(MessageExchange exchange, NormalizedMessage > in) throws Exception { > throw new UnsupportedOperationException("Unsupported MEP: " + > exchange.getPattern()); > } > > protected void processInOut(MessageExchange exchange, NormalizedMessage > in, NormalizedMessage out) throws Exception { > // Grab the in message > SourceTransformer sourceTransformer = new SourceTransformer(); > DOMSource inMessageXml = (DOMSource) > sourceTransformer.toDOMSource(in); > > // Parse out the actual message content > CachedXPathAPI xpath = new CachedXPathAPI(); > Node inMessageNode = xpath.selectSingleNode(inMessageXml.getNode(), > "/hello"); > String inMessage = inMessageNode.getTextContent(); > > // Create the out message and set it > String outMessage = "<hello>Message [" + inMessage + "] contains [" > + inMessage.getBytes().length + "] bytes</hello>"; > out.setContent(new StringSource(outMessage)); > } > > } > > -- > View this message in context: > http://old.nabble.com/Problem-getting-custom-BC-to-deploy-tp26321854p26321854.html > Sent from the ServiceMix - User mailing list archive at Nabble.com. > >
