You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by JimG <ji...@bull.com> on 2006/09/11 20:42:23 UTC

Pojo Support Example

I get the error given below when trying to get the Pojo Support Example to
work (http://www.servicemix.org/site/pojo-support.html), by starting it
with:
   servicemix servicemix.xml
Is this a user error on my part, or a problem with servicemix?

Apache ServiceMix ESB: 3.0-M2-incubating
Loading Apache ServiceMix from file: servicemix.xml
[INFO] SpringInitialContextFactory - Loading JNDI context from: class path
resource [jndi.xml]
[INFO] XBeanXmlBeanDefinitionReader - Loading XML bean definitions from
class path resource [jndi.xml]
[INFO] XBeanXmlBeanDefinitionReader - Loading XML bean definitions from
class path resource [tx.xml]
[INFO] XBeanXmlBeanDefinitionReader - Loading XML bean definitions from
class path resource [security.xml]
[INFO] ComponentMBeanImpl - Initializing component: #SubscriptionManager#
[INFO] DeploymentService - Restoring service assemblies
[INFO] JBIContainer - ServiceMix JBI Container (http://servicemix.org/)
name: ServiceMix running version: 3.0-M2-incubating
Caught: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jbi' defined in file
[C:\apache-servicemix-3.0-M2-incubating\examples\pojo\servicemix.xml]:
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: Component name: sender
 is bound to an object which is not a JBI component, it is of type:
org.apache.servicemix.components.pojo.MySender
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'jbi' defined in file
[C:\apache-servicemix-3.0-M2-incubating\examples\pojo\servicemix.xml]:
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: Component name: sender is boun
d to an object which is not a JBI component, it is of type:
org.apache.servicemix.components.pojo.MySender
Caused by: java.lang.IllegalArgumentException: Component name: sender is
bound to an object which is not a JBI component, it is of type:
org.apache.servicemix.components.pojo.MySender
        at
org.apache.servicemix.jbi.container.JBIContainer.activateComponent(JBIContainer.java:915)
        at
org.apache.servicemix.jbi.container.SpringJBIContainer.afterPropertiesSet(SpringJBIContainer.java:67)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:901)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:870)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:393)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:256)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:253)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:332)
        at
org.apache.xbean.spring.context.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:150)
        at
org.apache.xbean.spring.context.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:101)
        at org.apache.servicemix.Main.main(Main.java:80)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:461)


The servicemix.xml file is:

<beans xmlns:sm="http://servicemix.apache.org/config/1.0" 
      xmlns:foo="http://servicemix.org/cheese/">
  <classpath>
    <location>.</location>
  </classpath>
  <sm:container id="jbi" embedded="true">
    <sm:activationSpecs>
      <sm:activationSpec componentName="sender" service="foo:sender"
destinationService="foo:receiver">
         <sm:component><bean
class="org.apache.servicemix.components.pojo.MySender" /></sm:component>
      </sm:activationSpec>
      <sm:activationSpec id="receiver" service="foo:receiver">
         <sm:component><bean
class="org.apache.servicemix.components.pojo.MyReceiver"/></sm:component>
      </sm:activationSpec>
    </sm:activationSpecs>
  </sm:container>
</beans>

The sender source is the same as the example, with package and import
statements added (ditto for the receiver source):

package org.apache.servicemix.components.pojo;

import org.apache.commons.logging.*;

import javax.management.ObjectName;
import javax.xml.namespace.QName;

import javax.jbi.component.ComponentLifeCycle;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.InOnly;
import javax.jbi.messaging.MessageExchangeFactory;
import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.JBIException;
import javax.jbi.messaging.MessageExchange;

import org.apache.servicemix.MessageExchangeListener;
import org.apache.servicemix.jbi.jaxp.StringSource;
import org.apache.servicemix.tck.MessageList;

public class MySender implements ComponentLifeCycle {
    private ComponentContext context;
    private ObjectName extensionMBeanName;


    /**
     * Sends a number of messages
     */
    public void sendMessages(int count) throws MessagingException {
        DeliveryChannel deliveryChannel = context.getDeliveryChannel();
        MessageExchangeFactory factory =
deliveryChannel.createExchangeFactory();

        for (int i = 0; i < count; i++) {
            InOnly exchange = factory.createInOnlyExchange();
            NormalizedMessage message = exchange.createMessage();
            exchange.setInMessage(message);

            message.setProperty("id", new Integer(i));
            message.setContent(new StringSource("<example id=&apos;" + i +
"&apos;/>"));

            deliveryChannel.send(exchange);
        }
    }

