1


私は本の第14章「CamelinAction」の例に従いました。ビジネスロジックでミドルウェアを隠したい。「camel:run:」を使用して開発している間、すべてがかなりうまく機能しているように見えました。構成ファイルは以下のとおりです。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
">
      <!-- camel activemq component to connect to the broker -->
      <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
            <property name="brokerURL" value="tcp://localhost:61616" />
      </bean>

      <!-- the camel client -->
      <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
            <proxy id="StreamProxy" serviceInterface="ird.StockStream.StreamService"
                  serviceUrl="activemq:queue:queueStream" />
      </camel:camelContext>

</beans>

次に、servicemix内にデプロイするという要件が発生しました。私はヒューズガイドに従い、必要な手順を知るようになりました。Beanスキーマを(私が想定している)に変更する必要がありました

<

<?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:osgi="http://camel.apache.org/schema/osgi"
       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
       xmlns:ctx="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
       http://camel.apache.org/schema/osgi http://camel.apache.org/schema/osgi/camel-osgi.xsd
       http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
      <!-- camel activemq component to connect to the broker -->
      <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
            <property name="brokerURL" value="tcp://localhost:61616" />
      </bean>

      <!-- the camel client -->
      <osgi:camelContext xmlns="http://camel.apache.org/schema/spring">
            <proxy id="StreamProxy" serviceInterface="ird.StockStream.StreamService"
                  serviceUrl="activemq:queue:queueStream" />
      </osgi:camelContext>

</beans>

最後に、クライアントでプロキシを使用するために、次のことを行います。

AbstractXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
                              "classpath:META-INF/spring/camel-client.xml");
                  streamService=(StreamService) ctx.getBean("StreamProxy");

次のエラーが発生しますが、修正できないようです。私はここで何か悪いことをしているとは思わない、助けてください。私は検索を使い果たしましたが、誰もこの質問に答えることができないようです。ここでの助けはありがたいです。私のkaraf.framework=equinoxと正しいバンドルがインストールされています。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activemq' defined in class path resource [META-INF/spring/camel-client.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camelContext': FactoryBean threw exception on object creation; nested ex
lPointerException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
        at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:161)
        at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:51)
        at ird.StockStream.StreamClient.initProperties(StreamClient.java:83)
        at ird.StockStream.StreamClient.<init>(StreamClient.java:67)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:71)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:901)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
        at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
        at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camelContext': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:109)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1414)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:245)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
        at org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:95)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1405)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
        at org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:95)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1405)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        ... 34 more
Caused by: java.lang.NullPointerException
        at org.apache.camel.core.osgi.OsgiPackageScanClassResolver.<init>(OsgiPackageScanClassResolver.java:39)
        at org.apache.camel.core.osgi.OsgiCamelContextHelper.osgiUpdate(OsgiCamelContextHelper.java:45)
        at org.apache.camel.osgi.OsgiSpringCamelContext.<init>(OsgiSpringCamelContext.java:34)
        at org.apache.camel.osgi.CamelContextFactoryBean.newCamelContext(CamelContextFactoryBean.java:50)
        at org.apache.camel.spring.CamelContextFactoryBean.createContext(CamelContextFactoryBean.java:279)
        at org.apache.camel.spring.CamelContextFactoryBean.getContext(CamelContextFactoryBean.java:290)
        at org.apache.camel.spring.CamelContextFactoryBean.getContext(CamelContextFactoryBean.java:79)
        at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.getContext(AbstractCamelContextFactoryBean.java:594)
        at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.getObject(AbstractCamelContextFactoryBean.java:108)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
        ... 53 more
4

1 に答える 1

-1

名前空間は変更しないでください。名前空間http://camel.apache.org/schema/osgiは @deprecated です

また、Spring を使用して XML ファイルを再度ロードしないでください。

AbstractXmlApplicationContext ctx = new ClassPathXmlApplicationContext( "クラスパス:META-INF/spring/camel-client.xml");

そして、クライアントとはどういう意味ですか?クライアントが ESB 内で実行されているか、スタンドアロンから実行されているか。クライアントはどこで実行されていますか?

于 2010-11-03T09:41:10.730 に答える