    // ComponentLifeCycle interface
   
//-------------------------------------------------------------------------
    public ObjectName getExtensionMBeanName() {
        return extensionMBeanName;
    }

    public void init(ComponentContext context) throws JBIException {
        this.context = context;
    }

    public void shutDown() throws JBIException {
    }

    public void start() throws JBIException {
    }

    public void stop() throws JBIException {
    }


    // Properties
   
//-------------------------------------------------------------------------
    public void setExtensionMBeanName(ObjectName extensionMBeanName) {
        this.extensionMBeanName = extensionMBeanName;
    }
}


I used this ANT script for the compiles:

<project name="pojo" default="compile" basedir=".">
  <property name="class.dir" value="."/>
  <target name="clean">
    <delete dir="target" quiet="true"/>
    <delete dir="${class.dir}" quiet="true"/>
  </target>
  <target name="init">
    <path id="javac.classpath">
      <pathelement path="${class.dir}"/>
      <fileset dir="../../lib">
        <include name="**/*.jar"/>
      </fileset>
    </path>
  </target>
  <target name="compile" depends="init" description="Compile all Java">
    <javac srcdir="." destdir="${class.dir}">
      <classpath refid="javac.classpath"/>
    </javac>
  </target>
</project>

-- 
View this message in context: http://www.nabble.com/Pojo-Support-Example-tf2254209.html#a6252407
Sent from the ServiceMix - User forum at Nabble.com.


Re: Pojo Support Example

Posted by Guillaume Nodet <gn...@gmail.com>.
I guess you did additional manipulations of jars to be able
to start this example.  Using your files, it fails for me
with a NoClassDefFoundError: javax/jbi/component/ComponentLifeCycle.

You should move those class files to the conf dir or better, package
them in a jar in put this jar in the lib/optional folder.

On 9/11/06, JimG <ji...@bull.com> wrote:
>
>
> I get the error given below when trying to get the Pojo Support Example to
> work (http://www.servicemix.org/site/pojo-support.html), by starting it
> with:
>    servicemix servicemix.xml
> Is this a user error on my part, or a problem with servicemix?
>
> Apache ServiceMix ESB: 3.0-M2-incubating
> Loading Apache ServiceMix from file: servicemix.xml
> [INFO] SpringInitialContextFactory - Loading JNDI context from: class path
> resource [jndi.xml]
> [INFO] XBeanXmlBeanDefinitionReader - Loading XML bean definitions from
> class path resource [jndi.xml]
> [INFO] XBeanXmlBeanDefinitionReader - Loading XML bean definitions from
> class path resource [tx.xml]
> [INFO] XBeanXmlBeanDefinitionReader - Loading XML bean definitions from
> class path resource [security.xml]
> [INFO] ComponentMBeanImpl - Initializing component: #SubscriptionManager#
> [INFO] DeploymentService - Restoring service assemblies
> [INFO] JBIContainer - ServiceMix JBI Container (http://servicemix.org/)
> name: ServiceMix running version: 3.0-M2-incubating
> Caught: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'jbi' defined in file
> [C:\apache-servicemix-3.0-M2-incubating\examples\pojo\servicemix.xml]:
> Invocation of init method failed; nested exception is
> java.lang.IllegalArgumentException: Component name: sender
> is bound to an object which is not a JBI component, it is of type:
> org.apache.servicemix.components.pojo.MySender
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> with name 'jbi' defined in file
> [C:\apache-servicemix-3.0-M2-incubating\examples\pojo\servicemix.xml]:
> Invocation of init method failed; nested exception is
> java.lang.IllegalArgumentException: Component name: sender is boun
> d to an object which is not a JBI component, it is of type:
> org.apache.servicemix.components.pojo.MySender
> Caused by: java.lang.IllegalArgumentException: Component name: sender is
> bound to an object which is not a JBI component, it is of type:
> org.apache.servicemix.components.pojo.MySender
>         at
> org.apache.servicemix.jbi.container.JBIContainer.activateComponent(
> JBIContainer.java:915)
>         at
> org.apache.servicemix.jbi.container.SpringJBIContainer.afterPropertiesSet(
> SpringJBIContainer.java:67)
>         at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods
> (AbstractAutowireCapableBeanFactory.java:901)
>         at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean
> (AbstractAutowireCapableBeanFactory.java:870)
>         at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
> (AbstractAutowireCapableBeanFactory.java:393)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
> AbstractBeanFactory.java:256)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
> AbstractBeanFactory.java:167)
>         at
>
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
> (DefaultListableBeanFactory.java:253)
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(
> AbstractApplicationContext.java:332)
>         at
> org.apache.xbean.spring.context.FileSystemXmlApplicationContext.<init>(
> FileSystemXmlApplicationContext.java:150)
>         at
> org.apache.xbean.spring.context.FileSystemXmlApplicationContext.<init>(
> FileSystemXmlApplicationContext.java:101)
>         at org.apache.servicemix.Main.main(Main.java:80)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> :39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at
> org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:461)
>
>
> The servicemix.xml file is:
>
> <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>       xmlns:foo="http://servicemix.org/cheese/">
>   <classpath>
>     <location>.</location>
>   </classpath>
>   <sm:container id="jbi" embedded="true">
>     <sm:activationSpecs>
>       <sm:activationSpec componentName="sender" service="foo:sender"
> destinationService="foo:receiver">
>          <sm:component><bean
> class="org.apache.servicemix.components.pojo.MySender" /></sm:component>
>       </sm:activationSpec>
>       <sm:activationSpec id="receiver" service="foo:receiver">
>          <sm:component><bean
> class="org.apache.servicemix.components.pojo.MyReceiver"/></sm:component>
>       </sm:activationSpec>
>     </sm:activationSpecs>
>   </sm:container>
> </beans>
>
> The sender source is the same as the example, with package and import
> statements added (ditto for the receiver source):
>
> package org.apache.servicemix.components.pojo;
>
> import org.apache.commons.logging.*;
>
> import javax.management.ObjectName;
> import javax.xml.namespace.QName;
>
> import javax.jbi.component.ComponentLifeCycle;
> import javax.jbi.component.ComponentContext;
> import javax.jbi.messaging.MessagingException;
> import javax.jbi.messaging.InOnly;
> import javax.jbi.messaging.MessageExchangeFactory;
> import javax.jbi.messaging.NormalizedMessage;
> import javax.jbi.messaging.DeliveryChannel;
> import javax.jbi.messaging.ExchangeStatus;
> import javax.jbi.JBIException;
> import javax.jbi.messaging.MessageExchange;
>
> import org.apache.servicemix.MessageExchangeListener;
> import org.apache.servicemix.jbi.jaxp.StringSource;
> import org.apache.servicemix.tck.MessageList;
>
> public class MySender implements ComponentLifeCycle {
>     private ComponentContext context;
>     private ObjectName extensionMBeanName;
>
>
>     /**
>      * Sends a number of messages
>      */
>     public void sendMessages(int count) throws MessagingException {
>         DeliveryChannel deliveryChannel = context.getDeliveryChannel();
>         MessageExchangeFactory factory =
> deliveryChannel.createExchangeFactory();
>
>         for (int i = 0; i < count; i++) {
>             InOnly exchange = factory.createInOnlyExchange();
>             NormalizedMessage message = exchange.createMessage();
>             exchange.setInMessage(message);
>
>             message.setProperty("id", new Integer(i));
>             message.setContent(new StringSource("<example id=&apos;" + i +
> "&apos;/>"));
>
>             deliveryChannel.send(exchange);
>         }
>     }
>
>     // ComponentLifeCycle interface
>
>
> //-------------------------------------------------------------------------
>     public ObjectName getExtensionMBeanName() {
>         return extensionMBeanName;
>     }
>
>     public void init(ComponentContext context) throws JBIException {
>         this.context = context;
>     }
>
>     public void shutDown() throws JBIException {
>     }
>
>     public void start() throws JBIException {
>     }
>
>     public void stop() throws JBIException {
>     }
>
>
>     // Properties
>
>
> //-------------------------------------------------------------------------
>     public void setExtensionMBeanName(ObjectName extensionMBeanName) {
>         this.extensionMBeanName = extensionMBeanName;
>     }
> }
>
>
> I used this ANT script for the compiles:
>
> <project name="pojo" default="compile" basedir=".">
>   <property name="class.dir" value="."/>
>   <target name="clean">
>     <delete dir="target" quiet="true"/>
>     <delete dir="${class.dir}" quiet="true"/>
>   </target>
>   <target name="init">
>     <path id="javac.classpath">
>       <pathelement path="${class.dir}"/>
>       <fileset dir="../../lib">
>         <include name="**/*.jar"/>
>       </fileset>
>     </path>
>   </target>
>   <target name="compile" depends="init" description="Compile all Java">
>     <javac srcdir="." destdir="${class.dir}">
>       <classpath refid="javac.classpath"/>
>     </javac>
>   </target>
> </project>
>
> --
> View this message in context:
> http://www.nabble.com/Pojo-Support-Example-tf2254209.html#a6252407
> Sent from the ServiceMix - User forum at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet